@opensaas/stack-core 0.43.0 → 0.44.0-alpha.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 (641) hide show
  1. package/CHANGELOG.md +2720 -0
  2. package/README.md +182 -115
  3. package/dist/.build-hash +1 -0
  4. package/dist/access/declared-dependencies.d.ts +102 -88
  5. package/dist/access/declared-dependencies.d.ts.map +1 -1
  6. package/dist/access/declared-dependencies.js +83 -71
  7. package/dist/access/declared-dependencies.js.map +1 -1
  8. package/dist/access/depth-limits.d.ts +4 -0
  9. package/dist/access/depth-limits.d.ts.map +1 -1
  10. package/dist/access/depth-limits.js +4 -0
  11. package/dist/access/depth-limits.js.map +1 -1
  12. package/dist/access/engine.d.ts +68 -20
  13. package/dist/access/engine.d.ts.map +1 -1
  14. package/dist/access/engine.js +151 -37
  15. package/dist/access/engine.js.map +1 -1
  16. package/dist/access/errors.d.ts +33 -48
  17. package/dist/access/errors.d.ts.map +1 -1
  18. package/dist/access/errors.js +73 -63
  19. package/dist/access/errors.js.map +1 -1
  20. package/dist/access/field-access.d.ts +76 -5
  21. package/dist/access/field-access.d.ts.map +1 -1
  22. package/dist/access/field-access.js +235 -61
  23. package/dist/access/field-access.js.map +1 -1
  24. package/dist/access/field-visibility.d.ts +50 -4
  25. package/dist/access/field-visibility.d.ts.map +1 -1
  26. package/dist/access/field-visibility.js +143 -160
  27. package/dist/access/field-visibility.js.map +1 -1
  28. package/dist/access/index.d.ts +5 -12
  29. package/dist/access/index.d.ts.map +1 -1
  30. package/dist/access/index.js +6 -19
  31. package/dist/access/index.js.map +1 -1
  32. package/dist/access/orm-client.d.ts +19 -0
  33. package/dist/access/orm-client.d.ts.map +1 -0
  34. package/dist/access/orm-client.js +37 -0
  35. package/dist/access/orm-client.js.map +1 -0
  36. package/dist/access/query-validation.d.ts +7 -129
  37. package/dist/access/query-validation.d.ts.map +1 -1
  38. package/dist/access/query-validation.js +12 -314
  39. package/dist/access/query-validation.js.map +1 -1
  40. package/dist/access/system-fields.d.ts +2 -0
  41. package/dist/access/system-fields.d.ts.map +1 -0
  42. package/dist/access/system-fields.js +7 -0
  43. package/dist/access/system-fields.js.map +1 -0
  44. package/dist/access/transaction-registry.d.ts +25 -2
  45. package/dist/access/transaction-registry.d.ts.map +1 -1
  46. package/dist/access/transaction-registry.js +34 -17
  47. package/dist/access/transaction-registry.js.map +1 -1
  48. package/dist/access/types.d.ts +217 -131
  49. package/dist/access/types.d.ts.map +1 -1
  50. package/dist/config/field-kind.d.ts +66 -0
  51. package/dist/config/field-kind.d.ts.map +1 -0
  52. package/dist/config/field-kind.js +63 -0
  53. package/dist/config/field-kind.js.map +1 -0
  54. package/dist/config/hook-only-fields.d.ts +3 -0
  55. package/dist/config/hook-only-fields.d.ts.map +1 -0
  56. package/dist/config/hook-only-fields.js +17 -0
  57. package/dist/config/hook-only-fields.js.map +1 -0
  58. package/dist/config/index.d.ts +3 -1
  59. package/dist/config/index.d.ts.map +1 -1
  60. package/dist/config/index.js +6 -3
  61. package/dist/config/index.js.map +1 -1
  62. package/dist/config/mcp-tool-names.d.ts +3 -0
  63. package/dist/config/mcp-tool-names.d.ts.map +1 -0
  64. package/dist/config/mcp-tool-names.js +25 -0
  65. package/dist/config/mcp-tool-names.js.map +1 -0
  66. package/dist/config/nav-count.d.ts.map +1 -1
  67. package/dist/config/nav-count.js +4 -4
  68. package/dist/config/nav-count.js.map +1 -1
  69. package/dist/config/plugin-engine.d.ts +8 -2
  70. package/dist/config/plugin-engine.d.ts.map +1 -1
  71. package/dist/config/plugin-engine.js +102 -38
  72. package/dist/config/plugin-engine.js.map +1 -1
  73. package/dist/config/types.d.ts +966 -614
  74. package/dist/config/types.d.ts.map +1 -1
  75. package/dist/context/apply-defaults.d.ts +18 -1
  76. package/dist/context/apply-defaults.d.ts.map +1 -1
  77. package/dist/context/apply-defaults.js +30 -4
  78. package/dist/context/apply-defaults.js.map +1 -1
  79. package/dist/context/engine-context.d.ts +73 -0
  80. package/dist/context/engine-context.d.ts.map +1 -0
  81. package/dist/context/engine-context.js +67 -0
  82. package/dist/context/engine-context.js.map +1 -0
  83. package/dist/context/hook-pipeline.d.ts +9 -2
  84. package/dist/context/hook-pipeline.d.ts.map +1 -1
  85. package/dist/context/hook-pipeline.js +5 -4
  86. package/dist/context/hook-pipeline.js.map +1 -1
  87. package/dist/context/index.d.ts +98 -89
  88. package/dist/context/index.d.ts.map +1 -1
  89. package/dist/context/index.js +917 -722
  90. package/dist/context/index.js.map +1 -1
  91. package/dist/context/junction.d.ts +59 -0
  92. package/dist/context/junction.d.ts.map +1 -0
  93. package/dist/context/junction.js +126 -0
  94. package/dist/context/junction.js.map +1 -0
  95. package/dist/context/plugin-field-read.d.ts +33 -0
  96. package/dist/context/plugin-field-read.d.ts.map +1 -0
  97. package/dist/context/plugin-field-read.js +41 -0
  98. package/dist/context/plugin-field-read.js.map +1 -0
  99. package/dist/context/plugin-field-write.d.ts +104 -0
  100. package/dist/context/plugin-field-write.d.ts.map +1 -0
  101. package/dist/context/plugin-field-write.js +184 -0
  102. package/dist/context/plugin-field-write.js.map +1 -0
  103. package/dist/context/relationship-input.d.ts +146 -0
  104. package/dist/context/relationship-input.d.ts.map +1 -0
  105. package/dist/context/relationship-input.js +453 -0
  106. package/dist/context/relationship-input.js.map +1 -0
  107. package/dist/context/transaction-boundary.d.ts +54 -28
  108. package/dist/context/transaction-boundary.d.ts.map +1 -1
  109. package/dist/context/transaction-boundary.js +87 -169
  110. package/dist/context/transaction-boundary.js.map +1 -1
  111. package/dist/context/write-pipeline.d.ts +33 -51
  112. package/dist/context/write-pipeline.d.ts.map +1 -1
  113. package/dist/context/write-pipeline.js +372 -185
  114. package/dist/context/write-pipeline.js.map +1 -1
  115. package/dist/contract/dependencies.d.ts +88 -0
  116. package/dist/contract/dependencies.d.ts.map +1 -0
  117. package/dist/contract/dependencies.js +237 -0
  118. package/dist/contract/dependencies.js.map +1 -0
  119. package/dist/contract/derive.d.ts +49 -0
  120. package/dist/contract/derive.d.ts.map +1 -0
  121. package/dist/contract/derive.js +540 -0
  122. package/dist/contract/derive.js.map +1 -0
  123. package/dist/contract/fixtures/contract-configs.d.ts +64 -0
  124. package/dist/contract/fixtures/contract-configs.d.ts.map +1 -0
  125. package/dist/contract/fixtures/contract-configs.js +345 -0
  126. package/dist/contract/fixtures/contract-configs.js.map +1 -0
  127. package/dist/contract/id-boundary.d.ts +53 -0
  128. package/dist/contract/id-boundary.d.ts.map +1 -0
  129. package/dist/contract/id-boundary.js +76 -0
  130. package/dist/contract/id-boundary.js.map +1 -0
  131. package/dist/contract/index.d.ts +8 -0
  132. package/dist/contract/index.d.ts.map +1 -0
  133. package/dist/contract/index.js +11 -0
  134. package/dist/contract/index.js.map +1 -0
  135. package/dist/contract/prisma.d.ts +58 -0
  136. package/dist/contract/prisma.d.ts.map +1 -0
  137. package/dist/contract/prisma.js +282 -0
  138. package/dist/contract/prisma.js.map +1 -0
  139. package/dist/contract/relation-graph.d.ts +70 -0
  140. package/dist/contract/relation-graph.d.ts.map +1 -0
  141. package/dist/contract/relation-graph.js +113 -0
  142. package/dist/contract/relation-graph.js.map +1 -0
  143. package/dist/contract/types.d.ts +135 -0
  144. package/dist/contract/types.d.ts.map +1 -0
  145. package/dist/contract/types.js +2 -0
  146. package/dist/contract/types.js.map +1 -0
  147. package/dist/db/client.d.ts +55 -0
  148. package/dist/db/client.d.ts.map +1 -0
  149. package/dist/db/client.js +73 -0
  150. package/dist/db/client.js.map +1 -0
  151. package/dist/db/dev-database.d.ts +124 -0
  152. package/dist/db/dev-database.d.ts.map +1 -0
  153. package/dist/db/dev-database.js +291 -0
  154. package/dist/db/dev-database.js.map +1 -0
  155. package/dist/db/password-front.d.ts +10 -0
  156. package/dist/db/password-front.d.ts.map +1 -0
  157. package/dist/db/password-front.js +147 -0
  158. package/dist/db/password-front.js.map +1 -0
  159. package/dist/db/process-identity.d.ts +36 -0
  160. package/dist/db/process-identity.d.ts.map +1 -0
  161. package/dist/db/process-identity.js +114 -0
  162. package/dist/db/process-identity.js.map +1 -0
  163. package/dist/db/state-file.d.ts +54 -0
  164. package/dist/db/state-file.d.ts.map +1 -0
  165. package/dist/db/state-file.js +91 -0
  166. package/dist/db/state-file.js.map +1 -0
  167. package/dist/db/url.d.ts +89 -0
  168. package/dist/db/url.d.ts.map +1 -0
  169. package/dist/db/url.js +118 -0
  170. package/dist/db/url.js.map +1 -0
  171. package/dist/extend.d.ts +13 -2
  172. package/dist/extend.d.ts.map +1 -1
  173. package/dist/extend.js +24 -1
  174. package/dist/extend.js.map +1 -1
  175. package/dist/fields/index.d.ts +87 -42
  176. package/dist/fields/index.d.ts.map +1 -1
  177. package/dist/fields/index.js +457 -677
  178. package/dist/fields/index.js.map +1 -1
  179. package/dist/filter/collect.d.ts +3 -4
  180. package/dist/filter/collect.d.ts.map +1 -1
  181. package/dist/filter/collect.js +2 -2
  182. package/dist/filter/collect.js.map +1 -1
  183. package/dist/filter/index.d.ts +1 -2
  184. package/dist/filter/index.d.ts.map +1 -1
  185. package/dist/filter/index.js +0 -1
  186. package/dist/filter/index.js.map +1 -1
  187. package/dist/filter/map.d.ts +12 -5
  188. package/dist/filter/map.d.ts.map +1 -1
  189. package/dist/filter/map.js +47 -19
  190. package/dist/filter/map.js.map +1 -1
  191. package/dist/filter/types.d.ts +10 -24
  192. package/dist/filter/types.d.ts.map +1 -1
  193. package/dist/filter/types.js +2 -11
  194. package/dist/filter/types.js.map +1 -1
  195. package/dist/hooks/index.d.ts +22 -31
  196. package/dist/hooks/index.d.ts.map +1 -1
  197. package/dist/hooks/index.js +33 -37
  198. package/dist/hooks/index.js.map +1 -1
  199. package/dist/hooks/transition-guard.d.ts +61 -0
  200. package/dist/hooks/transition-guard.d.ts.map +1 -0
  201. package/dist/hooks/transition-guard.js +93 -0
  202. package/dist/hooks/transition-guard.js.map +1 -0
  203. package/dist/index.d.ts +52 -16
  204. package/dist/index.d.ts.map +1 -1
  205. package/dist/index.js +105 -51
  206. package/dist/index.js.map +1 -1
  207. package/dist/internal.d.ts +4 -2
  208. package/dist/internal.d.ts.map +1 -1
  209. package/dist/internal.js +16 -0
  210. package/dist/internal.js.map +1 -1
  211. package/dist/lib/case-utils.d.ts +0 -1
  212. package/dist/lib/case-utils.d.ts.map +1 -1
  213. package/dist/lib/case-utils.js +0 -3
  214. package/dist/lib/case-utils.js.map +1 -1
  215. package/dist/lib/client-safe-error.d.ts +9 -0
  216. package/dist/lib/client-safe-error.d.ts.map +1 -0
  217. package/dist/lib/client-safe-error.js +23 -0
  218. package/dist/lib/client-safe-error.js.map +1 -0
  219. package/dist/lib/database-errors.d.ts +78 -0
  220. package/dist/lib/database-errors.d.ts.map +1 -0
  221. package/dist/lib/database-errors.js +148 -0
  222. package/dist/lib/database-errors.js.map +1 -0
  223. package/dist/lib/null-prototype-registry.d.ts +9 -0
  224. package/dist/lib/null-prototype-registry.d.ts.map +1 -0
  225. package/dist/lib/null-prototype-registry.js +11 -0
  226. package/dist/lib/null-prototype-registry.js.map +1 -0
  227. package/dist/lib/prisma-errors.d.ts +30 -32
  228. package/dist/lib/prisma-errors.d.ts.map +1 -1
  229. package/dist/lib/prisma-errors.js +86 -46
  230. package/dist/lib/prisma-errors.js.map +1 -1
  231. package/dist/lib/process-global.d.ts +23 -0
  232. package/dist/lib/process-global.d.ts.map +1 -0
  233. package/dist/lib/process-global.js +33 -0
  234. package/dist/lib/process-global.js.map +1 -0
  235. package/dist/lib/warn-once.d.ts +7 -0
  236. package/dist/lib/warn-once.d.ts.map +1 -0
  237. package/dist/lib/warn-once.js +13 -0
  238. package/dist/lib/warn-once.js.map +1 -0
  239. package/dist/mcp/advertise.d.ts +16 -0
  240. package/dist/mcp/advertise.d.ts.map +1 -0
  241. package/dist/mcp/advertise.js +25 -0
  242. package/dist/mcp/advertise.js.map +1 -0
  243. package/dist/mcp/arguments.d.ts +10 -0
  244. package/dist/mcp/arguments.d.ts.map +1 -0
  245. package/dist/mcp/arguments.js +143 -0
  246. package/dist/mcp/arguments.js.map +1 -0
  247. package/dist/mcp/field-schema.d.ts +50 -5
  248. package/dist/mcp/field-schema.d.ts.map +1 -1
  249. package/dist/mcp/field-schema.js +137 -14
  250. package/dist/mcp/field-schema.js.map +1 -1
  251. package/dist/mcp/handler.d.ts +16 -5
  252. package/dist/mcp/handler.d.ts.map +1 -1
  253. package/dist/mcp/handler.js +404 -126
  254. package/dist/mcp/handler.js.map +1 -1
  255. package/dist/mcp/index.d.ts +1 -0
  256. package/dist/mcp/index.d.ts.map +1 -1
  257. package/dist/mcp/index.js +1 -0
  258. package/dist/mcp/index.js.map +1 -1
  259. package/dist/mcp/projection.d.ts +42 -34
  260. package/dist/mcp/projection.d.ts.map +1 -1
  261. package/dist/mcp/projection.js +246 -200
  262. package/dist/mcp/projection.js.map +1 -1
  263. package/dist/mcp/tool-error.d.ts +8 -0
  264. package/dist/mcp/tool-error.d.ts.map +1 -0
  265. package/dist/mcp/tool-error.js +11 -0
  266. package/dist/mcp/tool-error.js.map +1 -0
  267. package/dist/mcp/types.d.ts +3 -2
  268. package/dist/mcp/types.d.ts.map +1 -1
  269. package/dist/mcp/where-id-boundary.d.ts +28 -0
  270. package/dist/mcp/where-id-boundary.d.ts.map +1 -0
  271. package/dist/mcp/where-id-boundary.js +187 -0
  272. package/dist/mcp/where-id-boundary.js.map +1 -0
  273. package/dist/origin.d.ts +147 -0
  274. package/dist/origin.d.ts.map +1 -0
  275. package/dist/origin.js +191 -0
  276. package/dist/origin.js.map +1 -0
  277. package/dist/query/relationship-options.d.ts +35 -6
  278. package/dist/query/relationship-options.d.ts.map +1 -1
  279. package/dist/query/relationship-options.js +33 -23
  280. package/dist/query/relationship-options.js.map +1 -1
  281. package/dist/secured/aggregate.d.ts +32 -0
  282. package/dist/secured/aggregate.d.ts.map +1 -0
  283. package/dist/secured/aggregate.js +31 -0
  284. package/dist/secured/aggregate.js.map +1 -0
  285. package/dist/secured/include.d.ts +320 -0
  286. package/dist/secured/include.d.ts.map +1 -0
  287. package/dist/secured/include.js +650 -0
  288. package/dist/secured/include.js.map +1 -0
  289. package/dist/secured/lock.d.ts +127 -0
  290. package/dist/secured/lock.d.ts.map +1 -0
  291. package/dist/secured/lock.js +275 -0
  292. package/dist/secured/lock.js.map +1 -0
  293. package/dist/secured/lower.d.ts +82 -0
  294. package/dist/secured/lower.d.ts.map +1 -0
  295. package/dist/secured/lower.js +162 -0
  296. package/dist/secured/lower.js.map +1 -0
  297. package/dist/secured/operators.d.ts +7 -0
  298. package/dist/secured/operators.d.ts.map +1 -0
  299. package/dist/secured/operators.js +18 -0
  300. package/dist/secured/operators.js.map +1 -0
  301. package/dist/secured/read.d.ts +208 -0
  302. package/dist/secured/read.d.ts.map +1 -0
  303. package/dist/secured/read.js +1245 -0
  304. package/dist/secured/read.js.map +1 -0
  305. package/dist/secured/select.d.ts +87 -0
  306. package/dist/secured/select.d.ts.map +1 -0
  307. package/dist/secured/select.js +250 -0
  308. package/dist/secured/select.js.map +1 -0
  309. package/dist/secured/vector.d.ts +58 -0
  310. package/dist/secured/vector.d.ts.map +1 -0
  311. package/dist/secured/vector.js +113 -0
  312. package/dist/secured/vector.js.map +1 -0
  313. package/dist/secured/vocabulary.d.ts +227 -0
  314. package/dist/secured/vocabulary.d.ts.map +1 -0
  315. package/dist/secured/vocabulary.js +578 -0
  316. package/dist/secured/vocabulary.js.map +1 -0
  317. package/dist/secured/write.d.ts +58 -0
  318. package/dist/secured/write.d.ts.map +1 -0
  319. package/dist/secured/write.js +87 -0
  320. package/dist/secured/write.js.map +1 -0
  321. package/dist/testing/context.d.ts +236 -0
  322. package/dist/testing/context.d.ts.map +1 -0
  323. package/dist/testing/context.js +457 -0
  324. package/dist/testing/context.js.map +1 -0
  325. package/dist/testing/escape.d.ts +83 -0
  326. package/dist/testing/escape.d.ts.map +1 -0
  327. package/dist/testing/escape.js +148 -0
  328. package/dist/testing/escape.js.map +1 -0
  329. package/dist/testing/extensions.d.ts +48 -0
  330. package/dist/testing/extensions.d.ts.map +1 -0
  331. package/dist/testing/extensions.js +107 -0
  332. package/dist/testing/extensions.js.map +1 -0
  333. package/dist/testing/index.d.ts +5 -0
  334. package/dist/testing/index.d.ts.map +1 -0
  335. package/dist/testing/index.js +11 -0
  336. package/dist/testing/index.js.map +1 -0
  337. package/dist/testing/plans.d.ts +64 -0
  338. package/dist/testing/plans.d.ts.map +1 -0
  339. package/dist/testing/plans.js +47 -0
  340. package/dist/testing/plans.js.map +1 -0
  341. package/dist/types/context.d.ts +110 -0
  342. package/dist/types/context.d.ts.map +1 -0
  343. package/dist/types/context.js +2 -0
  344. package/dist/types/context.js.map +1 -0
  345. package/dist/types/contract.d.ts +198 -0
  346. package/dist/types/contract.d.ts.map +1 -0
  347. package/dist/types/contract.js +2 -0
  348. package/dist/types/contract.js.map +1 -0
  349. package/dist/types/index.d.ts +6 -0
  350. package/dist/types/index.d.ts.map +1 -0
  351. package/dist/types/index.js +11 -0
  352. package/dist/types/index.js.map +1 -0
  353. package/dist/types/inputs.d.ts +83 -0
  354. package/dist/types/inputs.d.ts.map +1 -0
  355. package/dist/types/inputs.js +2 -0
  356. package/dist/types/inputs.js.map +1 -0
  357. package/dist/types/rows.d.ts +76 -0
  358. package/dist/types/rows.d.ts.map +1 -0
  359. package/dist/types/rows.js +2 -0
  360. package/dist/types/rows.js.map +1 -0
  361. package/dist/types/secured-list.d.ts +396 -0
  362. package/dist/types/secured-list.d.ts.map +1 -0
  363. package/dist/types/secured-list.js +2 -0
  364. package/dist/types/secured-list.js.map +1 -0
  365. package/dist/unsafe.d.ts +162 -0
  366. package/dist/unsafe.d.ts.map +1 -0
  367. package/dist/unsafe.js +177 -0
  368. package/dist/unsafe.js.map +1 -0
  369. package/dist/validation/config-refusal.d.ts +16 -0
  370. package/dist/validation/config-refusal.d.ts.map +1 -0
  371. package/dist/validation/config-refusal.js +2 -0
  372. package/dist/validation/config-refusal.js.map +1 -0
  373. package/dist/validation/database-config.d.ts +19 -0
  374. package/dist/validation/database-config.d.ts.map +1 -0
  375. package/dist/validation/database-config.js +221 -0
  376. package/dist/validation/database-config.js.map +1 -0
  377. package/dist/validation/default-value.d.ts +21 -0
  378. package/dist/validation/default-value.d.ts.map +1 -0
  379. package/dist/validation/default-value.js +72 -0
  380. package/dist/validation/default-value.js.map +1 -0
  381. package/dist/validation/extension-packs.d.ts +11 -0
  382. package/dist/validation/extension-packs.d.ts.map +1 -0
  383. package/dist/validation/extension-packs.js +53 -0
  384. package/dist/validation/extension-packs.js.map +1 -0
  385. package/dist/validation/field-config.d.ts +35 -21
  386. package/dist/validation/field-config.d.ts.map +1 -1
  387. package/dist/validation/field-config.js +51 -41
  388. package/dist/validation/field-config.js.map +1 -1
  389. package/dist/validation/field-names.d.ts +15 -0
  390. package/dist/validation/field-names.d.ts.map +1 -0
  391. package/dist/validation/field-names.js +155 -0
  392. package/dist/validation/field-names.js.map +1 -0
  393. package/dist/validation/identifier-names.d.ts +4 -0
  394. package/dist/validation/identifier-names.d.ts.map +1 -0
  395. package/dist/validation/identifier-names.js +39 -0
  396. package/dist/validation/identifier-names.js.map +1 -0
  397. package/dist/validation/needs-closure.d.ts +20 -30
  398. package/dist/validation/needs-closure.d.ts.map +1 -1
  399. package/dist/validation/needs-closure.js +29 -105
  400. package/dist/validation/needs-closure.js.map +1 -1
  401. package/dist/validation/relations.d.ts +17 -0
  402. package/dist/validation/relations.d.ts.map +1 -0
  403. package/dist/validation/relations.js +268 -0
  404. package/dist/validation/relations.js.map +1 -0
  405. package/dist/validation/schema.d.ts.map +1 -1
  406. package/dist/validation/schema.js +1 -3
  407. package/dist/validation/schema.js.map +1 -1
  408. package/dist/where/like.d.ts +32 -0
  409. package/dist/where/like.d.ts.map +1 -0
  410. package/dist/where/like.js +42 -0
  411. package/dist/where/like.js.map +1 -0
  412. package/package.json +70 -8
  413. package/.turbo/turbo-build.log +0 -4
  414. package/CLAUDE.md +0 -609
  415. package/dist/access/access-filter.d.ts +0 -241
  416. package/dist/access/access-filter.d.ts.map +0 -1
  417. package/dist/access/access-filter.js +0 -692
  418. package/dist/access/access-filter.js.map +0 -1
  419. package/dist/access/access-filter.test.d.ts +0 -2
  420. package/dist/access/access-filter.test.d.ts.map +0 -1
  421. package/dist/access/access-filter.test.js +0 -1256
  422. package/dist/access/access-filter.test.js.map +0 -1
  423. package/dist/access/declared-dependencies.test.d.ts +0 -2
  424. package/dist/access/declared-dependencies.test.d.ts.map +0 -1
  425. package/dist/access/declared-dependencies.test.js +0 -226
  426. package/dist/access/declared-dependencies.test.js.map +0 -1
  427. package/dist/access/denied-relation-visibility.test.d.ts +0 -2
  428. package/dist/access/denied-relation-visibility.test.d.ts.map +0 -1
  429. package/dist/access/denied-relation-visibility.test.js +0 -114
  430. package/dist/access/denied-relation-visibility.test.js.map +0 -1
  431. package/dist/access/engine.test.d.ts +0 -2
  432. package/dist/access/engine.test.d.ts.map +0 -1
  433. package/dist/access/engine.test.js +0 -56
  434. package/dist/access/engine.test.js.map +0 -1
  435. package/dist/access/field-access.test.d.ts +0 -2
  436. package/dist/access/field-access.test.d.ts.map +0 -1
  437. package/dist/access/field-access.test.js +0 -635
  438. package/dist/access/field-access.test.js.map +0 -1
  439. package/dist/access/multi-column-read-write.test.d.ts +0 -2
  440. package/dist/access/multi-column-read-write.test.d.ts.map +0 -1
  441. package/dist/access/multi-column-read-write.test.js +0 -183
  442. package/dist/access/multi-column-read-write.test.js.map +0 -1
  443. package/dist/access/relationship-count.d.ts +0 -98
  444. package/dist/access/relationship-count.d.ts.map +0 -1
  445. package/dist/access/relationship-count.js +0 -262
  446. package/dist/access/relationship-count.js.map +0 -1
  447. package/dist/access/relationship-count.test.d.ts +0 -2
  448. package/dist/access/relationship-count.test.d.ts.map +0 -1
  449. package/dist/access/relationship-count.test.js +0 -247
  450. package/dist/access/relationship-count.test.js.map +0 -1
  451. package/dist/access/relationship-label-filter.d.ts +0 -45
  452. package/dist/access/relationship-label-filter.d.ts.map +0 -1
  453. package/dist/access/relationship-label-filter.js +0 -22
  454. package/dist/access/relationship-label-filter.js.map +0 -1
  455. package/dist/access/relationship-label-filter.test.d.ts +0 -2
  456. package/dist/access/relationship-label-filter.test.d.ts.map +0 -1
  457. package/dist/access/relationship-label-filter.test.js +0 -89
  458. package/dist/access/relationship-label-filter.test.js.map +0 -1
  459. package/dist/access/synthetic-include-read.test.d.ts +0 -2
  460. package/dist/access/synthetic-include-read.test.d.ts.map +0 -1
  461. package/dist/access/synthetic-include-read.test.js +0 -121
  462. package/dist/access/synthetic-include-read.test.js.map +0 -1
  463. package/dist/context/nested-operations.d.ts +0 -74
  464. package/dist/context/nested-operations.d.ts.map +0 -1
  465. package/dist/context/nested-operations.js +0 -847
  466. package/dist/context/nested-operations.js.map +0 -1
  467. package/dist/fields/calendar-day.test.d.ts +0 -2
  468. package/dist/fields/calendar-day.test.d.ts.map +0 -1
  469. package/dist/fields/calendar-day.test.js +0 -246
  470. package/dist/fields/calendar-day.test.js.map +0 -1
  471. package/dist/fields/format-prisma-default.d.ts +0 -35
  472. package/dist/fields/format-prisma-default.d.ts.map +0 -1
  473. package/dist/fields/format-prisma-default.js +0 -49
  474. package/dist/fields/format-prisma-default.js.map +0 -1
  475. package/dist/fields/format-prisma-default.test.d.ts +0 -2
  476. package/dist/fields/format-prisma-default.test.d.ts.map +0 -1
  477. package/dist/fields/format-prisma-default.test.js +0 -54
  478. package/dist/fields/format-prisma-default.test.js.map +0 -1
  479. package/dist/fields/relationship-foreign-key.test.d.ts +0 -2
  480. package/dist/fields/relationship-foreign-key.test.d.ts.map +0 -1
  481. package/dist/fields/relationship-foreign-key.test.js +0 -18
  482. package/dist/fields/relationship-foreign-key.test.js.map +0 -1
  483. package/dist/fields/select.test.d.ts +0 -2
  484. package/dist/fields/select.test.d.ts.map +0 -1
  485. package/dist/fields/select.test.js +0 -279
  486. package/dist/fields/select.test.js.map +0 -1
  487. package/dist/fields/text-keystone-compat.test.d.ts +0 -2
  488. package/dist/fields/text-keystone-compat.test.d.ts.map +0 -1
  489. package/dist/fields/text-keystone-compat.test.js +0 -93
  490. package/dist/fields/text-keystone-compat.test.js.map +0 -1
  491. package/dist/filter/filter.test.d.ts +0 -2
  492. package/dist/filter/filter.test.d.ts.map +0 -1
  493. package/dist/filter/filter.test.js +0 -431
  494. package/dist/filter/filter.test.js.map +0 -1
  495. package/dist/filter/serialize.test.d.ts +0 -2
  496. package/dist/filter/serialize.test.d.ts.map +0 -1
  497. package/dist/filter/serialize.test.js +0 -83
  498. package/dist/filter/serialize.test.js.map +0 -1
  499. package/dist/index.test.d.ts +0 -2
  500. package/dist/index.test.d.ts.map +0 -1
  501. package/dist/index.test.js +0 -33
  502. package/dist/index.test.js.map +0 -1
  503. package/dist/lib/case-utils.test.d.ts +0 -2
  504. package/dist/lib/case-utils.test.d.ts.map +0 -1
  505. package/dist/lib/case-utils.test.js +0 -123
  506. package/dist/lib/case-utils.test.js.map +0 -1
  507. package/dist/query/index.d.ts +0 -127
  508. package/dist/query/index.d.ts.map +0 -1
  509. package/dist/query/index.js +0 -179
  510. package/dist/query/index.js.map +0 -1
  511. package/dist/query/index.test.d.ts +0 -2
  512. package/dist/query/index.test.d.ts.map +0 -1
  513. package/dist/query/index.test.js +0 -632
  514. package/dist/query/index.test.js.map +0 -1
  515. package/dist/query/relationship-options.test.d.ts +0 -2
  516. package/dist/query/relationship-options.test.d.ts.map +0 -1
  517. package/dist/query/relationship-options.test.js +0 -150
  518. package/dist/query/relationship-options.test.js.map +0 -1
  519. package/dist/validation/field-config.test.d.ts +0 -2
  520. package/dist/validation/field-config.test.d.ts.map +0 -1
  521. package/dist/validation/field-config.test.js +0 -159
  522. package/dist/validation/field-config.test.js.map +0 -1
  523. package/dist/validation/schema.test.d.ts +0 -2
  524. package/dist/validation/schema.test.d.ts.map +0 -1
  525. package/dist/validation/schema.test.js +0 -409
  526. package/dist/validation/schema.test.js.map +0 -1
  527. package/docs/type-distribution-fix.md +0 -136
  528. package/src/access/access-filter.test.ts +0 -1919
  529. package/src/access/access-filter.ts +0 -1041
  530. package/src/access/declared-dependencies.test.ts +0 -277
  531. package/src/access/declared-dependencies.ts +0 -220
  532. package/src/access/denied-relation-visibility.test.ts +0 -173
  533. package/src/access/depth-limits.ts +0 -27
  534. package/src/access/engine.test.ts +0 -67
  535. package/src/access/engine.ts +0 -193
  536. package/src/access/errors.ts +0 -242
  537. package/src/access/field-access.test.ts +0 -792
  538. package/src/access/field-access.ts +0 -353
  539. package/src/access/field-transforms.ts +0 -68
  540. package/src/access/field-visibility.ts +0 -569
  541. package/src/access/index.ts +0 -82
  542. package/src/access/multi-column-read-write.test.ts +0 -305
  543. package/src/access/query-validation.ts +0 -486
  544. package/src/access/relationship-count.test.ts +0 -344
  545. package/src/access/relationship-count.ts +0 -346
  546. package/src/access/relationship-label-filter.test.ts +0 -128
  547. package/src/access/relationship-label-filter.ts +0 -63
  548. package/src/access/synthetic-include-read.test.ts +0 -179
  549. package/src/access/transaction-registry.ts +0 -58
  550. package/src/access/types.ts +0 -391
  551. package/src/config/index.ts +0 -177
  552. package/src/config/label.ts +0 -51
  553. package/src/config/nav-count.ts +0 -77
  554. package/src/config/plugin-engine.ts +0 -261
  555. package/src/config/types.ts +0 -3270
  556. package/src/context/apply-defaults.ts +0 -47
  557. package/src/context/hook-pipeline.ts +0 -137
  558. package/src/context/index.ts +0 -1737
  559. package/src/context/nested-operations.ts +0 -1470
  560. package/src/context/transaction-boundary.ts +0 -485
  561. package/src/context/write-pipeline.ts +0 -732
  562. package/src/extend.ts +0 -28
  563. package/src/fields/calendar-day.test.ts +0 -291
  564. package/src/fields/format-prisma-default.test.ts +0 -64
  565. package/src/fields/format-prisma-default.ts +0 -64
  566. package/src/fields/index.ts +0 -1901
  567. package/src/fields/relationship-foreign-key.test.ts +0 -29
  568. package/src/fields/select.test.ts +0 -336
  569. package/src/fields/text-keystone-compat.test.ts +0 -126
  570. package/src/filter/collect.ts +0 -108
  571. package/src/filter/filter.test.ts +0 -538
  572. package/src/filter/index.ts +0 -26
  573. package/src/filter/map.ts +0 -63
  574. package/src/filter/parse.ts +0 -99
  575. package/src/filter/serialize.test.ts +0 -115
  576. package/src/filter/serialize.ts +0 -73
  577. package/src/filter/types.ts +0 -120
  578. package/src/hooks/index.ts +0 -752
  579. package/src/index.test.ts +0 -50
  580. package/src/index.ts +0 -192
  581. package/src/internal.ts +0 -61
  582. package/src/lib/case-utils.test.ts +0 -159
  583. package/src/lib/case-utils.ts +0 -68
  584. package/src/lib/prisma-errors.ts +0 -86
  585. package/src/mcp/constants.ts +0 -24
  586. package/src/mcp/field-schema.ts +0 -84
  587. package/src/mcp/handler.ts +0 -633
  588. package/src/mcp/index.ts +0 -7
  589. package/src/mcp/projection.ts +0 -497
  590. package/src/mcp/types.ts +0 -18
  591. package/src/query/index.test.ts +0 -830
  592. package/src/query/index.ts +0 -352
  593. package/src/query/relationship-options.test.ts +0 -194
  594. package/src/query/relationship-options.ts +0 -78
  595. package/src/utils/password.ts +0 -80
  596. package/src/validation/field-config.test.ts +0 -199
  597. package/src/validation/field-config.ts +0 -139
  598. package/src/validation/needs-closure.ts +0 -188
  599. package/src/validation/schema.test.ts +0 -487
  600. package/src/validation/schema.ts +0 -51
  601. package/tests/access-relationships.test.ts +0 -646
  602. package/tests/access.test.ts +0 -590
  603. package/tests/apply-defaults.test.ts +0 -119
  604. package/tests/bare-read-scalars.test.ts +0 -147
  605. package/tests/computed-field-selective-evaluation.test.ts +0 -418
  606. package/tests/config.test.ts +0 -242
  607. package/tests/context.test.ts +0 -3146
  608. package/tests/default-value-create.test.ts +0 -299
  609. package/tests/field-hooks.test.ts +0 -410
  610. package/tests/field-types.test.ts +0 -1291
  611. package/tests/hook-context-secured.test.ts +0 -424
  612. package/tests/hook-pipeline.test.ts +0 -233
  613. package/tests/hooks.test.ts +0 -481
  614. package/tests/interactive-transaction.test.ts +0 -444
  615. package/tests/label.test.ts +0 -135
  616. package/tests/mcp-fields-projection-access.test.ts +0 -250
  617. package/tests/mcp-handler.test.ts +0 -1411
  618. package/tests/multi-column-validation-ordering.test.ts +0 -305
  619. package/tests/nav-count.test.ts +0 -189
  620. package/tests/needs-declared-dependencies.test.ts +0 -503
  621. package/tests/nested-access-and-hooks.test.ts +0 -2566
  622. package/tests/nested-operation-registry.test.ts +0 -317
  623. package/tests/nested-write-hooks.test.ts +0 -864
  624. package/tests/nested-write-synthetic-relation.test.ts +0 -437
  625. package/tests/password-type-distribution.test.ts +0 -154
  626. package/tests/password-types.test.ts +0 -174
  627. package/tests/password.test.ts +0 -263
  628. package/tests/plugin-engine.test.ts +0 -1155
  629. package/tests/prisma-errors.test.ts +0 -141
  630. package/tests/resolve-chain.test.ts +0 -411
  631. package/tests/singleton.test.ts +0 -421
  632. package/tests/sudo.test.ts +0 -676
  633. package/tests/to-one-include-access-filter.test.ts +0 -172
  634. package/tests/transaction-boundary-hooks.test.ts +0 -710
  635. package/tests/transaction-boundary-outermost.test.ts +0 -530
  636. package/tests/virtual-fields.test.ts +0 -421
  637. package/tests/with-session.test.ts +0 -243
  638. package/tests/write-pipeline.test.ts +0 -617
  639. package/tsconfig.json +0 -12
  640. package/tsconfig.tsbuildinfo +0 -1
  641. package/vitest.config.ts +0 -69
package/CHANGELOG.md CHANGED
@@ -1,5 +1,2720 @@
1
1
  # @opensaas/stack-core
2
2
 
3
+ ## 0.44.0-alpha.1
4
+
5
+ ### Minor Changes
6
+
7
+ - [#2101](https://github.com/OpenSaasAU/stack/pull/2101) [`0aac914`](https://github.com/OpenSaasAU/stack/commit/0aac914c03cb1ae9916e47ca990ac1045ed116ca) Thanks [@borisno2](https://github.com/borisno2)! - `db.indexes` entries accept `where`, a raw SQL predicate that makes the entry a partial index (or a partial unique index with `unique: true`), so partial unique invariants are declared rather than planned away.
8
+
9
+ ```typescript
10
+ db: {
11
+ indexes: [{ fields: ['twilioSid'], unique: true, where: `("twilioSid" <> ''::text)` }],
12
+ }
13
+ ```
14
+
15
+ - [#2113](https://github.com/OpenSaasAU/stack/pull/2113) [`5154e86`](https://github.com/OpenSaasAU/stack/commit/5154e86742ffda5643e63b8ecf04fb43e2bdd0bd) Thanks [@borisno2](https://github.com/borisno2)! - Add `db.indexNaming: 'prisma7'`, which names every derived index, unique constraint and foreign key `<Table>_<cols>_idx` / `_key` / `_fkey` (63-byte truncated), so adopting a Prisma 7 database plans no index renames.
16
+
17
+ - [#2103](https://github.com/OpenSaasAU/stack/pull/2103) [`273a682`](https://github.com/OpenSaasAU/stack/commit/273a68276223460f181b63b6dbdf8af47379f912) Thanks [@borisno2](https://github.com/borisno2)! - Add a `db.idField: 'cuid'` strategy for adopting a live database whose ids are `text` holding cuid v1 values. The column stays `text`, new rows get cuid2 values, and the id boundary accepts both cuid shapes, so no id or foreign-key column is altered.
18
+
19
+ ```typescript
20
+ export default config({ db: { provider: 'postgresql', idField: 'cuid' }, lists: {} })
21
+ ```
22
+
23
+ ### Patch Changes
24
+
25
+ - [#2111](https://github.com/OpenSaasAU/stack/pull/2111) [`cd5ea44`](https://github.com/OpenSaasAU/stack/commit/cd5ea4490f83e4a29e95de82243cd8bcd646ff13) Thanks [@borisno2](https://github.com/borisno2)! - `afterTransaction`'s `item` is now the raw persisted row, matching `originalItem` and `afterOperation`, instead of the caller's Field Visibility projection. The caller's return value is still projected.
26
+
27
+ - [#2107](https://github.com/OpenSaasAU/stack/pull/2107) [`856b1a4`](https://github.com/OpenSaasAU/stack/commit/856b1a4ba36b0105859c030457a654028d1baa57) Thanks [@borisno2](https://github.com/borisno2)! - Fix `combine()` rows branches bypassing the declared-dependency rule view, so `read` rules and `needs` hooks see unfiltered declared rows.
28
+
29
+ - [#2087](https://github.com/OpenSaasAU/stack/pull/2087) [`ffd993f`](https://github.com/OpenSaasAU/stack/commit/ffd993fc02941bbd3ba31957a6d0661975f198e9) Thanks [@borisno2](https://github.com/borisno2)! - A `delete()` that returns `null` after its hooks ran now rolls back the hooks' writes, and poisons an enclosing transaction, matching create and update.
30
+
31
+ - [#2115](https://github.com/OpenSaasAU/stack/pull/2115) [`5970719`](https://github.com/OpenSaasAU/stack/commit/5970719e647f8d33cdb22cac3943482c680b97c5) Thanks [@borisno2](https://github.com/borisno2)! - Fix `generate` failing with `CONTRACT.NAMESPACE_UNKNOWN` when a list declares `db.schema: 'public'`.
32
+
33
+ - [#2062](https://github.com/OpenSaasAU/stack/pull/2062) [`aa5d187`](https://github.com/OpenSaasAU/stack/commit/aa5d1876c58806762446922b48b85dfac0491bf2) Thanks [@borisno2](https://github.com/borisno2)! - A caught nested `tx.transaction()` callback rejection now poisons the owning transaction, so the outer transaction rolls back instead of committing the inner unit's writes.
34
+
35
+ - [#2058](https://github.com/OpenSaasAU/stack/pull/2058) [`d4a5302`](https://github.com/OpenSaasAU/stack/commit/d4a5302ac09f66f4ca77eb537c2da5977059a14a) Thanks [@borisno2](https://github.com/borisno2)! - A write that returns `null` after its hooks ran now rolls those hooks' writes back (and poisons an enclosing transaction), so `afterTransaction`'s `rolled-back` matches the database.
36
+
37
+ - [#2061](https://github.com/OpenSaasAU/stack/pull/2061) [`de62abd`](https://github.com/OpenSaasAU/stack/commit/de62abd46fdd9642d706df960e0ad71139f0b1a1) Thanks [@borisno2](https://github.com/borisno2)! - A `password()` field is no longer accepted in `where`, `orderBy` or `distinct`, so an MCP client cannot extract a hash with `contains`; it is refused as an unknown column is.
38
+
39
+ - [#2056](https://github.com/OpenSaasAU/stack/pull/2056) [`0930c89`](https://github.com/OpenSaasAU/stack/commit/0930c8902260453eb230de36fced121d620c1a91) Thanks [@borisno2](https://github.com/borisno2)! - Document and pin that an update with an empty resolved payload still runs `afterOperation`/`afterTransaction` (`committed`, `item === originalItem`).
40
+
41
+ - [#2057](https://github.com/OpenSaasAU/stack/pull/2057) [`841c88b`](https://github.com/OpenSaasAU/stack/commit/841c88be9bd758ef8ed8bcb07ee82d83a7d0ef4c) Thanks [@borisno2](https://github.com/borisno2)! - An access rule returning `null` or `undefined` now denies instead of throwing a raw `TypeError`, so reads of unrelated lists no longer break.
42
+
43
+ - [#2106](https://github.com/OpenSaasAU/stack/pull/2106) [`84e74e2`](https://github.com/OpenSaasAU/stack/commit/84e74e2ab9056f717b28d1a1a0259872a051a192) Thanks [@borisno2](https://github.com/borisno2)! - Refuse `limit`, `offset` and `orderBy` on a synthetic back-relation include whose source field has a row-dependent `read` rule, closing a paging existence oracle ([#1970](https://github.com/OpenSaasAU/stack/issues/1970)).
44
+
45
+ - [#2088](https://github.com/OpenSaasAU/stack/pull/2088) [`240fce6`](https://github.com/OpenSaasAU/stack/commit/240fce6a25f5d3fb9ddca8f37433624c5191dbd5) Thanks [@borisno2](https://github.com/borisno2)! - Fix `select()` inside a synthetic back-relation include skipping the source field's row-dependent `read` rule, which leaked or hid rows depending on the projection.
46
+
47
+ - [#2104](https://github.com/OpenSaasAU/stack/pull/2104) [`864da3a`](https://github.com/OpenSaasAU/stack/commit/864da3aba8fc322758be958a9785d19eef021714) Thanks [@borisno2](https://github.com/borisno2)! - Validate `decimal` precision/scale and the `defaultValue` of `checkbox`, `integer`, `bigInt`, `decimal`, `select` and `calendarDay` when the contract is derived, failing `opensaas generate` with an error naming the list, field and option.
48
+
49
+ - [#2105](https://github.com/OpenSaasAU/stack/pull/2105) [`e275bec`](https://github.com/OpenSaasAU/stack/commit/e275bec13258b15f9af54f3cddd874331d9bb8df) Thanks [@borisno2](https://github.com/borisno2)! - Cap caller `where` predicates at 5 nested relation quantifiers and 256 entries; exceeding either throws a `ValidationError` before any access rule runs.
50
+
51
+ ## 0.44.0-alpha.0
52
+
53
+ ### Minor Changes
54
+
55
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - `connect` on the foreign-key-owning field, with `null` as its counterpart
56
+
57
+ A write payload's `field: { connect: { id } }` is lowered onto the column the
58
+ row actually carries. The terminal issues the reachability query first — the
59
+ target list's `query` access ANDed with the identity criterion — then writes
60
+ the scalar foreign key, both inside the terminal's origin. `field: null`
61
+ clears the same column, which is what replaces nested `disconnect`
62
+ (ADR-0050).
63
+
64
+ ```typescript
65
+ await context.db.Post.create({ data: { title: 'Hello', author: { connect: { id: userId } } } })
66
+ await context.db.Post.update({ where: { id }, data: { author: null } })
67
+ ```
68
+
69
+ An unreadable target and one that does not exist are the same answer: the
70
+ write returns `null`, with no error and nothing written, so a foreign key
71
+ cannot become a probing oracle.
72
+
73
+ Three refusals name what a payload may carry on a relationship key:
74
+
75
+ - `NonOwningRelationInputError` — relation input on a field that owns no
76
+ foreign key (an inverse to-many, the non-owning half of a one-to-one, a
77
+ junction list's inverse, a synthetic back-relation). The generated input
78
+ types carry no member for those, so this is the runtime half of a compile
79
+ error.
80
+ - `MalformedRelationInputError` — an owning field carrying neither
81
+ `{ connect: { id } }` nor `null`.
82
+ - `RelationTargetMissingError` — a `connect` whose ref names a list the config
83
+ does not declare.
84
+
85
+ The relationship table's remove control follows the same rule: removing a row
86
+ through a to-one back-reference assigns `null` to it and the row survives,
87
+ while removing a junction row deletes it under that list's own delete access.
88
+
89
+ A relationship whose foreign key lives on the related row — a to-many, or the
90
+ non-owning half of a one-to-one — is not writable through the surfaces that
91
+ carry a payload for a single row, so neither surface offers it any more:
92
+
93
+ - The admin item form renders it read-only, stating that the related record
94
+ holds the link, instead of a picker whose selection had nowhere to go. An
95
+ item form ignores a change for any field it rendered read-only, so a field
96
+ component that does not honour the read mode it is handed cannot stage a
97
+ value the submit transform would then have to drop.
98
+ - The standalone `ItemCreateForm` / `ItemEditForm` take optional `listKey` and
99
+ `config` props. Given both, they mark the non-owning half of a one-to-one
100
+ the same way — a field config alone cannot answer which end holds the
101
+ column, so without them that end still renders a picker whose selection the
102
+ engine refuses at save.
103
+ - The MCP create/update tools omit it from the advertised `data` properties,
104
+ so a client cannot spell a call that could only fail.
105
+
106
+ On the end that does hold the column, the MCP schema now advertises `null`
107
+ alongside `connect`, so both spellings of an edge the engine accepts are
108
+ describable through the tool surface — and only those: the object form
109
+ requires `connect`, requires `id` within it, and admits no other key, matching
110
+ what the engine lowers rather than leaving the difference to prose.
111
+
112
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Export the access-filter builder from the public entry
113
+
114
+ `checkAccess`, `mergeFilters` and `checkCreateAccess` — the operation-level
115
+ access primitives — are now supported API on `@opensaas/stack-core`, with TSDoc. A
116
+ package that reads outside `context.db` (a vector search issuing its own SQL, a
117
+ plugin composing a filter) imports them instead of carrying a copy that drifts
118
+ from the engine's own evaluation (ADR-0038, ADR-0057):
119
+
120
+ ```typescript
121
+ import { checkAccess, mergeFilters } from '@opensaas/stack-core'
122
+
123
+ const result = await checkAccess(config.lists.Post.access?.operation?.query, {
124
+ session: context.session,
125
+ context,
126
+ })
127
+
128
+ // `null` is the Silent failure signal: denied, so do not query at all.
129
+ const where = mergeFilters(callerWhere, result)
130
+ if (where === null) return []
131
+ ```
132
+
133
+ An absent rule denies. A filter result is ANDed with the caller's `where`, never
134
+ merged key-by-key, so it can only ever narrow what the caller asked for. Gate a
135
+ `create` with `checkCreateAccess`, which refuses a filter result rather than
136
+ reading it as an allow (ADR-0030). All three scope rows, not fields: field-level
137
+ `read` access runs inside `context.db`, so a caller reading outside it is
138
+ responsible for field visibility itself.
139
+
140
+ `@opensaas/stack-rag` drops its own copies of both — the ones ADR-0038 names as
141
+ the reason this export exists — and calls core's. Behaviour is unchanged;
142
+ `buildAccessControlFilter`, `mergeAccessFilter` and `prismaFilterToSQL` keep
143
+ their signatures.
144
+
145
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - `context.prisma` becomes the Unsafe surface, `context.unsafe`
146
+
147
+ The deliberately unsecured handle now carries a name that states the bypass, and it is Prisma 8's own query lanes rather than a bare client. Everything the secured surface does, it skips — no access filter, no field visibility, no `resolveOutput`, no hooks, no error normalisation — and every execution enters the unsafe origin, so the tripwire lets it through and a query issued by neither surface is still refused.
148
+
149
+ ```typescript
150
+ // Before
151
+ const posts = await context.prisma.post.findMany()
152
+
153
+ // After — the ORM lane, behind a transparent proxy that marks every call
154
+ const posts = await context.unsafe.orm.public.Post.all()
155
+
156
+ // Rows, streamed, from a typed SQL plan
157
+ const rows = context.unsafe.query(context.unsafe.sql.public.Post.select('id').build())
158
+ for await (const row of rows) {
159
+ // consumed after the scope closed, still marked
160
+ }
161
+
162
+ // Statistics from a raw statement
163
+ const stats = await context.unsafe.execute(
164
+ context.unsafe.raw.sql`UPDATE "public"."Post" SET "published" = true`.affectedCount().build(),
165
+ )
166
+ ```
167
+
168
+ `sql` and `raw` are Prisma's builders untouched. The surface hands out neither the bare client nor `prepare()`/`runtime()` — they are not among its own members, in the type or in the runtime value — because either would execute a statement the tripwire never sees.
169
+
170
+ Inside `context.transaction(...)`, the transaction context's `unsafe` runs its plans through the transaction's own executor while keeping the client's contract-scoped raw lane, so a script no longer has to close over the outer client. The engine's own ORM handle is rebound to the transaction's collections at the same time: a Prisma 8 transaction holds one pooled connection for the whole callback, so a `db` left on the outer handle would commit outside the open transaction, or wait for a second connection the dev database's single-connection pool never frees.
171
+
172
+ Core exports the surface and its builders from `@opensaas/stack-core` and `@opensaas/stack-core/unsafe`; the generated context hands the client to `getContext` so it can build one.
173
+
174
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - A plugin's hooks survive on a list that declares hooks of its own
175
+
176
+ `extendList`'s hook merge copied only `resolveInput`, `validateInput`, `beforeOperation`
177
+ and `afterOperation`. When a list declared any hook itself, every other kind a plugin
178
+ added — `validate`, `beforeTransaction`, `afterTransaction` — was dropped on the floor, so
179
+ the plugin's side of the list silently stopped running:
180
+
181
+ ```typescript
182
+ Article: list({
183
+ fields: { content: searchable(text()) },
184
+ // Before: this one hook made ragPlugin's afterTransaction disappear, and the
185
+ // row was persisted with a null embedding, with nothing said.
186
+ hooks: { resolveInput: async ({ resolvedData }) => resolvedData },
187
+ })
188
+ ```
189
+
190
+ All hook kinds now merge, the list's own running first and the plugin's after it — the
191
+ order `resolveInput` already used.
192
+
193
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - A denied write to a multi-column field now throws instead of silently dropping the key
194
+
195
+ `splitMultiColumnFields` — the phase that turns a multi-column field's logical value into
196
+ its physical columns — dropped the key and continued when field-level write access denied
197
+ it, so the write "succeeded" while doing less than asked. `filterWritableFields` has
198
+ thrown for a denied single-column field since [#568](https://github.com/OpenSaasAU/stack/issues/568); this brings the multi-column path in
199
+ line with it.
200
+
201
+ ```typescript
202
+ // A field whose write is denied — @opensaas/stack-storage's multi-column
203
+ // image()/file(), or @opensaas/stack-rag's embedding()
204
+ await context.db.Article.update({
205
+ where: { id },
206
+ data: { contentEmbedding: myVector },
207
+ })
208
+ // Before: resolved successfully, and the vector was discarded.
209
+ // Now: throws ValidationError
210
+ // 'Cannot update "contentEmbedding": field-level access denied.'
211
+ ```
212
+
213
+ Sudo is unchanged: `checkFieldAccess` returns `true` under sudo, so an elevated write never
214
+ reaches the throw. A caller that relied on the silent drop to pass a denied field through
215
+ an ordinary write must stop sending the key, or write under `sudo()`.
216
+
217
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Move the toolchain to the Prisma 8 line and drop Prisma 7 and SQLite
218
+
219
+ The Prisma 8 ORM family (`@prisma/orm-postgres` at `8.0.0-rc.8`) and the `prisma` CLI (`8.0.0-rc.12`) are now the single pinned toolchain. `@prisma/client`, `@prisma/adapter-better-sqlite3` and every other Prisma 7 package are gone from every manifest, and every package states a Node `>=22.18.0` floor.
220
+
221
+ - `@opensaas/stack-core` peers on `@prisma/orm-postgres` instead of `@prisma/client`, and takes `@electric-sql/pglite`, `@electric-sql/pglite-socket` and `@electric-sql/pglite-pgvector` as optional peers for the in-process dev database.
222
+ - `@opensaas/stack-cli` depends on `prisma`, `@prisma/orm-postgres` and the three PGlite packages directly. `opensaas generate` runs `prisma` from the app's own `node_modules/.bin`, so the app must still list `prisma@8.0.0-rc.12` as a devDependency and `@prisma/orm-postgres@8.0.0-rc.8` as a dependency itself.
223
+
224
+ An app on this line installs the family alongside the stack:
225
+
226
+ ```bash
227
+ pnpm add @prisma/orm-postgres@8.0.0-rc.8
228
+ pnpm add -D prisma@8.0.0-rc.12
229
+ ```
230
+
231
+ This is the first step of the Prisma 8 build ([#1121](https://github.com/OpenSaasAU/stack/issues/1121)); the generator, runtime and examples follow in later releases.
232
+
233
+ - [#1895](https://github.com/OpenSaasAU/stack/pull/1895) [`56a8ce5`](https://github.com/OpenSaasAU/stack/commit/56a8ce57c8dbde712e885655d9c8c7e786ab9e50) Thanks [@borisno2](https://github.com/borisno2)! - `checkbox()` now defaults to `false` when no `defaultValue` is set, matching Keystone
234
+
235
+ Creating a row that omits a checkbox field no longer fails with a not-null `DatabaseError`; it reads back `false`. An explicit `defaultValue: true` is unchanged, and `db.isNullable: true` keeps the column nullable while still defaulting to `false`.
236
+
237
+ Migration note: existing projects get `DEFAULT false` on checkbox columns at their next migration. Existing rows are not backfilled. This also applies to boolean columns `@opensaas/stack-auth` derives without an upstream default (e.g. the MCP plugin's `skipConsent` and `requirePKCE`).
238
+
239
+ - [#1768](https://github.com/OpenSaasAU/stack/pull/1768) [`de2bd7a`](https://github.com/OpenSaasAU/stack/commit/de2bd7a035ee60fc09d0718885148eeaafecd798) Thanks [@borisno2](https://github.com/borisno2)! - A throwing `afterTransaction` hook is reported, never propagated
240
+
241
+ A committed write, and `context.transaction()`, now resolve even when an `afterTransaction` hook throws. The error goes to the new `onAfterTransactionError` config callback, or to `console.error` by default. A rejection always means the write did not persist. `AfterTransactionError` is removed.
242
+
243
+ ```typescript
244
+ config({
245
+ db: { provider: 'postgresql' },
246
+ lists: {},
247
+ onAfterTransactionError: ({ error, status, listKey, operation }) => {
248
+ logger.error({ error, status, listKey, operation }, 'afterTransaction failed')
249
+ },
250
+ })
251
+ ```
252
+
253
+ Migration: `AfterTransactionError` is no longer thrown or exported, so code matching `error.name === 'AfterTransactionError'` should move that handling into `onAfterTransactionError`.
254
+
255
+ - [#1781](https://github.com/OpenSaasAU/stack/pull/1781) [`6e0db6b`](https://github.com/OpenSaasAU/stack/commit/6e0db6bdc39f047f4eb62523765054826327214e) Thanks [@borisno2](https://github.com/borisno2)! - `transitionGuard()` enforces a state machine on a `select` field
256
+
257
+ Returns a list-level `validate` hook, so it runs for every caller (`sudo()` included) and checks values set by `resolveInput`. An optional stored `discriminator` field keys the allow-list.
258
+
259
+ ```typescript
260
+ import { transitionGuard } from '@opensaas/stack-core'
261
+
262
+ hooks: {
263
+ validate: transitionGuard({
264
+ field: 'state',
265
+ discriminator: 'action',
266
+ initial: { EDIT: ['PREPARED'] },
267
+ allowed: { EDIT: { PREPARED: ['DISPATCHING'] } },
268
+ }),
269
+ }
270
+ ```
271
+
272
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Automatic embedding generation runs, and the package no longer says otherwise
273
+
274
+ `@opensaas/stack-rag` was built and documented while the secured write surface could not
275
+ execute on the Prisma 8 collection, so the plugin's escalated write threw on every
276
+ invocation. That surface now executes, and generation with it:
277
+ `context.db.Article.create({ data: { content } })` commits the row, and once that
278
+ transaction settles the plugin embeds the **persisted** source text and writes the vector
279
+ and its metadata past that field's own write denial. Writing the source text again
280
+ regenerates it; a write that leaves the source text alone does not, because the
281
+ `sourceHash` on the stored metadata short-circuits.
282
+
283
+ Everything written for the inert surface is gone with it:
284
+
285
+ - `generation-failure.ts` no longer classifies "the secured write surface has not been
286
+ ported" as a standing defect. The predicate matched
287
+ `findUnique is not a function` / `Unknown column "data"`, neither of which the write
288
+ pipeline can now raise, and the branch logged
289
+ `EMBEDDING GENERATION IS NOT RUNNING … No config change works around it` — a false
290
+ statement to a user. A provider `type` no factory answers to is still reported as
291
+ standing; everything else is still reported per occurrence as transient.
292
+ - The write denial and the search helpers are tested through `context.db` rather than
293
+ through `hookPipeline`, and every vector under assertion is one the generation hook
294
+ produced from source text written through the same surface. `allowManualWrites` is
295
+ asserted by reading the columns back rather than by inspecting resolved data.
296
+
297
+ `hookPipeline` is no longer exported from `@opensaas/stack-core/internal`. It was added
298
+ there so `@opensaas/stack-rag` could prove its write denial one layer below
299
+ `context.db`, which was the deepest seam that then existed; nothing depends on it now.
300
+ That path carries no semver guarantee and the export was never released.
301
+
302
+ `allowManualWrites` remains the deliberate opt-out for an application that maintains its
303
+ own vectors — it is not a workaround for anything:
304
+
305
+ ```typescript
306
+ manualVector: embedding({ dimensions: 1536, allowManualWrites: true })
307
+ ```
308
+
309
+ Core's multi-column write-access gate is now also proven through `context.db`: a denied
310
+ create or update throws naming the field and leaves the per-part columns untouched, a
311
+ granted one writes both, `sudo()` bypasses the gate, and clearing the field with `null`
312
+ clears both columns.
313
+
314
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Every write through `context.db` opens a real Prisma 8 transaction again
315
+
316
+ The Write Pipeline decided whether to open a transaction by probing the client
317
+ for `$transaction` — the Prisma 7 name, which no Prisma 8 object carries. The
318
+ guard was constant-false, so every write ran with no transaction and no
319
+ rollback guarantee: a multi-statement write that failed partway, or a hook that
320
+ threw after the database call, left its rows committed.
321
+
322
+ The transaction capability is now an explicit signal rather than a probed
323
+ method name. `getContext` resolves a `TransactionOpener` from the Prisma 8
324
+ client it is handed, and puts it on the context; a context that is already
325
+ bound to an open transaction — `context.transaction()`'s callback, a hook's
326
+ rebound context — carries none, so a joined write still joins the enclosing
327
+ transaction rather than opening a second one (ADR-0028). `context.transaction()`
328
+ opens through the same opener, so both paths share one mechanism.
329
+
330
+ The generated context now hands `getContext` the ORM handle rather than the
331
+ client, which is what the engine reaches models through:
332
+
333
+ ```typescript
334
+ // .opensaas/context.ts (generated)
335
+ getOpensaasContext(
336
+ config,
337
+ ormHandleFor(config, db),
338
+ session,
339
+ storage,
340
+ false,
341
+ undefined,
342
+ undefined,
343
+ db,
344
+ )
345
+ ```
346
+
347
+ `requireOrmHandle(config, orm)` is exported from `@opensaas/stack-core` for a
348
+ caller that builds a context over a Prisma 8 client of its own, and throws
349
+ `OrmHandleUnresolvableError` naming the list whose collection the client does
350
+ not expose.
351
+
352
+ A context built over a Prisma 8 client whose collections do not cover the
353
+ config now refuses at construction rather than quietly downgrading its writes
354
+ to non-transactional. This widens the blast radius of contract drift: before,
355
+ a list the client couldn't reach only errored when that list was actually
356
+ used (`OrmModelMissingError`, lazily, per operation) while every other list
357
+ kept working; now the whole context fails to build — no list is usable —
358
+ the moment any one of them is unresolvable. Reviewers judged that the right
359
+ trade for [#1262](https://github.com/OpenSaasAU/stack/issues/1262): a context that can silently downgrade every write's
360
+ atomicity is a worse failure mode than refusing outright, and contract drift
361
+ this severe should fail loudly rather than only on the paths a test happens
362
+ to exercise.
363
+
364
+ `context.transaction()` over a client that can neither open a transaction nor
365
+ join one throws `TransactionUnavailableError` instead of running the callback
366
+ with no atomicity. A context assembled from a hand-built ORM double —
367
+ `getContext` called without its `client` argument — still writes directly
368
+ against that double, with no such terminal to refuse from; it now warns once
369
+ per list and operation via `console.warn` instead of staying silent.
370
+
371
+ - [#1494](https://github.com/OpenSaasAU/stack/pull/1494) [`d4c0ecd`](https://github.com/OpenSaasAU/stack/commit/d4c0ecd103bd2d31b2a4f459529fc200506874e2) Thanks [@borisno2](https://github.com/borisno2)! - Add `getPluginData<T>(config, pluginName)`, a typed reader paired with `setPluginData<T>`, so a consumer reading a plugin's stored data no longer casts `config._pluginData` itself:
372
+
373
+ ```typescript
374
+ import { getPluginData } from '@opensaas/stack-core'
375
+ import type { NormalizedAuthConfig } from '@opensaas/stack-auth'
376
+
377
+ const resolvedConfig = await config
378
+ const authConfig = getPluginData<NormalizedAuthConfig>(resolvedConfig, 'auth')
379
+ ```
380
+
381
+ `@opensaas/stack-auth`'s `buildBetterAuthOptions` and the core MCP handler's plugin-tool lookup both adopt it in place of their own casts.
382
+
383
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@{](https://github.com/{)! - The generated types file declares the contract remainder and instantiates core's generics
384
+
385
+ `.opensaas/types.ts` no longer re-derives every scalar type, nullability and
386
+ relation arity by hand. It writes one `Remainder` entry per list — the four
387
+ facts the emitted Contract artifacts cannot carry — and names one interface per
388
+ shape extending a generic `@opensaas/stack-core` now exports, keyed by the
389
+ emitted `Contract`:
390
+
391
+ ```typescript
392
+ export type Remainder = {
393
+
394
+ computed: { displayName: string }
395
+ output: { secret: import('@opensaas/stack-core/internal').HashedPassword }
396
+ input: Record<never, never>
397
+ needs: { displayName: 'name' }
398
+ }
399
+ Settings: {
400
+ computed: Record<never, never>
401
+ output: Record<never, never>
402
+ input: Record<never, never>
403
+ needs: Record<never, never>
404
+ singleton: true
405
+ }
406
+ }
407
+
408
+ export interface User extends Stack$Row<Stack$Contract, Remainder, 'User'> {}
409
+ export interface UserCreateInput extends Stack$CreateInput<Stack$Contract, Remainder, 'User'> {}
410
+ export interface UserUpdateInput extends Stack$UpdateInput<Stack$Contract, Remainder, 'User'> {}
411
+ export interface UserList extends Stack$SecuredList<Stack$Contract, Remainder, 'User'> {}
412
+
413
+ export interface Context<TSession extends Stack$Session = Stack$Session> extends Stack$StackContext<
414
+ DB,
415
+ TSession,
416
+ Stack$PluginServices
417
+ > {}
418
+ ```
419
+
420
+ Everything the file imports is aliased behind `Stack$`, so a list may be named
421
+ `Row`, `Contract` or `Session` without shadowing the generic its own interface
422
+ is declared from. Only what is used is imported, so a bundle compiled under
423
+ `noUnusedLocals` stays clean.
424
+
425
+ `Post`, `PostCreateInput`, `PostUpdateInput`, `Context`, `BaseContext`,
426
+ `TransactionContext` and `Lists.Post.TypeInfo` keep their names, so imports do
427
+ not change. What changes is what they mean:
428
+
429
+ - **An included to-one relation reads `| null`, a to-many `[]`** — by arity
430
+ alone, whatever the foreign key's nullability. Access control can scope the
431
+ related row away, so code that dereferenced a required relation without a
432
+ check now fails `tsc`.
433
+ - **A virtual field's `resolveOutput` hook receives exactly its declared
434
+ `needs` plus the list's system fields.** Reading an undeclared column is a
435
+ compile error for any hook authored under `list<Lists.Post.TypeInfo>`:
436
+
437
+ ```typescript
438
+ excerpt: virtual({
439
+ type: 'string',
440
+ needs: ['content'],
441
+ hooks: {
442
+ resolveOutput: ({ item }) => item.content.slice(0, 100), // compiles
443
+ // resolveOutput: ({ item }) => item.title, // tsc error
444
+ },
445
+ })
446
+ ```
447
+
448
+ The set is the one `deriveDependencyTable` resolves for the runtime
449
+ (ADR-0051), not the declaration as written, so **a `needs` naming a
450
+ relationship yields a different `item` type than before**: it now carries the
451
+ foreign-key column this side owns as well as the relation, matching what the
452
+ widening actually fetches.
453
+
454
+ ```typescript
455
+ byline: virtual({
456
+ type: 'string',
457
+ needs: ['author'],
458
+ hooks: {
459
+ // `authorId` is now on `item`; previously only `author` was.
460
+ resolveOutput: ({ item }) => `${item.author?.name ?? '?'} (${item.authorId})`,
461
+ },
462
+ })
463
+ ```
464
+
465
+ A `needs` entry naming a field the list does not have is dropped rather than
466
+ typed, the list's system fields are its actual ones (a list with
467
+ `db.timestamps: false` carries only `id`), and only a **virtual** field gets
468
+ this narrowed `item` — a stored field's `resolveOutput` still sees the whole
469
+ row, which is what the runtime hands it.
470
+
471
+ - **A write input is checked against the contract's columns.** A system-filled
472
+ column (`id`, `createdAt`, `updatedAt`) is not writable, a non-nullable column
473
+ with no default is required on create, and an unknown key is rejected.
474
+ - **Every write terminal admits silent denial.** `create` returns
475
+ `Row | null`, and `createMany` / `updateMany` — which run one secured write
476
+ per item — return `(Row | null)[]`, so a partially denied batch is visible in
477
+ the type. Code that used a create result without checking now fails `tsc`:
478
+
479
+ ```typescript
480
+ const post = await context.db.post.create({ data })
481
+ if (!post) return { error: 'Access denied' }
482
+ ```
483
+
484
+ - Every per-list `GetPayload`, `Select`, `Include`, `WhereInput`, `*Args`,
485
+ `VirtualFields`, `TransformedFields` and `{List}Crud` type is gone;
486
+ `CustomDB` is now `DB`.
487
+
488
+ Resolving a list's model off the ORM client now **throws**
489
+ `OrmModelMissingError` where the client carries no delegate for it. The
490
+ previous behaviour degraded silently in one place: a nested write's
491
+ pre-existing-id capture treated a missing parent delegate as "no pre-existing
492
+ ids", so a disconnect that should have been reported instead ran against an
493
+ empty set. A real client always carries the delegate, so this surfaces on test
494
+ doubles — give the double the model, or use a client whose model keys match the
495
+ config's list names in `getDbKey` form (`AuthUser` → `authUser`):
496
+
497
+ ```typescript
498
+ // Before: a double missing `post` silently captured nothing
499
+ const prisma = { user: userDouble }
500
+ // After: give it the delegate the config declares
501
+ const prisma = { user: userDouble, post: postDouble }
502
+ ```
503
+
504
+ `PrismaClientLike = any` is deleted. `context.prisma` is `OrmClient`, a
505
+ structural interface, and `AccessContext`, `StackContext` and
506
+ `AccessControlledDB` lose their `TPrisma` type parameter — drop the argument:
507
+
508
+ ```typescript
509
+ // Before
510
+ function render(context: AccessContext<unknown>) {}
511
+ // After
512
+ function render(context: AccessContext) {}
513
+ ```
514
+
515
+ `OrmClient`, `OrmRow` and `OrmOperationArgs` are deliberately untyped
516
+ (`Record<string, unknown>` and an index signature). The unsecured surface's
517
+ shape depends on the config's list names, so the typed surface is the generated
518
+ bundle's `DB` and `Row`; `unknown` here forces a narrow at each use where the
519
+ `any` it replaces did not. Use `context.db` when you want types.
520
+
521
+ `StackContext`'s first parameter is now the generated `db` surface, not the
522
+ client, and refuses one: a stale `StackContext<MyPrismaClient>` fails its
523
+ constraint rather than silently meaning `db: MyPrismaClient`.
524
+
525
+ `pnpm generate` now refuses two configs it used to emit uncompilable code for:
526
+ a virtual field with no declared `outputType`, and two lists whose generated
527
+ names collide (`Post` and `PostList` both want `PostList`). Both errors name the
528
+ list and field involved.
529
+
530
+ The bundle's type-only import of the emitted declarations is now
531
+ `'../prisma/contract.d.js'`. `'../prisma/contract.d.ts'` resolved to the
532
+ Contract module sitting beside it, so `Contract` was not among the exports the
533
+ import found; re-run `pnpm generate`.
534
+
535
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - MCP's `tools/list` now gates its published vocabulary at field grain, per session
536
+
537
+ A field whose access rule the session alone decides — a rule that never reaches
538
+ into the row or the payload — and which denies, no longer appears in what MCP
539
+ advertises: not in the `query` tool's `fields` projection at either level, and
540
+ not in the `create`/`update` tools' `data` schemas. A rule that does reach into
541
+ the row stays advertised, because it may pass for rows the session owns.
542
+
543
+ ```typescript
544
+ Memo: list({
545
+ fields: {
546
+ title: text(),
547
+ // Row-independent: never advertised to a non-admin session.
548
+ internal: text({ access: { read: () => false, update: () => false } }),
549
+ // Row-dependent: stays advertised to everyone.
550
+ ownerNotes: text({
551
+ access: { read: ({ session, item }) => item?.ownerId === session?.userId },
552
+ }),
553
+ },
554
+ })
555
+ ```
556
+
557
+ A list whose `create` needs a field the session can never write no longer
558
+ advertises a `create` tool at all, rather than offering one that refuses every
559
+ call. Naming a field the schema withheld — including a relation whose target
560
+ list this session cannot reach — is refused with the same message an unknown
561
+ field name gets, so the refusal discloses nothing the schema held back.
562
+
563
+ A field rule that throws while `tools/list` decides whether to advertise the
564
+ field costs that one field its advertisement rather than the whole listing, and
565
+ is reported on the server console. The rule still throws when the field is
566
+ actually read or written.
567
+
568
+ Classification runs per session and is not cached. No configuration is
569
+ required — the behaviour follows from the field-level access rules already in
570
+ your config.
571
+
572
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Remove `findMany` / `findFirst` / `findUnique` / `count` from the generated read surface
573
+
574
+ The Prisma 7 read names outlived the client that could serve them: every one of
575
+ them type-checked and then threw `TypeError: … is not a function`, under `sudo`
576
+ too. Reaching for one is now a compile error rather than a runtime failure.
577
+
578
+ ```typescript
579
+ // Before
580
+ const posts = await context.db.Post.findMany({ where: { published: { equals: true } } })
581
+ const post = await context.db.Post.findUnique({ where: { id } })
582
+ const first = await context.db.Post.findFirst({ where: { slug: { equals: slug } } })
583
+ const total = await context.db.Post.count()
584
+
585
+ // After
586
+ const posts = await context.db.Post.where({ published: { equals: true } }).all()
587
+ const post = await context.db.Post.where({ id }).first()
588
+ const first = await context.db.Post.where({ slug: { equals: slug } }).first()
589
+ const { total } = await context.db.Post.aggregate((aggregate) => ({ total: aggregate.count() }))
590
+ ```
591
+
592
+ A singleton's `get()` is unchanged in shape and now resolves through the same
593
+ composed read an ordinary list reads through, so its operation access, Access
594
+ Filter, Field Visibility and related-list `query` access are the engine's rather
595
+ than a second copy of them.
596
+
597
+ Its auto-create is also tightened on a security path. `get()` previously fired
598
+ the auto-create for any `query` rule that did not answer a strict `false`, so a
599
+ rule that answered a **filter** — a first-class form, used to scope a read —
600
+ fell through it. On an absent row that created the singleton and handed it to a
601
+ session the filter excluded; on a present row it reached the singleton-create
602
+ constraint's unscoped row count and threw
603
+ `Cannot create: … is a singleton list with an existing record`, turning a read
604
+ whose whole design is silent failure into an existence oracle. The auto-create
605
+ now fires only for a rule that answered a strict `true` (or under `sudo`), and
606
+ the created row is handed back through the composed read rather than raw. Every
607
+ other form — `false`, a filter, a missing rule — answers the same `null` an
608
+ absent row answers, writes nothing, and raises nothing; a rule that throws still
609
+ propagates.
610
+
611
+ If you relied on a filter-returning `query` rule auto-creating a singleton, give
612
+ that list a `query` rule that answers `true` and scope it with the Access Filter
613
+ on the fields instead.
614
+
615
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Delete the Node build; the Generated bundle loads under plain Node from the committed contract
616
+
617
+ The `.opensaas/` bundle is erasable TypeScript by contract and loads natively under Node 22.18+, so the compiled twin that existed to serve bundler-less consumers is gone (ADR-0054, withdrawing ADR-0011). Removed:
618
+
619
+ - `output.buildTarget` from the config surface. A config that sets it is now a compile error; delete the `output` block (or the key) — nothing replaces it, because `.opensaas/context.ts` is the one specifier both a bundler and plain Node load.
620
+
621
+ ```typescript
622
+ // Before
623
+ export default config({
624
+ output: { buildTarget: 'node' },
625
+ // ...
626
+ })
627
+
628
+ // After
629
+ export default config({
630
+ // ...
631
+ })
632
+ ```
633
+
634
+ A plain-Node consumer imports the bundle entry directly:
635
+
636
+ ```typescript
637
+ const { rawOpensaasContext } = await import('./.opensaas/context.ts')
638
+ ```
639
+
640
+ - The CLI's Node build step, its `.opensaas/dist/` layout, and `@typescript/native` as a runtime dependency of `@opensaas/stack-cli` (it stays a devDependency, the compiler the package builds and type-checks its own tests with).
641
+
642
+ The CLI's tests now run the real `node` binary over a generated bundle with no flags and no loader, and type-check generator output under `erasableSyntaxOnly` and `verbatimModuleSyntax` so a non-erasable construct fails a CLI test before it fails a user's Node.
643
+
644
+ `create-opensaas-app` no longer accepts `--db`, and its SQLite-to-PostgreSQL transform is deleted. The scaffolded project uses the database its template declares; change it by editing `db` in the generated `opensaas.config.ts`. The scaffolded `tsconfig.json` now carries `erasableSyntaxOnly` and `verbatimModuleSyntax`, so the type-checker reports a non-erasable config before Node does.
645
+
646
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - `AccessContext.prisma` becomes `AccessContext.ormHandle`
647
+
648
+ The engine's internal ORM handle now carries a name that says what it is. The public bypass was renamed to `context.unsafe` first; until now the handle underneath it was still called `prisma`, so a reader could not tell which of the two a `prisma` in the source meant.
649
+
650
+ `ormHandle` is the client the secured surface's terminals, the Write Pipeline and the access filter actually issue their queries through. The engine applies the Access Filter, Field Visibility and hooks _around_ it, so the handle itself enforces none of them — the same absence of protection as `context.unsafe`, on a different object. `AccessContext` has no `unsafe` member, so `ormHandle` is what a hook or a plugin `runtime()` factory is handed.
651
+
652
+ ```typescript
653
+ // Before
654
+ const plugin = {
655
+ runtime: (context) => ({
656
+ getAuditTrail: (listName: string) =>
657
+ context.prisma.auditLog.findMany({ where: { listName } }),
658
+ }),
659
+ }
660
+
661
+ // After
662
+ const plugin = {
663
+ runtime: (context) => ({
664
+ getAuditTrail: (listName: string) =>
665
+ context.ormHandle.auditLog.findMany({ where: { listName } }),
666
+ }),
667
+ }
668
+ ```
669
+
670
+ The Write Pipeline rebinds `ormHandle` wherever it rebinds `context.db`, exactly as it did before — this rename changes nothing about when a hook's database work is transactional. Every write opens a transaction (ADR-0010), so a hook's own write through either handle rolls back with the write that failed.
671
+
672
+ `getContext()`'s second positional parameter is renamed to match; it is positional, so no call site changes. `@opensaas/stack-auth`'s better-auth wiring and `@opensaas/stack-rag`'s vector search now read `context.ormHandle`.
673
+
674
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - The Prisma 8 config surface: `db.idField`, `db.extensions`, `db.client`, `db.provider` (postgresql only), typed `onDelete`/`onUpdate` on relationships, `db.indexes` without `sort`, and `PluginContext.addExtension` (ADR-0040, ADR-0048, ADR-0049, ADR-0064).
675
+
676
+ ```typescript
677
+ export default config({
678
+ db: {
679
+ provider: 'postgresql',
680
+ idField: 'uuid7', // the default; 'cuid2' | 'int autoincrement'
681
+ extensions: [{ name: 'pgvector', from: '@prisma/orm-extension-pgvector' }],
682
+ client: {
683
+ pg: () => new Pool({ connectionString: process.env.DATABASE_URL }), // a lazy factory
684
+ },
685
+ },
686
+ lists: {
687
+ Invoice: list({
688
+ fields: {
689
+ customer: relationship({ ref: 'Customer.invoices', db: { onDelete: 'restrict' } }),
690
+ },
691
+ db: {
692
+ idField: 'int autoincrement',
693
+ indexes: [{ fields: ['customer'], name: 'Invoice_customer_idx' }],
694
+ },
695
+ }),
696
+ },
697
+ })
698
+
699
+ // A plugin declares the pack its field types need; the same name from the same
700
+ // package merges, the same name from a different package throws.
701
+ init: async (context) => {
702
+ context.addExtension({ name: 'pgvector', from: '@prisma/orm-extension-pgvector' })
703
+ }
704
+ ```
705
+
706
+ `pnpm generate` now refuses, naming the list, the entry and the fix (`validateDatabaseConfig` and `validateRelations` are exported for the same checks elsewhere): a `sort` direction on a `db.indexes` field reference; `many: true` on both sides of a relationship or on a list-only ref (author the junction as its own list); `db.idField` on a singleton; `db.foreignKey: true` on both sides of a one-to-one; `db.isNullable: false`, `db.onDelete`/`db.onUpdate` or a `db.indexes` entry on a side that owns no foreign key column; `'setNull'` together with `db.isNullable: false`; a `many: false` relationship whose `ref` is its own field; the same extension pack name declared from two packages; and a relationship at a composite-keyed list.
707
+
708
+ `prismaClientConstructor`, `extendPrismaSchema` (config- and field-level), `joinTableNaming` and `db.relationName` are removed from the config types. `@opensaas/stack-auth`'s derived lists declare their cascade through `db.onDelete` instead of `extendPrismaSchema`.
709
+
710
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Add the row lock and the advisory lock to the transaction-bound context
711
+
712
+ A capacity gate is the case a stricter isolation level used to cover, and `context.transaction(fn)` no longer takes one. `.forUpdate()` is the replacement: a row lock on the contended parent, taken **before** the count, so every racer takes the same token on the same row and the count cannot go stale under a booking a racer that got there first has already committed.
713
+
714
+ ```typescript
715
+ const result = await context.transaction(async (tx) => {
716
+ // The lock comes BEFORE both reads below. `null` here is denied-or-gone —
717
+ // either way there is no gate to run.
718
+ const held = await tx.db.Slot.where({ id: { equals: slotId } })
719
+ .forUpdate()
720
+ .first()
721
+ if (held === null) return { booked: false }
722
+
723
+ // BOTH sides of the gate are read after the lock, each in its own statement.
724
+ // `held`'s own columns are the row as of BEFORE the lock was granted, so
725
+ // `held.capacity` can be stale; this re-read cannot be, because no one else
726
+ // can commit an update to a row this transaction holds.
727
+ const slot = await tx.db.Slot.where({ id: { equals: slotId } }).first()
728
+ const { taken } = await tx.db.Booking.where({ slotId: { equals: slotId } }).aggregate(
729
+ (aggregate) => ({ taken: aggregate.count() }),
730
+ )
731
+ if (slot === null || taken >= slot.capacity) return { booked: false }
732
+
733
+ return { booked: true, item: await tx.db.Booking.create({ data: { slotId, holder } }) }
734
+ })
735
+ ```
736
+
737
+ **The lock is a mutex on the row, not a fresh read of it.** Each of the two statements takes its own snapshot under Read Committed, so a column another transaction committed between the read and the lock reaches the caller as its **pre-lock** value — only the row's identity is post-lock, and this differs from a single-statement `SELECT … FOR UPDATE`, which Postgres re-evaluates after acquiring. Read whatever the gate compares against in its own statement after the lock, the way the count above is.
738
+
739
+ `.forUpdate()` is on the transaction-bound builder and nowhere else. A lock taken outside a transaction is released at the end of the statement that took it, so it would compile, run, return rows and guard nothing — `context.db.Slot.forUpdate()` is a compile error rather than a throw. The generated bundle names two faces per list for it, `SlotList` and `SlotTxList`, and `TransactionContext` is the context over the locking one.
740
+
741
+ The terminal runs two statements. The scoped read goes first and resolves operation access, the Access Filter and Field Visibility exactly as any read does; the engine then composes `SELECT <pk> FROM <table> WHERE <pk> IN ($1…$n) ORDER BY <pk> LIMIT $n+1 FOR UPDATE` over the keys it returned and runs it on the transaction's own connection. So the locked set is provably a subset of the readable set, and **a terminal never returns a row it did not lock**: a row deleted between the two statements locks nothing, `first()` yields `null` and `all()` the surviving subset. `null` now means denied-or-vanished.
742
+
743
+ `first()` and `all()` carry the modifier. `aggregate()` and `nearest()` refuse it rather than drop it — an aggregate returns no primary keys to lock, and a ranking is not a gate. There is no `forShare`, no `NOWAIT` and no `SKIP LOCKED`: a skipped locked row would be indistinguishable from an access-denied one, which would make silent failure mean two things at once. The engine always emits `ORDER BY <pk>`, so acquisition order is the same in every session.
744
+
745
+ A list whose table has no single-column primary key cannot be locked (`RowLockIdentityError`), and one terminal binds at most `ROW_LOCK_MAX_KEYS` keys (`RowLockKeyLimitExceededError`) — a cost limit, fail-closed, well under Postgres's bind-parameter ceiling, where the failure is a corrupted bind rather than a clean refusal.
746
+
747
+ `tx.advisoryLock(key)` joins it on the transaction context, for an invariant that is not a row:
748
+
749
+ ```typescript
750
+ await context.transaction(async (tx) => {
751
+ await tx.advisoryLock(`checkout:${cartId}`)
752
+ // …
753
+ })
754
+ ```
755
+
756
+ It runs `pg_advisory_xact_lock(hashtext($1))` and releases when the transaction ends, whichever way it ends. It sits on the context rather than on `db` because it locks a number and belongs to no list. `hashtext` is 32-bit, so two distinct keys can collide — a collision costs spurious serialisation, never a missed lock.
757
+
758
+ See ADR-0047 and ADR-0062.
759
+
760
+ - [#1468](https://github.com/OpenSaasAU/stack/pull/1468) [`5aa3815`](https://github.com/OpenSaasAU/stack/commit/5aa38159fe5a54f3f0c294cc47f439ec9175d544) Thanks [@borisno2](https://github.com/borisno2)! - Fix a to-one relation's foreign-key column colliding with the relation's own alias ([#1236](https://github.com/OpenSaasAU/stack/issues/1236)). This broke nested to-one includes (`column reference "…" is ambiguous`) and could make a field-level rule that reads `item.<relation>Id` directly answer wrong — an allow flipping to a deny, or a deny flipping to a **disclosure**, depending on whether the caller happened to include the relation.
761
+
762
+ The fix changes the foreign key's default physical column name, which is a **schema change** for any list using a to-one relationship that did not set `db.foreignKey.map` explicitly: the physical column moves from the relation's own name (`author`) to the contract member's name (`authorId`) — the two are no longer forced to disagree.
763
+
764
+ Before deploying this version against an existing database, rename each affected column so the deploy reconciles against a schema that already matches (no destructive diff for a rename-detection tool to get wrong):
765
+
766
+ ```sql
767
+ ALTER TABLE "Post" RENAME COLUMN "author" TO "authorId";
768
+ ```
769
+
770
+ Run one such statement per to-one relationship field that relies on the default (i.e. every one that does not set `db.foreignKey.map`). There is no way to opt out and keep the old column name — `db.foreignKey.map` set to the field's own name is now a generate-time refusal, because that is exactly the collision this release closes.
771
+
772
+ The read-boundary workaround this collision required (`restoreForeignKeys` and its helpers, and `NestedToOneIncludeError`) is removed now that the collision cannot occur — a nested to-one include just works:
773
+
774
+ ```typescript
775
+ await context.db.User.include('posts', (posts) => posts.include('author')).all()
776
+ ```
777
+
778
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - The nested-write access gap reported in [#1384](https://github.com/OpenSaasAU/stack/issues/1384) is closed by refusal, not by gating
779
+
780
+ Nested `set`, `updateMany` and `deleteMany` under a relationship key used to
781
+ reach the database as an unchecked pass-through: the target list's access was
782
+ never consulted, no hooks ran, and an unscoped `where` could reach rows well
783
+ outside the parent's own subtree. Nested `disconnect` could name a target row
784
+ the caller could not read.
785
+
786
+ Both are closed here by ADR-0050 rather than by per-kind access machinery:
787
+ `create`, `update`, `delete`, `connectOrCreate`, `disconnect`, `set`,
788
+ `updateMany` and `deleteMany` under a relationship key are refused with
789
+ `NestedRelationInputError`. `connect` is not among them — it lowers onto a
790
+ foreign-key column the row being written owns, and survives unchanged. The
791
+ refusal is unconditional — `sudo()` does not lift it — which is strictly
792
+ stronger than the interim non-sudo-only refusal [#1385](https://github.com/OpenSaasAU/stack/issues/1385) shipped on the previous
793
+ line.
794
+
795
+ Clearing an edge is `null` on the relationship field **that owns the foreign
796
+ key**. On a field that owns none — a to-many, the non-owning half of a
797
+ one-to-one, a synthetic back-relation — `null` is refused in turn with
798
+ `NonOwningRelationInputError`, exactly as `connect` is there, so clearing that
799
+ edge is an update against the target list:
800
+
801
+ ```typescript
802
+ // `Author.posts` owns no column, so the write goes to `Post`:
803
+ await context.db.Post.update({ where: { id: postId }, data: { author: null } })
804
+ ```
805
+
806
+ Every other refused kind is likewise a write against the target list, wrapped in
807
+ `context.transaction()` when it must land atomically.
808
+
809
+ See `rugged-terminals-persist.md` for the full write-surface change.
810
+
811
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - MCP's `fields` projection is a translator onto the secured surface
812
+
813
+ The `query` tool's `fields` argument keeps the wire shape it has always had, and now lowers onto the secured read instead of a Prisma `include` bag that MCP trimmed by hand afterwards. Root scalars and virtuals become one `.select()` with `id` forced at every level; a relation becomes one `.include()` refinement carrying its own selection, `where`, `orderBy` and per-parent page under the standing nested caps; and `count: true` becomes a single `combine({ items, count })` — one include, one correlated subquery, and the `{ items, count }` shape the tool already returned, reduced to the bare number when the caller asked for the count alone. The count is taken off the unpaged relation, so it counts the relation rather than the page beside it.
814
+
815
+ A projected row now also carries `createdAt` and `updatedAt` alongside `id`, whether or not the caller named them. They are system fields, always readable and outside access control, and MCP gets them because a projected row is the engine's to shape rather than something MCP trims afterwards.
816
+
817
+ Negative `take` and `skip` are refused at the root of the `query` tool as they already were inside a relation entry, rather than reaching the driver.
818
+
819
+ `where` and `orderBy`, at the root and inside a relation entry, are the Where vocabulary, and the tools' schema descriptions say which operators that is:
820
+
821
+ ```jsonc
822
+ {
823
+ "where": { "title": { "contains": "release" }, "comments": { "some": { "approved": true } } },
824
+ "orderBy": { "title": "asc" },
825
+ "fields": {
826
+ "title": true,
827
+ "comments": {
828
+ "fields": { "body": true },
829
+ "where": { "approved": true },
830
+ "take": 5,
831
+ "count": true,
832
+ },
833
+ },
834
+ }
835
+ ```
836
+
837
+ The `query`, `update` and `delete` tools' `where.id` is typed from the list's own id strategy: an `int autoincrement` list advertises an integer, takes `"3"` off the wire as `3`, and answers a malformed id exactly as a missing row is answered.
838
+
839
+ `pickFields`, the MCP field-selection type, `projectMcpResult` and the `_count` folding are gone — the engine's exact selection is the only authority on what a caller receives, and the projection module does no post-query trimming of its own.
840
+
841
+ A relation's rows may now be `combine`d beside a reducer on the secured surface — `include('posts', (posts) => posts.combine({ items: posts.limit(5), total: posts.count() }))` — with those rows going through Field Visibility exactly as an unreduced relation's do. At most one branch may be the rows.
842
+
843
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Add the Dev database primitive and give the URL lookup a provenance
844
+
845
+ `@opensaas/stack-core/dev-database` exports `startDevDatabase()`, which starts an
846
+ in-process PGlite behind a socket server on a free loopback TCP port and publishes
847
+ it in a state file (URL and pid) under the Generated bundle directory, so that the
848
+ app, a seed script and a second-terminal `db update` all find it through the same
849
+ lookup instead of an injected variable (ADR-0063). PGlite and its socket and
850
+ pgvector packages are optional peers, imported only when the primitive is called.
851
+
852
+ ```typescript
853
+ import { startDevDatabase } from '@opensaas/stack-core/dev-database'
854
+
855
+ const database = await startDevDatabase({
856
+ dataDir: '.opensaas/dev-db',
857
+ extensions: ['vector'],
858
+ })
859
+ // ... database.url, database.port
860
+ await database.stop()
861
+ ```
862
+
863
+ `stop()` is idempotent — a `SIGINT` handler and a `finally` may both call it — and drops
864
+ the state file only once the socket server and PGlite are actually released. A failure
865
+ anywhere in startup tears down whatever was already constructed, so no port is left
866
+ bound. An IPv6 `host` is bracketed into the published URL.
867
+
868
+ `resolveDatabaseUrl()` now returns `{ url, provenance }` rather than a bare string,
869
+ and consults the dev database state file when the environment names no connection.
870
+ `provenance` is `'env'` for `DATABASE_URL`/`DIRECT_DATABASE_URL` and `'dev-database'`
871
+ for the state file; with neither it throws, naming both remedies. Callers that want
872
+ just the string take `.url`; `findDatabaseUrl()`, which the generated
873
+ `prisma.config.ts` uses, is unchanged in shape and still non-throwing.
874
+
875
+ ```typescript
876
+ // Before
877
+ const url = resolveDatabaseUrl()
878
+
879
+ // After
880
+ const { url, provenance } = resolveDatabaseUrl()
881
+ ```
882
+
883
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - `context.db` is keyed by the PascalCase list name and carries the opaque read wrapper
884
+
885
+ `context.db.<List>` is now spelled the way the config spells the list — `context.db.AuthUser`, not
886
+ `context.db.authUser` — and `getDbKey()` is deleted (`getUrlKey()` and `getListKeyFromUrl()` stay).
887
+ Every call site through the secured surface, and every ORM handle the engine reaches a model
888
+ through, moves to the list key.
889
+
890
+ ```typescript
891
+ // Before
892
+ const posts = await context.db.blogPost.findMany()
893
+
894
+ // After
895
+ const posts = await context.db.BlogPost.findMany()
896
+ ```
897
+
898
+ The same member is now also a query value: `.where(...)` composes an immutable read and `.all()` /
899
+ `.first()` are the terminals that run it. A terminal resolves operation-level `query` access, adds
900
+ the access filter as a second entry in the collection's own filter list (nothing is hand-merged),
901
+ enters the engine origin around the ORM call, applies Field Visibility, and returns `[]` / `null`
902
+ on denial — indistinguishable from an empty result.
903
+
904
+ ```typescript
905
+ const mine = await context.db.Post.where({ published: true }).all()
906
+ const first = await context.db.Post.where({ authorId: session.userId }).first()
907
+ ```
908
+
909
+ `where` takes an equality predicate (`{ column: value }` or `{ column: { equals: value } }`); an
910
+ operator the engine does not lower yet is refused rather than passed through.
911
+
912
+ The three read members belong to a list you can query for many rows, so a singleton list does not
913
+ carry them — `get()` stays the way to read one. That matches the type the generator has always
914
+ emitted for a singleton.
915
+
916
+ Code the CLI writes into your project moves to the list key with everything else: the feature
917
+ generator's blog and auth pages (`context.db.Post.findMany(…)`), and the Keystone migration guide,
918
+ which now says list names are PascalCase.
919
+
920
+ A predicate whose condition is `undefined` is still skipped rather than refused, matching Prisma's
921
+ `undefined`-means-omitted semantics — so an access filter spelled `({ session }) => ({ authorId:
922
+ session?.userId })` constrains nothing for an anonymous caller, while the explicit `{ equals:
923
+ undefined }` spelling of the same rule is refused. Making the lowering total is the closed Where
924
+ vocabulary's job ([#1147](https://github.com/OpenSaasAU/stack/issues/1147)). Relation-valued `needs` are likewise not yet widened on `all()`/`first()`
925
+ the way `findMany` widens them ([#1149](https://github.com/OpenSaasAU/stack/issues/1149)).
926
+
927
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - `getContractField` replaces the PSL pair at the field self-containment gate
928
+
929
+ `validateConfigFields` — the check `pnpm generate` runs over every stored field before it
930
+ reads any contract — used to require the PSL-shaped `getPrismaType` and `getTypeScriptType`
931
+ from every non-virtual field. Those two describe one Prisma column and one TypeScript type,
932
+ and neither is read by anything on the contract-era generators: columns come from
933
+ `getContractField`, and the emitted types come from `outputType`/`inputType`, else from
934
+ the column's own codec. Both members are removed from the field-builder contract in this
935
+ same release.
936
+
937
+ For a field spanning several columns of different types there was no honest single
938
+ `getPrismaType` to give, so the gate was forcing field packages to declare a plausible but
939
+ false one purely to pass it — `@opensaas/stack-rag`'s `embedding()` is a `vector(n)` column
940
+ plus a `jsonb` column, and had to claim `Json?`.
941
+
942
+ `getContractField` is now what satisfies the gate for a stored field, with no PSL method in
943
+ the picture at all. `getZodSchema` is still required of it — no contract supplies
944
+ validation — and a field with no single column to be typed from must also declare
945
+ `outputType`. That is decided by the descriptor: `kind: 'columns'`, or `kind: 'computed'`
946
+ whether or not the builder also sets the `virtual` flag core's own `virtual()` sets
947
+ alongside it. A relationship field needs only `getContractField`. A stored field that
948
+ declares no contract now fails the gate outright: there is no PSL pair left to satisfy it
949
+ with.
950
+
951
+ ```typescript
952
+ // A field package can now describe its columns once, to the contract:
953
+ export function myField(): MyField {
954
+ return {
955
+ type: 'myField',
956
+ getZodSchema: () => /* … */,
957
+ getContractField: (fieldName) => ({ kind: 'columns', columns: [/* … */] }),
958
+ outputType: "import('@my/pkg').MyValue | null",
959
+ inputType: "import('@my/pkg').MyValue | null",
960
+ }
961
+ }
962
+ ```
963
+
964
+ This affects field packages, not applications: a field package migrates by describing its
965
+ columns to `getContractField` once, and no application config has to be edited.
966
+
967
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Add `.include()` refinements to the secured read surface
968
+
969
+ `context.db.<List>.include(name, refine?)` reaches one hop into a relation and returns a new query value. The refinement is a related read with `where`, `orderBy`, `limit`, `offset` and a nested `include` — and no terminal, because the parent's terminal is the only thing that runs.
970
+
971
+ ```typescript
972
+ const users = await context.db.User.include('posts', (posts) =>
973
+ posts
974
+ .where({ published: { equals: true } })
975
+ .orderBy({ createdAt: 'desc' })
976
+ .limit(5),
977
+ ).all()
978
+ ```
979
+
980
+ The related list's `query` access rides in as a refinement `where`, so a to-one the session cannot read comes back `null` and a to-many `[]` — with the key present and the parent row kept, whatever the session. Every key inside a refinement, and every synthetic back-relation (`from_<SourceList>_<field>`), is validated and scoped exactly as a top-level one; a relation whose own `read` rule is row-independent and denies is left out of the include before the query unless a live declared dependency set names it, and Field Visibility re-checks every relation it is handed regardless. An include tree deeper than `READ_INCLUDE_MAX_DEPTH` is refused with `AccessScopeDepthExceededError`.
981
+
982
+ A to-one's foreign-key column follows the relation's own visibility: it carries the related row's id when the relation is visible and `null` when it is not — scoped away by the Access Filter or stripped by Field Visibility alike — whatever `db: { foreignKey: { map } }` names the column. A relationship field the session cannot read is equally unqueryable under its foreign key, so `where({ authorId })` is refused exactly as an undeclared key is.
983
+
984
+ Naming the same relation twice in one read throws `DuplicateIncludeError` — neither merging the two refinements nor letting one win is a safe silent answer.
985
+
986
+ A read's include narrowing is derived from the contract's relation graph: a to-one reads as `Row<Target> | null` whatever its foreign key's nullability, a to-many as `Row<Target>[]`.
987
+
988
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Add the origin module — the ambient Engine stamp, its tripwire and its refusal error
989
+
990
+ `@opensaas/stack-core/origin` is the one component a declared surface installs to mark the
991
+ queries it executes, and the one the ORM refuses unmarked queries with (ADR-0059). The
992
+ generated context and the test harness install the same value.
993
+
994
+ ```ts
995
+ import { originTripwire, withOrigin, preserveOrigin } from '@opensaas/stack-core/origin'
996
+
997
+ // Installed once, where the client is constructed.
998
+ const client = postgres({ contractJson, middleware: [originTripwire] })
999
+
1000
+ // A surface that materialises enters the origin around exactly its ORM call,
1001
+ // with the await inside — hooks therefore run outside the mark. The terminal
1002
+ // returns Prisma's `AsyncIterableResult`, a `PromiseLike` rather than a
1003
+ // `Promise`, which is what `withOrigin` accepts.
1004
+ const rows: Post[] = await withOrigin('engine', () => orm.Post.where({ id }).all())
1005
+
1006
+ // A surface that hands a lazy result back wraps it, so `then`, `toArray`,
1007
+ // `first`, `firstOrThrow` and the async iterator's `next` each re-enter the
1008
+ // scope and the query executes marked wherever the caller consumes it. The
1009
+ // caller's own continuations still run under the caller's origin.
1010
+ return preserveOrigin('unsafe', client.runtime().query(plan))
1011
+ ```
1012
+
1013
+ Any plan compiled with no origin in scope throws `UnmarkedQueryError` from `beforeCompile`,
1014
+ in every environment — there is no warn mode and no dev-only mode. The store carries
1015
+ `'engine' | 'unsafe'` and nothing else: no session, no policy. Scoping a query to a session
1016
+ stays an ordinary rebind of the secured context.
1017
+
1018
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Rewrite each package README against the Prisma 8 surface
1019
+
1020
+ The READMEs now document the API the packages actually ship, replacing the
1021
+ Prisma 7 spellings that no longer resolve.
1022
+
1023
+ Reads compose on `context.db` keyed by the list's PascalCase config key and end
1024
+ in a terminal, rather than calling a Prisma delegate:
1025
+
1026
+ ```ts
1027
+ const posts = await context.db.Post.where({ status: { equals: 'published' } })
1028
+ .orderBy({ createdAt: 'desc' })
1029
+ .limit(20)
1030
+ .all()
1031
+
1032
+ const post = await context.db.Post.where({ id }).first()
1033
+ if (!post) return null
1034
+ ```
1035
+
1036
+ `findMany`, `findUnique`, `findFirst` and `count()` are gone; the terminals are
1037
+ `all()`, `first()`, `aggregate()` and `nearest()`. A denied read is silent, so
1038
+ every `first()` result is a null check.
1039
+
1040
+ Writes take an args object with an identity-only `where`, and a relationship is
1041
+ set with `connect` or cleared with `null`:
1042
+
1043
+ ```ts
1044
+ const updated = await context.db.Post.update({
1045
+ where: { id },
1046
+ data: { title, author: { connect: { id: authorId } } },
1047
+ })
1048
+ ```
1049
+
1050
+ The database config documented in each README is the one `DatabaseConfig`
1051
+ carries — `provider: 'postgresql'`, `idField`, `timestamps`, `schemas`,
1052
+ `extensions` and `client`. `prismaClientConstructor`, `db.url` and
1053
+ `extendPrismaSchema` are gone, and the connection is resolved from the
1054
+ environment rather than named in the config.
1055
+
1056
+ Review round two swept each README against the built `.d.ts` rather than against
1057
+ another doc, and corrected what the grep-shaped sweep had missed:
1058
+
1059
+ - The UI README's theming block documented bare `--background`/`--primary` HSL
1060
+ triplets under a `.dark` class. The shipped contract is `--color-*` tokens in
1061
+ `oklch()`, resolved through `light-dark()` and switched by `data-theme` — the
1062
+ stylesheet's own header says the design exists "without a duplicated `.dark`
1063
+ block". Its primitives list also omitted eight real exports (`Textarea`,
1064
+ `Popover`, `Calendar`, `TimePicker`, `DateTimePicker`, `Combobox`, `Badge`,
1065
+ `Avatar`), and two samples read `config.lists` without awaiting `config`.
1066
+ - The tiptap README reused a filter-returning `AccessControl` rule as
1067
+ **field-level** `access.update`. `FieldAccess` types those slots as
1068
+ boolean-returning, so that is a type error and a runtime
1069
+ `InvalidFieldAccessResultError`, not a scoped update.
1070
+ - The storage README's upload route was the last copy still casting
1071
+ `formData.get(...) as string` / `as 'file' | 'image'` off a
1072
+ `FormDataEntryValue | null`.
1073
+ - The auth README's Account shape named `providerId: 'credentials'`; better-auth
1074
+ 1.7 uses `'credential'` for email/password, and the model carries `issuer`.
1075
+ - The Vercel Blob README passed `cacheControl` to `vercelBlobStorage()`. The
1076
+ provider option is `cacheControlMaxAge` (a number of seconds);
1077
+ `VercelBlobStorageConfig` carries an index signature, so the wrong spelling
1078
+ type-checked and was silently ignored.
1079
+
1080
+ Round three corrected what round two's sweeps could not see, each having keyed
1081
+ on where a construct sat rather than on what it was:
1082
+
1083
+ - The Vercel Blob README's **options listing** still named `cacheControl` 112
1084
+ lines above the call site round two fixed, so the page contradicted itself and
1085
+ the half a reader consults first was the wrong half.
1086
+ - Sixteen hook samples across the docs and the core, cli and example READMEs
1087
+ destructured a member the `delete` branch of its args union does not carry, so
1088
+ the destructure failed before any in-body `operation` guard could narrow. Three
1089
+ more named an argument on no branch at all: `value` and `inputValue` on
1090
+ `resolveInput`/`afterOperation`, and `session` on `ResolveInputHookArgs`.
1091
+ - The core README carried a third instance of the field-access class — a bare
1092
+ `text({ access: … })` excerpt with no enclosing `fields: {` — plus
1093
+ `query: true` where `OperationAccess.query` takes a function, a
1094
+ `ValidationError` built from a string where the constructor takes `string[]`,
1095
+ and a stale claim that `password()` is excluded from reads.
1096
+ - The cli README's "What it does" block under `opensaas db update` described
1097
+ `opensaas dev`, and called `migrate` a command group when it has no
1098
+ subcommands.
1099
+
1100
+ - [#2039](https://github.com/OpenSaasAU/stack/pull/2039) [`3a60ca8`](https://github.com/OpenSaasAU/stack/commit/3a60ca85a6757ff595ab83fd770d8fb82688e4cc) Thanks [@borisno2](https://github.com/borisno2)! - Add `ui.classifyActionError` to map errors thrown during a server action to a typed `{ success: false, error, code }` failure, applied before the default mapping.
1101
+
1102
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - A directly-written foreign key now takes the same reachability check `connect` does, so the two spellings of one edge give the same answer ([#1331](https://github.com/OpenSaasAU/stack/issues/1331)).
1103
+
1104
+ Writing the column (`data: { authorId }`) and writing the relationship field (`data: { author: { connect: { id } } }`) are the same edge, and ADR-0050 pairs both access components with it: the owning field's write access, and query access on the target row evaluated in the database. Only the first half applied to the column, so a target the caller could not see was linked anyway, and a target that did not exist raised a database error instead — success versus an error told an invisible row from an absent one, which is the probing oracle the check exists to close.
1105
+
1106
+ Both spellings now run one implementation, in `lowerRelationInput`. An unreadable target and an absent one are the same silent `null` for either, `sudo` bypasses the target's `query` rule for both and the row's existence for neither, and the owning field's write access still applies first.
1107
+
1108
+ ```typescript
1109
+ // With Author.query denying this session, both are now null.
1110
+ await context.db.Post.create({ data: { title: 't', author: { connect: { id } } } })
1111
+ await context.db.Post.create({ data: { title: 't', authorId: id } })
1112
+ ```
1113
+
1114
+ A foreign-key column carrying something that is neither a row id nor `null` — an ORM scalar wrapper such as `{ set: … }` — is now refused with `MalformedForeignKeyInputError` rather than reaching the driver, since lowering it would write the edge without the reachability query. Like every other payload-shape refusal, it is raised before the transaction opens, so a malformed payload runs no hooks.
1115
+
1116
+ A payload spelling one edge both ways is refused with the new `ConflictingRelationInputError`. The generated input type is an intersection of independent optional members, so `{ author: { connect: { id: a } }, authorId: b }` type-checks; only one of the two values could reach the row, and the discarded one was still checked for reachability — so an unreadable `b` denied a write whose applied value, `a`, was perfectly reachable. Write one spelling.
1117
+
1118
+ ```typescript
1119
+ // Refused: two spellings of one edge.
1120
+ await context.db.Post.create({ data: { author: { connect: { id: a } }, authorId: b } })
1121
+ ```
1122
+
1123
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Field builders declare their contract contribution as a structured descriptor, and `needs` accepts stored columns
1124
+
1125
+ Every core field builder now carries `getContractField(fieldName, listKey, config)`, returning a `ContractFieldDescriptor`: a stored column as a pack-qualified type constructor (`{ pack, type, args }`) with native type, nullability and column mapping; for a relationship, the relation and the foreign-key column this side owns; for a virtual field, `{ kind: 'computed' }`. It is the only way a field describes its storage: the PSL-shaped `getPrismaType`/`getPrismaColumns`/`getPrismaRelation` it replaces are removed from the contract in this same release.
1126
+
1127
+ ```typescript
1128
+ import type { BaseFieldConfig } from '@opensaas/stack-core/extend'
1129
+
1130
+ export function embedding(dimensions: number): BaseFieldConfig<TypeInfo> {
1131
+ return {
1132
+ type: 'embedding',
1133
+ getContractField: (fieldName) => ({
1134
+ kind: 'column',
1135
+ name: fieldName,
1136
+ type: { pack: 'pgvector', type: 'Vector', args: [dimensions] },
1137
+ nullable: true,
1138
+ }),
1139
+ // ...getZodSchema and the rest of the builder
1140
+ }
1141
+ }
1142
+
1143
+ text().getContractField('title', 'Post', config)
1144
+ // { kind: 'column', name: 'title', type: { pack: 'pg', type: 'text' }, nullable: true }
1145
+
1146
+ relationship({ ref: 'User.posts' }).getContractField('author', 'Post', config)
1147
+ // { kind: 'relation', target: 'User', inverse: { field: 'posts', synthetic: false }, many: false,
1148
+ // foreignKey: { name: 'authorId', map: 'author', nullable: true, unique: false, index: true,
1149
+ // references: { list: 'User', field: 'id' } } }
1150
+ ```
1151
+
1152
+ A default that is not a JSON literal (a `Date`, a `Decimal`, a `Map`) is refused by the builder, naming the list and field, rather than silently dropped; a `bigint` default is carried as its decimal string whether written `42n`, `42` or `'42'`. A caller-supplied `outputType`/`inputType` now wins over the `select`, `password` and `calendarDay` builder defaults.
1153
+
1154
+ A field's TypeScript face is one pair of `TypeDescriptor` values — `outputType` (what a read returns) and `inputType` (what a write accepts) — set only where it differs from the column's codec type: `password` reads as `HashedPassword`, `select` reads and writes its option union, `calendarDay` reads and writes a `YYYY-MM-DD` string, and `virtual({ type })` keeps its spelling with `outputType` as the computed entry. A stored field that sets neither takes the codec's type.
1155
+
1156
+ `needs` now accepts stored-column keys as well as relations (`needs: ['lineItems', 'price']`), and `pnpm generate` refuses a `needs` on a field with no `resolveOutput` hook, naming the list and field. A declared column is honoured at runtime: under a fragment `query` that selects only the computed field, the hook's `item` still carries the column and the result still does not.
1157
+
1158
+ ```typescript
1159
+ total: virtual({
1160
+ type: 'number',
1161
+ needs: ['price', 'quantity'],
1162
+ hooks: { resolveOutput: ({ item }) => item.price * item.quantity },
1163
+ })
1164
+ ```
1165
+
1166
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - A plugin's write of a column it owns runs no hook, which stops it destroying derived fields
1167
+
1168
+ An embedding is write-denied to application code, so the RAG plugin's generation hook
1169
+ wrote it through `sudo().db.<list>.update()`. That is an ordinary secured write, so it
1170
+ re-ran the list's **whole** hook pipeline carrying the embedding column and nothing else —
1171
+ and a list-level `resolveInput` that derives one field from other input, the pattern
1172
+ `CLAUDE.md` documents, then recomputed the derived field from values that were not there:
1173
+
1174
+ ```typescript
1175
+ Article: list({
1176
+ fields: {
1177
+ title: text(),
1178
+ body: text(),
1179
+ content: text(),
1180
+ contentEmbedding: embedding({ sourceField: 'content', dimensions: 3 }),
1181
+ },
1182
+ hooks: {
1183
+ // Ran a second time on the plugin's write, with `title` and `body` absent
1184
+ resolveInput: ({ resolvedData }) => ({
1185
+ ...resolvedData,
1186
+ content: [resolvedData.title, resolvedData.body].join(' '),
1187
+ }),
1188
+ },
1189
+ })
1190
+ ```
1191
+
1192
+ `create({ data: { title: 'red', body: 'hot' } })` committed `content: 'red hot'` and then
1193
+ overwrote it with `' '` — the join of two `undefined`s — and embedded that. No error, no
1194
+ log: the row and its vector were both silently wrong. The write threw on every invocation
1195
+ before the Write Pipeline landed, so this was only reachable once generation began running.
1196
+
1197
+ The plugin's write no longer goes through `context.db`. Core owns it as a single-field
1198
+ write, `writePluginOwnedField`, exported from `@opensaas/stack-core/extend` for any plugin
1199
+ that injects a field it computes:
1200
+
1201
+ ```typescript
1202
+ import { writePluginOwnedField } from '@opensaas/stack-core/extend'
1203
+
1204
+ runtime: (context) => ({
1205
+ [WRITE_VECTOR]: async (listName, id, fieldName, value) =>
1206
+ await writePluginOwnedField({ context, listName, id, fieldName, value }),
1207
+ })
1208
+ ```
1209
+
1210
+ It splits the value through the field's own `splitColumns` exactly as the Write Pipeline
1211
+ does, issues one scoped `UPDATE`, and runs no hook.
1212
+
1213
+ It reaches no field but the one named, and that is enforced rather than asked of the
1214
+ caller: the field is resolved against the config the context was built from, so the
1215
+ columns written are that field's own and the caller passes no layout. A list or a field
1216
+ the config does not declare — including one named for a key it inherits from
1217
+ `Object.prototype`, which a bare lookup answers for — is refused by name, as is a context
1218
+ carrying no config, as is an `undefined` value, which would otherwise wipe a multi-column
1219
+ field and no-op a single-column one, two outcomes for one input. This narrows the escalated
1220
+ `db` update it replaces, which could write any column on the row, but it is not a privilege
1221
+ boundary: a plugin holding `context.ormHandle` can already write anything, and this refuses
1222
+ the mistake rather than the intent.
1223
+
1224
+ It takes the `AccessContext` `Plugin.runtime` receives as its first argument; the
1225
+ `StackContext` `getContext` returns carries no ORM handle and is refused by name. That
1226
+ second argument, `sudo`, is now declared as the `StackContext` it always was — a plugin
1227
+ reaching `sudo().db` is unaffected, one reaching `ormHandle` off it was already getting
1228
+ `undefined` and now fails to compile. See ADR-0068.
1229
+
1230
+ A write refused by name is a wiring defect that fails identically on every row, so the RAG
1231
+ plugin's failure log now reports all three refusals — and `WriteCollectionMissingError`
1232
+ beside them — as the standing defect they are, rather than telling the reader to retry a
1233
+ write that can never succeed.
1234
+
1235
+ What changes for an application: a list hook no longer fires a second time when the plugin
1236
+ writes a generated column, so one logical change now fires one side effect. Nothing about
1237
+ `context.db` changes — an application write runs the pipeline exactly as before, and
1238
+ `embedding({ allowManualWrites: true })` still writes through it.
1239
+
1240
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - `pnpm generate` emits the Prisma 8 artifact set: a Contract module, `prisma.config.ts` and the committed contract artifacts
1241
+
1242
+ `opensaas generate` no longer writes a Prisma schema or a generated Prisma client. It derives the contract from `opensaas.config.ts`, renders a standalone, fully literal `prisma/contract.ts`, writes a `prisma.config.ts` at the project root, shells to the pinned `prisma contract emit` for `prisma/contract.json` + `prisma/contract.d.ts`, checks the emitted relation graph against the derivation, then writes the `.opensaas/` bundle.
1243
+
1244
+ The Contract module imports nothing from your config — only `@prisma/orm-postgres/contract-builder`, the column-type helpers, and each pack declared in `db.extensions`:
1245
+
1246
+ ```typescript
1247
+ // prisma/contract.ts — generated
1248
+ import { defineContract, nativeEnum, pg } from '@prisma/orm-postgres/contract-builder'
1249
+ import pgvector from '@prisma/orm-extension-pgvector/pack'
1250
+
1251
+ export const contract = defineContract({ extensions: { pgvector } }, ({ field, model, rel }) => {
1252
+ // ...
1253
+ })
1254
+ ```
1255
+
1256
+ `prisma.config.ts` imports each pack's `/control` façade, loads the project's `.env`, and resolves its connection through the stack's URL lookup (`DIRECT_DATABASE_URL`, then `DATABASE_URL`). Prisma's config evaluation loads no dotenv of its own, so without that load a project keeping its connection only in `.env` would reach `db update` and `migrate` with nothing set. The load is native — `process.loadEnvFile`, no dependency — and guarded, so a project with no `.env` still generates and runs:
1257
+
1258
+ ```typescript
1259
+ // prisma.config.ts — generated
1260
+ import { existsSync } from 'node:fs'
1261
+ import { join } from 'node:path'
1262
+ import { definePrismaConfig } from 'prisma/config'
1263
+ import { defineConfig } from '@prisma/orm-postgres/config'
1264
+ import { findDatabaseUrl } from '@opensaas/stack-core'
1265
+ import pgvector from '@prisma/orm-extension-pgvector/control'
1266
+
1267
+ const envFile = join(import.meta.dirname, '.env')
1268
+ if (existsSync(envFile)) process.loadEnvFile(envFile)
1269
+
1270
+ export default definePrismaConfig({
1271
+ orm: defineConfig({
1272
+ contract: './prisma/contract.ts',
1273
+ output: './prisma',
1274
+ extensions: [pgvector],
1275
+ db: { connection: findDatabaseUrl() },
1276
+ }),
1277
+ })
1278
+ ```
1279
+
1280
+ Commit `prisma/contract.ts`, `prisma/contract.json` and `prisma/contract.d.ts` — a schema change is then reviewable in the PR that made it, and CI can fail on a stale artifact.
1281
+
1282
+ The generated `.opensaas/context.ts` constructs its client from the committed `contract.json` rather than from a generated client package:
1283
+
1284
+ ```typescript
1285
+ postgres<Contract>({ contractJson, url: resolveDatabaseUrl() })
1286
+ ```
1287
+
1288
+ Core adds `resolveDatabaseUrl()` (throws when nothing is set) and `findDatabaseUrl()` (returns `undefined`) — the one place a connection string is read from `DIRECT_DATABASE_URL` or `DATABASE_URL` — plus `resolveListTimestamps`. `output.prismaSchema` is now `output.contractModule` (default `prisma/contract.ts`), and a plugin's `afterGenerate` receives `contractModule` where it received `prismaSchema`. The hook runs **before** `prisma contract emit`, so a rewritten `contractModule` is the one the emitted artifacts describe and the one the relation-graph gate checks — a rewrite the toolchain rejects fails `opensaas generate` rather than landing on disk unemitted.
1289
+
1290
+ Until the bundle is rewritten against `prisma/contract.d.ts`, the per-model `Select`, `Include`, `WhereInput`, `*Args` and write-`data` shapes in `.opensaas/types.ts` are unnarrowed placeholders: a query result is typed as the full model row (no `select`/`include` narrowing), and only the scalars OpenSaaS itself narrows are checked on a write.
1291
+
1292
+ `authPlugin`'s per-model `indexes` no longer document a `sort` direction on a field reference; an index column cannot carry one, and a `sort` key is refused at generation.
1293
+
1294
+ - [#1771](https://github.com/OpenSaasAU/stack/pull/1771) [`ad294d8`](https://github.com/OpenSaasAU/stack/commit/ad294d8e934bda0606870078e72e3d0c01a9c9f8) Thanks [@borisno2](https://github.com/borisno2)! - Hook-only fields: `access: { write: 'hooks' }`
1295
+
1296
+ No caller, `sudo()` included, may name the field in a create or update; only the list's own `resolveInput` sets it. The admin form renders it read-only and MCP omits it from write tools.
1297
+
1298
+ ```typescript
1299
+ state: select({ options, defaultValue: 'new', access: { write: 'hooks' } })
1300
+ ```
1301
+
1302
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Remove the PSL-shaped and TypeScript-face members from the field-builder contract
1303
+
1304
+ **Third-party field packages must migrate.** The generator emits a TypeScript
1305
+ contract module, not PSL (ADR-0040), and reads a field's TypeScript face from
1306
+ `outputType`/`inputType` (ADR-0052). Nothing consulted the PSL-shaped members
1307
+ any more, so they are gone from `BaseFieldConfig` and from every builder:
1308
+
1309
+ - `getPrismaType`
1310
+ - `getPrismaColumns`
1311
+ - `getPrismaRelation`
1312
+ - `getTypeScriptType`
1313
+ - `getTypeScriptImports`
1314
+ - `resultExtension`
1315
+ - `VirtualField.outputType` (the required `string` narrowing; the optional
1316
+ `outputType: TypeDescriptor` on `BaseFieldConfig` is what a virtual field
1317
+ declares now)
1318
+
1319
+ The `PrismaRelationResult`, `MultiColumnPrismaResult` and `ResultExtensionConfig`
1320
+ types they were shaped by are removed with them.
1321
+
1322
+ Migrating a field builder — describe the column instead of the PSL line:
1323
+
1324
+ ```ts
1325
+ // Before
1326
+ export function slug(options?: Omit<SlugField, 'type'>): SlugField {
1327
+ return {
1328
+ type: 'slug',
1329
+ ...options,
1330
+ getZodSchema: () => z.string().optional(),
1331
+ getPrismaType: () => ({ type: 'String', modifiers: '? @unique' }),
1332
+ getTypeScriptType: () => ({ type: 'string', optional: true }),
1333
+ }
1334
+ }
1335
+
1336
+ // After
1337
+ export function slug(options?: Omit<SlugField, 'type'>): SlugField {
1338
+ return {
1339
+ type: 'slug',
1340
+ ...options,
1341
+ getZodSchema: () => z.string().optional(),
1342
+ getContractField: (fieldName) => ({
1343
+ kind: 'column',
1344
+ name: fieldName,
1345
+ type: { pack: 'pg', type: 'text' },
1346
+ nullable: true,
1347
+ unique: true,
1348
+ }),
1349
+ }
1350
+ }
1351
+ ```
1352
+
1353
+ A field whose TypeScript face differs from its column's codec type declares it
1354
+ directly, rather than through `resultExtension` or `getTypeScriptType`:
1355
+
1356
+ ```ts
1357
+ // Before
1358
+ resultExtension: { outputType: "import('@my/pkg').Metadata | null" },
1359
+ getTypeScriptType: () => ({ type: 'Metadata | null', optional: true }),
1360
+ getTypeScriptImports: () => [{ names: ['Metadata'], from: '@my/pkg' }],
1361
+
1362
+ // After — the import is inline, so no separate import declaration is needed
1363
+ outputType: "import('@my/pkg').Metadata | null",
1364
+ inputType: "File | import('@my/pkg').Metadata | null",
1365
+ ```
1366
+
1367
+ A field spanning several physical columns returns `{ kind: 'columns', columns }`
1368
+ from `getContractField` and keeps `getColumnNames`/`assembleColumns`/`splitColumns`.
1369
+
1370
+ **The generate-time gate moved with the contract.** `validateFieldConfig` now
1371
+ requires `getContractField` and `getZodSchema` from a stored field (a
1372
+ relationship only the former), and additionally `outputType` from a field that
1373
+ has no single column to be typed from — one whose descriptor is
1374
+ `kind: 'columns'` or `kind: 'computed'`. Both are read off the descriptor, so a
1375
+ `computed` field carries the obligation whether or not its builder also sets the
1376
+ `virtual` flag that core's own `virtual()` sets alongside it. That closes a hole
1377
+ where such a field passed
1378
+ the gate, generated successfully, and left every consumer reading it as
1379
+ `unknown` (issue [#1292](https://github.com/OpenSaasAU/stack/issues/1292)). `FieldConfigValidationError.missingMethod` is renamed
1380
+ to `missingMember` to carry `outputType` alongside the two methods.
1381
+
1382
+ `validateFieldConfig`'s signature changed with it: `listKey` and a new fourth
1383
+ `config` argument are both **required**, because they are what
1384
+ `getContractField` takes and reading the descriptor is what makes the rule
1385
+ decidable. The optional `getColumnNames` is not consulted — it is a separate
1386
+ member that only travels with `kind: 'columns'` by convention, so reading it
1387
+ would both miss a `columns` field that does not implement it ([#1292](https://github.com/OpenSaasAU/stack/issues/1292)'s hole) and
1388
+ wrongly demand `outputType` from a single-column field that does.
1389
+ `FieldConfigValidationError.listKey` is likewise no longer optional.
1390
+
1391
+ The gate swallows a throw out of `getContractField`: that is a field's own
1392
+ refusal seam (`embedding()` throws there for an impossible `dimensions`).
1393
+ `opensaas generate` runs this gate first of all, and its config-surface step —
1394
+ `validateDatabaseConfig` → `validateExtensionPacks` — re-reads every descriptor
1395
+ straight afterwards and reports the throw as a `field-descriptor-error` refusal
1396
+ carrying the field's own message, so the run still fails with
1397
+ `List "<List>": fields.<field> cannot describe its contract column — <message>`
1398
+ rather than a raw stack trace. Derivation is never reached.
1399
+
1400
+ `inputType` is never required by the generator. On a single-column field its
1401
+ absence means the column's own input type; a `kind: 'columns'` field has no
1402
+ single column for that to name, so it should declare `inputType` alongside
1403
+ `outputType` — every multi-column field in this repo does, and what the
1404
+ generator emits for one that does not is untested.
1405
+
1406
+ **A field-level hook's value type is resolved from the field key, and is
1407
+ `unknown` when there is no single key to resolve.** `FieldHooks`'
1408
+ `resolveInput`/`resolveOutput` positions used to be typed from the deleted
1409
+ `getTypeScriptType`. `FieldHooks<TTypeInfo, 'title'>` now resolves to the
1410
+ field's statically declared `outputType`, or else to the property the generated
1411
+ `Lists.<List>.Item` carries for it.
1412
+
1413
+ But `BaseFieldConfig.hooks` cannot pin a field key — a builder is written
1414
+ before it knows where it is mounted — so through the config surface
1415
+ (`list<Lists.Post.TypeInfo>({ fields: { title: text({ hooks }) } })`) the
1416
+ instantiation is `FieldHooks<TTypeInfo>`, whose key is the union of every field
1417
+ on the list, and the value type is **`unknown`**: the same open type as before
1418
+ this change. Resolving that union would type each field's hook by the whole
1419
+ row, so a `text()` hook would accept a `Date` and reject its own `string`. An
1420
+ honestly `unknown` type is better than a confidently wrong one; narrowing it
1421
+ needs the field key threaded into `BaseFieldConfig`, tracked in issue [#1306](https://github.com/OpenSaasAU/stack/issues/1306).
1422
+
1423
+ Two related limits, for the same reason: `lists.ts` emits `Fields` as the field
1424
+ _interfaces_, on which `outputType` is optional, so a declared face never
1425
+ survives into a generated `TypeInfo` — the declared branch is reachable only
1426
+ from a hand-authored one. And a virtual field's hook value stays `unknown`,
1427
+ since it has no declared face there and no column in the stored row.
1428
+
1429
+ `db.keystoneCompat`'s implicit empty-string text default is now carried by
1430
+ `text()`'s contract column, where the deleted `getPrismaType` used to emit it —
1431
+ but only where the field's own create validator accepts **both** the omission
1432
+ that default is there to fill **and** the `''` it inserts. Both questions are
1433
+ asked of the schema rather than restated, so the column and the validator
1434
+ cannot drift apart:
1435
+
1436
+ - a column default drops the column from the required half of the generated
1437
+ `CreateInput`, so carrying one where the validator refuses an omission would
1438
+ type-check a `create` that then threw `ValidationError`;
1439
+ - and the value a column default inserts is never seen by validation — the
1440
+ database supplies it — so carrying one where the validator refuses `''`
1441
+ would store a row the config forbids on every omitted `create`. That is the
1442
+ outcome an explicit `defaultValue: ''` already gets right: it is filled by
1443
+ `applyCreateDefaults` before validation and correctly rejected. The two
1444
+ spellings of "this column defaults to an empty string" now agree.
1445
+
1446
+ **Known limit: the flag is therefore inert for
1447
+ `validation: { isRequired: true }` text — Keystone's commonest text column —
1448
+ and for `validation: { length: { min: N } }` with `N` above zero.** Keystone 6
1449
+ renders both as `NOT NULL DEFAULT ''`, so a migrating project sees
1450
+ `DROP DEFAULT` for them in `migrate diff`. Setting `defaultValue: ''` by hand
1451
+ is refused at runtime for the same reason, so the field's validation has to be
1452
+ relaxed alongside it. Full parity would need the flag to relax the create
1453
+ validator itself, which `getZodSchema` has no config to read; that is a
1454
+ separate change. A column made non-null through `db: { isNullable: false }`
1455
+ alone still gets the default, as does one carrying only a `length.max`.
1456
+
1457
+ Relatedly, `text()` no longer treats `validation: { length: { min: 0 } }` as
1458
+ `min(1)`. A zero minimum now means no minimum, so `''` validates — which is
1459
+ what the option says, and what lets such a column keep its compat default
1460
+ without the column and the validator disagreeing. `isRequired` still imposes a
1461
+ floor of `min(1)` on a field that declares `length: { min: 0 }` or no minimum
1462
+ at all, and never lowers a larger declared one — `isRequired` with
1463
+ `length: { min: 5 }` is still `min(5)`.
1464
+
1465
+ **Test coverage that thinned.** Three assertions were lost rather than ported,
1466
+ and are recorded here so the change is not silent:
1467
+
1468
+ - `select()`'s "falls back to a capitalized `fieldName` when `listName` is not
1469
+ provided" — `getContractField` is always given a `listKey`.
1470
+ - The quoted-vs-unquoted PSL default rendering for a string versus an enum
1471
+ `select()` — the contract carries one `{ kind: 'literal' }` for both.
1472
+ - The per-field `getTypeScriptType` blocks in `tests/field-types.test.ts`
1473
+ became `expect(field.outputType).toBeUndefined()` — "declares no override",
1474
+ which is weaker than the old "text is `string`, optional when not required".
1475
+ Column nullability is still asserted on the same fields, and the codec now
1476
+ owns the type (ADR-0052), so the fact has moved rather than vanished.
1477
+
1478
+ - [#1741](https://github.com/OpenSaasAU/stack/pull/1741) [`e1f93c0`](https://github.com/OpenSaasAU/stack/commit/e1f93c0a9cd2c5e0a5ccb82b8a2cfcce9ef1db0e) Thanks [@borisno2](https://github.com/borisno2)! - List-level admin UI options `ui.hideCreate`, `ui.hideDelete` and `ui.itemView.defaultFieldMode`
1479
+
1480
+ Each takes a literal or a function of the session, resolved on the server. They change what the admin offers, never access control, hooks or server actions.
1481
+
1482
+ ```typescript
1483
+ Ledger: list({
1484
+ access: { operation: { create: isAdmin, update: isAdmin, delete: isAdmin } },
1485
+ ui: {
1486
+ hideCreate: true,
1487
+ hideDelete: ({ session }) => session?.role !== 'OWNER',
1488
+ itemView: { defaultFieldMode: 'read' },
1489
+ },
1490
+ })
1491
+ ```
1492
+
1493
+ `hideCreate` removes the list header, empty-state, dashboard and relationship-drawer Create affordances and renders `/create` as not-found. `hideDelete` removes row, bulk and item-view Delete. `defaultFieldMode: 'read'` renders the item view read-only with no Save.
1494
+
1495
+ - [#1893](https://github.com/OpenSaasAU/stack/pull/1893) [`9c226fd`](https://github.com/OpenSaasAU/stack/commit/9c226fd95272dbe9a64cd8299734da64ebbc80dc) Thanks [@borisno2](https://github.com/borisno2)! - `createMcpHandlers` accepts an optional `resourceMetadataUrl`; when set, the 401 `WWW-Authenticate` challenge carries `resource_metadata` (RFC 9728) so MCP clients can discover the authorization server.
1496
+
1497
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - `.select()` is honoured exactly, and the fragment API is deleted
1498
+
1499
+ The breaks below are real and are documented in full. They ship on `minor`,
1500
+ as every other changeset on this line does: before 1.0, a minor release is
1501
+ where breaking changes go.
1502
+
1503
+ A read on the secured surface is narrowed with `.select(...fields)`, which the
1504
+ engine honours exactly: it widens the query by the declared dependency sets of
1505
+ the computed fields the read will return and by anything a row-dependent field
1506
+ `read` rule has to see, then strips `widened ∖ caller` as a recursive set
1507
+ difference at every nesting level. `.select()` replaces on call rather than
1508
+ accumulating, names this list's own fields only, and a computed field is
1509
+ selectable whether or not the columns it reads were named. An `.include()`
1510
+ refinement carries its own `.select()`.
1511
+
1512
+ ```typescript
1513
+ // `wordCount` declares `needs: ['body']`. The engine reads `body`, computes the
1514
+ // field, and `body` is not in the result — the caller did not ask for it.
1515
+ const rows = await context.db.Post.select('wordCount')
1516
+ .include('author', (author) => author.select('name'))
1517
+ .all()
1518
+ ```
1519
+
1520
+ `.select()` is on the generated typed surface, so a projected read's row type
1521
+ is exactly the keys it named plus the list's system fields — an unselected
1522
+ column, and anything the engine widened the query by, is a compile error rather
1523
+ than an absent value. A relation named in `.select()` is refused at compile
1524
+ time and, at runtime, with `RelationSelectError` (now exported from the package
1525
+ root).
1526
+
1527
+ `.limit(count)` joins the composed read as well, bounding `.all()`.
1528
+
1529
+ Relation-valued `needs` are now folded into the read on the new terminals, so
1530
+ `.all()` / `.first()` and the legacy read path agree on a computed field with a
1531
+ relation dependency.
1532
+
1533
+ Two behaviours change on every read path, per ADR-0051:
1534
+
1535
+ - **A `resolveOutput` hook's `item` is exactly its own declared dependency set
1536
+ plus the list's system fields.** A hook that reads a key it did not declare in
1537
+ `needs` now finds nothing there. Migration: find `resolveOutput` hooks whose
1538
+ `item` reads a key absent from that field's `needs`, and declare it.
1539
+ - **A declaration outranks a caller-facing `read` denial** on the same column or
1540
+ relation. The value reaches the hook and is still stripped before the caller
1541
+ sees it, so adding a `read` rule elsewhere can no longer silently change a
1542
+ computed field's value — and `needs: ['passwordHash']` is a deliberate way to
1543
+ surface a denied column's derived value.
1544
+
1545
+ `defineFragment`, `runQuery`, `runQueryOne`, `ResultOf`, `RelationSelector`,
1546
+ `QueryArgs`, `Fragment`, `FieldSelection`, `buildInclude`, `pickFields` and the
1547
+ `query:` argument on `findMany` / `findFirst` / `findUnique` are removed.
1548
+
1549
+ Migration:
1550
+
1551
+ ```typescript
1552
+ // Before
1553
+ const postFragment = defineFragment<Post>()({ id: true, title: true } as const)
1554
+ const posts = await context.db.post.findMany({ query: postFragment, where: { published: true } })
1555
+
1556
+ // After
1557
+ const posts = await context.db.Post.where({ published: { equals: true } })
1558
+ .select('title')
1559
+ .all()
1560
+ ```
1561
+
1562
+ A nested fragment or `RelationSelector` becomes an `.include()` refinement:
1563
+
1564
+ ```typescript
1565
+ // Before
1566
+ defineFragment<Post>()({
1567
+ id: true,
1568
+ comments: { query: commentFragment, where: { approved: true }, take: 5 },
1569
+ } as const)
1570
+
1571
+ // After
1572
+ context.db.Post.select('title').include('comments', (comments) =>
1573
+ comments
1574
+ .where({ approved: { equals: true } })
1575
+ .limit(5)
1576
+ .select('body'),
1577
+ )
1578
+ ```
1579
+
1580
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@{](https://github.com/{)! - The secured surface takes the closed Where vocabulary, lowered in one place
1581
+
1582
+ `context.db.<List>.where(...)` now accepts the whole vocabulary — `equals`,
1583
+ `not`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `contains`, the `AND`/`OR`/`NOT`
1584
+ combinators, and `some`/`every`/`none` on a relation of any cardinality — plus a
1585
+ new scalar-only `.orderBy()`. Everything lowers onto the ORM's predicate lambda
1586
+ in one place (ADR-0055).
1587
+
1588
+ ```typescript
1589
+ const posts = await context.db.Post.where({
1590
+ OR: [{ title: { contains: 'release' } }, { views: { gte: 100 } }],
1591
+ some: { handle: { equals: 'ada' } } },
1592
+ })
1593
+ .orderBy({ views: 'desc' })
1594
+ .all()
1595
+ ```
1596
+
1597
+ - `contains` is engine-escaped and case-insensitive, so `contains: '50%'` matches
1598
+ a literal per-cent sign rather than binding a wildcard.
1599
+ - `equals: null` lowers to `IS NULL`, `not: null` to `IS NOT NULL`.
1600
+ - A relation predicate scopes the `EXISTS` by the related list's own `query`
1601
+ access. `some` and `none` ask about the rows the caller may see; `every` asks
1602
+ whether every row the caller may see matches, so a row the caller cannot see
1603
+ never decides the parent's membership. A related list the session cannot
1604
+ query is the empty set: `some` is false, `none` and `every` are true.
1605
+ - An Access Filter that scopes by a relation is expanded into the related list's
1606
+ own Access Filter. A filter that expands into itself — directly, or through
1607
+ another list — throws `AccessFilterRecursionError` naming the chain, rather
1608
+ than recursing until the process runs out of memory. An acyclic chain deeper
1609
+ than ten lists is refused the same way. Failing closed is deliberate: a
1610
+ truncated Access Filter is a widened read.
1611
+ - An unknown key or operator is a `ValidationError` naming the list and the key,
1612
+ under `sudo` too. A key the session cannot read is refused with the identical
1613
+ message a key the list does not declare gets, so the refusal is not an
1614
+ existence oracle; a denied caller still gets the Silent failure first and sees
1615
+ no validation error at all.
1616
+
1617
+ **Lowering is now total.** A condition that resolved to `undefined` is refused
1618
+ rather than dropped, on both spellings. An access rule written as
1619
+ `({ session }) => ({ authorId: session?.userId })` used to match every row for an
1620
+ anonymous caller; it now throws. Spell the denial:
1621
+
1622
+ ```typescript
1623
+ // Before — silently matched everything when session was null
1624
+ query: ({ session }) => ({ authorId: session?.userId })
1625
+
1626
+ // After
1627
+ query: ({ session }) => (session ? { authorId: { equals: session.userId } } : false)
1628
+ ```
1629
+
1630
+ The same refusal now covers the clause `mergeFilters` folds in, so the guarantee
1631
+ holds on every surface rather than only on `.where().all()/.first()`: an access
1632
+ filter carrying an `undefined` condition anywhere (including nested under an
1633
+ operator or inside an `AND`/`OR` branch) throws the new, exported
1634
+ `UndefinedAccessFilterError`. A caller's own `where` is untouched — this applies
1635
+ only to what an access rule returns.
1636
+
1637
+ **Also changed:** the filter engine's `FilterCondition` is a Where vocabulary
1638
+ value; a to-one relationship's label filter emits `some` rather than `is`; a
1639
+ to-many count filter shrinks to presence (`orders:0` → `none`, `orders:>0` /
1640
+ `orders:>=1` → `some`, any other comparison degrades to free text);
1641
+ and read-path key validation rejects an operator outside the vocabulary
1642
+ (`startsWith`, `endsWith`, `mode`, `search` and the array/JSON operators are
1643
+ gone).
1644
+
1645
+ **Removed exports.** These have no replacement — the behaviour they carried is
1646
+ either gone or now expressed in the Where vocabulary:
1647
+
1648
+ | Removed | What to do instead |
1649
+ | --------------------------------------------- | -------------------------------------------------------------- |
1650
+ | `RELATIONSHIP_COUNT_FILTER_KEY` | Nothing — the count-filter marker no longer exists. |
1651
+ | `RelationshipCountFilterMarker` | Nothing — same. |
1652
+ | `resolveRelationshipCountFilters` | Nothing — a count filter shrinks to `some`/`none` when parsed. |
1653
+ | `resolveRelationshipLabelFilters` | Nothing — a to-one label filter emits `some` directly. |
1654
+ | `isToOneRelationshipField` | Read `many` off the relationship field config. |
1655
+ | `ColumnEquality`, `UnsupportedPredicateError` | Gone with the predicate builder they belonged to. |
1656
+
1657
+ **Newly exported:** `UndefinedAccessFilterError` and, from the secured surface,
1658
+ `AccessFilterRecursionError`.
1659
+
1660
+ - [#1878](https://github.com/OpenSaasAU/stack/pull/1878) [`a2d6d6e`](https://github.com/OpenSaasAU/stack/commit/a2d6d6e17072f3cd9bd202f40fd1865d0ef8a41d) Thanks [@borisno2](https://github.com/borisno2)! - `McpSessionProvider` receives the incoming `Request`
1661
+
1662
+ `createBetterAuthMcpAdapter` verified every token against a synthetic `POST` to the resource, so a DPoP-bound token with a correct proof was rejected on the MCP `GET` and `DELETE` routes. The provider now gets the real request and verifies against its method and URL, without consuming the body.
1663
+
1664
+ Migration: `getSession: (headers) => …` becomes `getSession: (req) => … req.headers …`.
1665
+
1666
+ - [#1764](https://github.com/OpenSaasAU/stack/pull/1764) [`0a18d1f`](https://github.com/OpenSaasAU/stack/commit/0a18d1f74117a61f495870c26c975c49802a1547) Thanks [@borisno2](https://github.com/borisno2)! - Opt-in OAuth scope enforcement for MCP tools
1667
+
1668
+ ```typescript
1669
+ mcp: { enabled: true, scopes: { read: 'mcp:read', write: 'mcp:write' } }
1670
+ ```
1671
+
1672
+ `query` tools require the `read` scope(s); `create`/`update`/`delete` require `write`. A list's `mcp.scopes` overrides the config-level value, and a custom tool or `registerMcpTool` tool can declare `scopes: ['reports:run']`. A token missing a scope gets a tool error naming it and the tool is omitted from `tools/list`. With nothing configured, behaviour is unchanged.
1673
+
1674
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Generation emits the dependency-set table and the unique-constraint map; the runtime dependency fold is deleted
1675
+
1676
+ `pnpm generate` now resolves each computed field's `needs` into its one-hop set — columns and relations, a relation implying its foreign-key column — records each list's actual system fields, and writes both plus a unique-constraint-name-to-field-names map to `.opensaas/tables.ts`. The generated context hands them to the runtime, so the engine widens a read from an emitted fact instead of walking the config on every read (ADR-0051), and a unique violation can resolve to per-field messages without parsing error prose (ADR-0042).
1677
+
1678
+ ```ts
1679
+ // .opensaas/tables.ts
1680
+ export const dependencyTable: DependencyTable = {
1681
+ Post: {
1682
+ systemFields: ['id', 'createdAt', 'updatedAt'],
1683
+ fields: {
1684
+ byline: { columns: ['authorId', 'title'], relations: ['author'] },
1685
+ },
1686
+ },
1687
+ Category: { systemFields: ['id'], fields: {} }, // db.timestamps: false
1688
+ }
1689
+
1690
+ export const constraintMap: ConstraintMap = {
1691
+ User_email_key: { list: 'User', fields: ['email'] },
1692
+ Profile_user_key: { list: 'Profile', fields: ['user'] },
1693
+ }
1694
+ ```
1695
+
1696
+ Core exports `deriveDependencyTable(config)`, `deriveConstraintMap(config, contract)` and `deriveGeneratedTables(config, contract)` for anything that needs the same facts.
1697
+
1698
+ The dependency set is one hop and non-transitive, so a declaration can no longer form a closure: `validateNeedsClosureDepth` and its `'cycle'`/`'depth'` refusals, the recursive `foldDeclaredDependencies`, its `visitedLists` cycle guard and `DeclaredOnlyTree` are all removed. A config that used to fail generation with an over-deep or cyclic `needs` closure now generates. `validateNeedsDeclarations` is unchanged and still refuses an entry naming nothing on the list, an entry naming a computed field, and a `needs` on a field with no `resolveOutput` hook.
1699
+
1700
+ One behaviour change to be aware of: a relation fetched only to satisfy a declaration no longer has its own computed fields run, so it no longer carries its own declarations either. A hook needing two hops takes a privileged read inside itself.
1701
+
1702
+ **Migration note (silent break):** a `resolveOutput` hook on a list reached only as another field's declared dependency stops running. Its value was already stripped from the caller's result along with the branch, so nothing a caller receives changes — but a hook with a side effect (a counter, a log, a cache write) loses it. Grep for `resolveOutput` hooks on lists that appear in another list's `needs` and do more than return a value.
1703
+
1704
+ The derived constraint names now match what PostgreSQL actually stores for an identifier over 63 bytes. A primary key is emitted unnamed and PostgreSQL derives it with `makeObjectName`, which reserves the `_pkey` label and shrinks the table component (`<58 chars>_pkey`); a unique is named by Prisma and only clipped by PostgreSQL, which keeps the leading 63 bytes and loses `_key`. Previously both were clipped, so every derived primary-key name over the limit was wrong and a `23505` on it would have missed the map.
1705
+
1706
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - `richText()` is generic over `TTypeInfo`, so it composes with a typed list
1707
+
1708
+ Every other field builder — core's `text()`/`json()`, storage's `file()`/`image()` — carries the list's `TypeInfo` through, but `richText()` was pinned to the default. A field declared inside a `list<Lists.Article.TypeInfo>()` therefore failed to type-check with `Type 'string' is not assignable to type '"Article"'`, and the only way to use the field was to drop the generated TypeInfo from the list.
1709
+
1710
+ ```ts
1711
+ import { richText } from '@opensaas/stack-tiptap/fields'
1712
+ import type { Lists } from '@/.opensaas/lists'
1713
+
1714
+ Article: list<Lists.Article.TypeInfo>({
1715
+ fields: {
1716
+ // now infers TTypeInfo from the surrounding list, so the field's own
1717
+ // hooks see `listKey: 'Article'` and the list's field keys
1718
+ content: richText({ validation: { isRequired: true } }),
1719
+ },
1720
+ })
1721
+ ```
1722
+
1723
+ No call-site change is required: the parameter is inferred, and an untyped `list({ … })` keeps the previous default.
1724
+
1725
+ A required `richText()` field can also be left out of a partial update again. Its update schema was `z.union([z.any(), z.undefined()])`, which is still a _required_ key inside `z.object()`, so any update that did not mention the field — editing only an article's title, say — was refused with `expected nonoptional, received undefined`. The schema is now `.optional()`, matching core's `json()`; a present `null` is still rejected, because required means non-null.
1726
+
1727
+ The matching hole on **create** is closed too. The create schema was a bare `z.any()`, which inside `z.object()` rejects an absent key but accepts a present `null` or explicit `undefined` — so a required field could be created empty and the write reached a non-nullable column with nothing in it. It now carries the same refinement core's `json()` uses.
1728
+
1729
+ `TiptapField` no longer resets the document while you type. Its `onChange` was typed as `UseEditorOptions['onUpdate']` and handed the whole editor-update payload straight to the field's `onChange`, rather than the JSON value the field stores; the props are now `value: JSONContent | null` and `onChange: (value: JSONContent) => void`, and the component calls `editor.getJSON()` itself. The accompanying `useEffect` compared `value` against `editor.getJSON()` by identity — `getJSON()` allocates a fresh object every call, so the check never matched and `setContent` re-ran on every keystroke, dropping the caret. It now short-circuits on the object it last emitted, and otherwise compares the serialised forms, so it fires only on a genuinely external change.
1730
+
1731
+ **`TiptapField` also no longer reports an edit nobody made.** Two Tiptap calls emit an `update` by default, and this component forwarded both to `onChange`:
1732
+
1733
+ - `setContent(content)` — `emitUpdate` defaults to `true`, so mounting with a `null` value pushed `{"type":"doc","content":[{"type":"paragraph"}]}` into form state;
1734
+ - `setEditable(editable)` — its second argument is `emitUpdate`, also defaulted to `true`, so merely becoming editable counted as a content change.
1735
+
1736
+ Between them, creating a record while touching neither rich-text field submitted both as empty documents: an **optional** `richText()` column was written an empty doc instead of `null`, and a **required** one was satisfied without the user typing anything. Both calls now pass `false`, and a suite covers mount, editability changes, the controlled keystroke round trip, an externally reloaded row, and a form resetting the field to `null`.
1737
+
1738
+ `formatFieldName` is now exported from `@opensaas/stack-core/extend`, the third-party field-authoring surface:
1739
+
1740
+ ```ts
1741
+ import { formatFieldName } from '@opensaas/stack-core/extend'
1742
+
1743
+ formatFieldName('internalNotes') // 'Internal Notes'
1744
+ ```
1745
+
1746
+ `richText()` uses it, so its validation messages address a field the same way core's `json()` does — a form carrying both no longer says `content is required` for one and `Content is required` for the other.
1747
+
1748
+ `@opensaas/stack-tiptap` gains a test suite (`pnpm test`); it had none. It runs under `happy-dom` so the component's behaviour is covered against a real ProseMirror document, not just the schema.
1749
+
1750
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - The write terminals run over the rc.8 collection, and nested relation input leaves the payload
1751
+
1752
+ `create`, `update` and `delete` now reach the database through the Prisma 8
1753
+ collection itself — `collection.create(row)`, `collection.where(…).update(row)`,
1754
+ `collection.where(…).delete()` — instead of the Prisma 7 delegate names. Every
1755
+ write still opens a transaction, and the phase order is unchanged: operation
1756
+ access outside the transaction, then hooks, validation, writable-field
1757
+ filtering, persistence, after-hooks and Field Visibility.
1758
+
1759
+ `update` and `delete` target a row by its identity and nothing else. The engine
1760
+ lowers `id` alone into a write's predicate, so a `where` naming another column —
1761
+ a secondary unique one included — is now a compile error against
1762
+ `ListIdentityWhere`, and a thrown caller-shape error at runtime for a payload
1763
+ that arrived untyped. It never silently writes nothing:
1764
+
1765
+ ```typescript
1766
+ // Compile error, and a throw at runtime: `email` selects no row to write.
1767
+ await context.db.User.update({ where: { email: 'a@b.com' }, data: { name: 'Ada' } })
1768
+
1769
+ // Find the row, then write it by its id.
1770
+ const user = await context.db.User.findUnique({ where: { email: 'a@b.com' } })
1771
+ if (user) await context.db.User.update({ where: { id: user.id }, data: { name: 'Ada' } })
1772
+ ```
1773
+
1774
+ `update` and `delete` now merge the list's Access Filter into the predicate of
1775
+ the write itself, beside the row's identity, so the statement acts on the same
1776
+ rows the read would return:
1777
+
1778
+ ```typescript
1779
+ Post: list({
1780
+ access: {
1781
+ operation: {
1782
+ update: ({ session }) => ({ authorId: { equals: session?.userId } }),
1783
+ },
1784
+ },
1785
+ })
1786
+
1787
+ // Runs `UPDATE … WHERE id = … AND "authorId" = …`; a row the filter excludes
1788
+ // answers `null`, denied-or-gone, exactly as a denied read does.
1789
+ await context.db.Post.update({ where: { id }, data: { title: 'edited' } })
1790
+ ```
1791
+
1792
+ Because the filter is lowered through the same Where vocabulary a read uses, an
1793
+ Access Filter must now name fields the list declares — a rule that scoped by an
1794
+ undeclared column is refused rather than silently passed through.
1795
+
1796
+ Nested relation input leaves the write payload, `connect` excepted (ADR-0050).
1797
+ `create`/`update`/`delete`/`connectOrCreate`/`disconnect`/`set`/`updateMany`/`deleteMany`
1798
+ under a relationship key are a compile error against the generated input types
1799
+ and a `NestedRelationInputError` at runtime; `{ connect: { id } }` survives,
1800
+ because it lowers onto a foreign-key column the row being written owns.
1801
+
1802
+ `disconnect` has a direct replacement on the side that owns that column — assign
1803
+ `null` to the relationship field, which is the same column and the same
1804
+ lowering. On a field owning no column, `null` is refused in turn with
1805
+ `NonOwningRelationInputError`, so that edge is cleared by an update against the
1806
+ target list. The remaining kinds have no replacement in the payload at all:
1807
+ write the related rows yourself and wrap them in `context.transaction` when they
1808
+ must land together:
1809
+
1810
+ ```typescript
1811
+ await context.transaction(async (tx) => {
1812
+ const author = await tx.db.Author.create({ data: { name: 'Ada' } })
1813
+ await tx.db.Post.create({ data: { title: 'Notes', authorId: author.id } })
1814
+ })
1815
+ ```
1816
+
1817
+ `connect` is the one spelling ADR-0050 keeps, and the engine lowers it onto the
1818
+ column the row carries — see `amber-keys-reach.md` for the reachability query it
1819
+ issues first. An owning field carrying neither `{ connect: { id } }` nor `null`
1820
+ is refused by name with a `MalformedRelationInputError` naming the list and the
1821
+ field, rather than reaching the driver as a column value and failing as a raw
1822
+ type error that names neither. Every refusal on this surface is checked against
1823
+ both the caller's payload and the data a `resolveInput` hook produced, and each
1824
+ recognises a synthetic `from_<List>_<field>` back-relation key rather than
1825
+ mistaking it for a column of this list.
1826
+
1827
+ `afterTransaction` no longer reports `committed` for a write that persisted
1828
+ nothing. A write whose predicate matched no row — the row dropped by a
1829
+ `beforeOperation` hook, say — answers `null` to the caller and `rolled-back` to
1830
+ the bracket, so a compensator keyed on `committed` never acts on a write that
1831
+ did not happen.
1832
+
1833
+ `context.db.<List>.createMany` and `updateMany` are removed — both ran one
1834
+ secured write per item, which `context.transaction` expresses directly — and
1835
+ `packages/core/src/context/nested-operations.ts` is deleted with them.
1836
+
1837
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Add `aggregate`, include count reducers, `combine`, `distinct`/`distinctOn` and `cursor` to the secured read surface
1838
+
1839
+ `aggregate` counts only the rows the session may see, so a count always equals the length of the same session's `.all()`. A denied read answers `0` under every key rather than throwing — the empty value of a count's type, indistinguishable from a genuinely empty scoped set.
1840
+
1841
+ ```typescript
1842
+ const { total } = await context.db.Post.where({ published: { equals: true } }).aggregate(
1843
+ (aggregate) => ({ total: aggregate.count() }),
1844
+ )
1845
+ ```
1846
+
1847
+ An include refinement can reduce a to-many relation to a count, scoped by both the related list's `query` access and the relationship field's own `read` rule. `combine` holds several counts over one relation, each its own independently scoped subquery:
1848
+
1849
+ ```typescript
1850
+ const users = await context.db.User.include('posts', (posts) =>
1851
+ posts.combine({
1852
+ published: posts.where({ published: { equals: true } }).count(),
1853
+ total: posts.count(),
1854
+ }),
1855
+ ).all()
1856
+ // each row: { …user, posts: { published: number; total: number } }
1857
+ ```
1858
+
1859
+ `distinct(...fields)`, `distinctOn(...fields)` and `cursor(values)` join the read subset. Every column they name goes through the same read gate a `where` key does, so a field this session cannot read is refused exactly as an undeclared one is — as is one that is declared but stored nowhere, such as a `virtual()` field. `cursor` requires a prior `orderBy`, and `distinctOn` requires one that leads with its own columns, so a pair Postgres would reject with `42P10` is refused by name instead. An empty column list, and a second `distinct` or `distinctOn` on the same read, are both refused rather than silently answering a different question.
1860
+
1861
+ `nearest()` refuses a read that composed `distinct` or a cursor, as `aggregate` does: the ranking is that query's leading order, so a cursor has no axis left to resume along and a distinct would collapse rows the limit is already counted over.
1862
+
1863
+ `groupBy`, the `*All` family, `*AndCount` and `upsert` remain absent from the surface: a method appears only where the engine knows how to scope it.
1864
+
1865
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - The core test corpus is organised by guarantee and the coverage ratchet is re-baselined
1866
+
1867
+ `packages/core/tests/` is gone. Every suite that stood the engine up on a hand-built
1868
+ object of `vi.fn()` per-model delegates has been rewritten against the Test context —
1869
+ an in-process Postgres per Vitest worker, honouring the `DATABASE_URL` escape
1870
+ (ADR-0057) — and the rest moved beside the module it covers, so the whole corpus now
1871
+ lives under `packages/core/src/`.
1872
+
1873
+ The suites are named for the glossary term they protect: Silent failure, Access Filter,
1874
+ Field Visibility, the Where vocabulary, the Declared dependency set, the Write Pipeline,
1875
+ the Row lock and the Engine stamp.
1876
+
1877
+ Nothing about writing a test against `@opensaas/stack-core/testing` changes:
1878
+
1879
+ ```typescript
1880
+ import { createTestContext } from '@opensaas/stack-core/testing'
1881
+
1882
+ const harness = await createTestContext(config, { userId: 'u1' })
1883
+ await harness.context.db.Post.create({ data: { title: 'ship it' } })
1884
+ expect(await harness.context.db.Post.all()).toHaveLength(1)
1885
+ await harness.close()
1886
+ ```
1887
+
1888
+ ADR-0002's per-glob coverage ratchet is re-baselined once against the new corpus and
1889
+ still enforced by `pnpm --filter @opensaas/stack-core test:coverage`. No threshold was
1890
+ lowered and no path was excluded.
1891
+
1892
+ - [#1556](https://github.com/OpenSaasAU/stack/pull/1556) [`477a75b`](https://github.com/OpenSaasAU/stack/commit/477a75bbfd2ee6e95ed78941b837cad7eea6a5f1) Thanks [@borisno2](https://github.com/borisno2)! - Fix a read-restricted `embedding()` field re-embedding on every write forever: the regeneration skip read the stored hash off the write's own Field-Visibility-filtered projection instead of the row, so a session denied read on the field always saw `undefined` and paid for a fresh provider call on every subsequent write ([#1282](https://github.com/OpenSaasAU/stack/issues/1282)). The regeneration check now costs one extra id-scoped read per write on a list with an `autoGenerate` embedding field, whether or not the field is read-restricted — a fixed, small price for correctness the in-memory comparison could no longer pay for.
1893
+
1894
+ `@opensaas/stack-core` gains `readPluginOwnedRow` and `HandlelessPluginFieldReadError` from `@opensaas/stack-core/extend` — the read-side twin of `writePluginOwnedField` (ADR-0068), for a plugin that needs to see a row as persisted rather than through the caller's access-controlled projection:
1895
+
1896
+ ```typescript
1897
+ import { readPluginOwnedRow } from '@opensaas/stack-core/extend'
1898
+
1899
+ const row = await readPluginOwnedRow({ context, listName: 'Article', id })
1900
+ ```
1901
+
1902
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Framework components and `createAuth` accept the app's generated context; core is declared side-effect free
1903
+
1904
+ The generated `Context` and the engine's `AccessContext` describe one request from two faces, and neither type is assignable to the other. `@opensaas/stack-ui`'s public components (`AdminUI`, `Dashboard`, `Navigation`, `ListView`, `ItemForm`, `SingletonView`, `RelationshipTable`) and `@opensaas/stack-auth`'s `createAuth` / `buildBetterAuthOptions` now take the app-facing context — what `getContext()` and `rawOpensaasContext` produce — so a page passes it straight through:
1905
+
1906
+ ```tsx
1907
+ import { getContext, config } from '@/.opensaas/context'
1908
+
1909
+ export default async function AdminPage() {
1910
+ return (
1911
+ <AdminUI context={await getContext()} config={await config} serverAction={serverAction} />
1912
+ )
1913
+ }
1914
+ ```
1915
+
1916
+ Core exports the bridge for other framework code: `AnyStackContext` is the type of a context on either face, and `engineContextOf(context)` returns the engine's `AccessContext` for it (`EngineContextUnavailableError` for a hand-assembled object).
1917
+
1918
+ **Watch for this when you upgrade.** The seven components above previously read `context.db[listKey]` and `context.session` and worked with any object carrying them. They now narrow through `engineContextOf`, which accepts a context the engine built or a full `AccessContext` and throws otherwise. A hand-assembled stand-in — a component test's double, a Storybook story, a wrapper that rebuilds `{ db, session, … }` by hand instead of passing `getContext()`'s result through — now throws at render. Pass a context from `getContext()`, or from `createTestContext` in `@opensaas/stack-core/testing`.
1919
+
1920
+ Two engine fixes the first Next app on Prisma 8 exposed:
1921
+
1922
+ - The origin store the tripwire reads, and the key an app-facing context carries its engine face under, are one per process rather than one per module instance. Next.js compiles the page layer and the route-handler layer separately, each with its own copy of the module, while the generated context caches one client for both: a query marked through one layer's Unsafe surface was refused as unmarked by the other layer's tripwire (every `/api/auth/*` route answered 500), and a context built by one layer's `getContext()` could not be narrowed by the other layer's `engineContextOf`. Both now resolve through one helper over the symbol registry `globalThis` shares.
1923
+ - On the include path the ORM hands an included to-one back under its foreign-key key as well as its own, so a row-dependent field `read` rule comparing `item.authorId` saw the related row rather than its id and denied the author. A field `read` rule is now answered against the row's own stored foreign key whichever way the row was read, so the same rule gives the same answer with and without `.include()` — including where the related list's Access Filter scopes the relation away, which previously made `item.authorId` read as `null` and could open a field whose rule tests for an absent relation. Every terminal (`all()`, `first()`, the `forUpdate()` lane, `nearest()`) returns rows through one funnel that runs both foreign-key passes; a read whose to-one include is narrowed costs one extra query to read the column the include's alias overwrites ([#1236](https://github.com/OpenSaasAU/stack/issues/1236)).
1924
+
1925
+ Core's `package.json` now declares `"sideEffects": false`. The root barrel re-exports modules that import `node:fs` and `node:async_hooks`; a client component importing a value from the barrel — as the admin's own do — would otherwise pull them into the browser bundle and fail to compile under Turbopack. The declaration is truthful: no module in core has an import-time effect a consumer relies on.
1926
+
1927
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Add the `nearest()` vector-search terminal to the secured read surface
1928
+
1929
+ `context.db.<List>.where(…).nearest(field, vector, { limit, minScore })` runs one
1930
+ scoped similarity query over a native `Vector(n)` column and returns
1931
+ `{ item, score }`. The ranking, the `limit` and the `minScore` bound all sit
1932
+ inside the query alongside the Access Filter, so top-K is computed over the rows
1933
+ the session may see rather than filtered down afterwards, and the raw distance is
1934
+ never exposed. Searching requires read access to the embedding field: ordering by
1935
+ a vector measures its contents, so a session that cannot read it is refused with
1936
+ the message an undeclared key gets.
1937
+
1938
+ ```typescript
1939
+ const hits = await context.db.Article.where({ published: true }).nearest(
1940
+ 'embedding',
1941
+ queryVector,
1942
+ {
1943
+ limit: 5,
1944
+ minScore: 0.8,
1945
+ },
1946
+ )
1947
+
1948
+ for (const { item, score } of hits) {
1949
+ console.log(item.title, score)
1950
+ }
1951
+ ```
1952
+
1953
+ The database owns the ordering. `score` is the same distance function recomputed
1954
+ from the row's own vector, in float64 over a float4 column, so two tied rows can
1955
+ arrive in an order their scores do not reproduce — read it as the similarity, not
1956
+ as the sort key. A column that does not read back as a vector raises
1957
+ `VectorDecodeError` naming the list and field, rather than scoring `NaN`.
1958
+
1959
+ A field declares its vector column through the new `getVectorColumn` member of
1960
+ `BaseFieldConfig`, which core reads to know the column, its dimension and the
1961
+ distance function (`cosine`, `l2` or `inner_product`) — a descriptor naming any
1962
+ other distance function is refused:
1963
+
1964
+ ```typescript
1965
+ getVectorColumn: (fieldName) => ({
1966
+ column: fieldName,
1967
+ dimensions: 1536,
1968
+ distanceFunction: 'cosine',
1969
+ })
1970
+ ```
1971
+
1972
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - The item form writes to-many edges against the related list, and admin routing parses ids through the contract
1973
+
1974
+ A to-many relationship's foreign key lives on the related row, so it can never ride in the record's own update payload — and connecting through an inverse field no longer compiles. The item form's multi-select now writes each edge as a write against the **related list**, under that list's own access control: adding one sets the related row's foreign key, removing one clears it. A denied write reverts the control to what the database actually holds and shows the reason, instead of navigating away on a save that never landed.
1975
+
1976
+ The related-row writes go through two server actions, both keyed on the related list:
1977
+
1978
+ ```typescript
1979
+ // Link an existing related row to the parent (new)
1980
+ await serverAction({
1981
+ listKey: 'Post',
1982
+ action: 'linkRelated',
1983
+ id: postId,
1984
+ field: 'author',
1985
+ parentId: userId,
1986
+ })
1987
+
1988
+ // Unlink it again (unchanged)
1989
+ await serverAction({
1990
+ listKey: 'Post',
1991
+ action: 'removeRelated',
1992
+ mode: 'disconnect',
1993
+ id: postId,
1994
+ field: 'author',
1995
+ })
1996
+ ```
1997
+
1998
+ Nothing needs configuring: a to-many whose back-reference owns a nullable foreign key becomes editable on the edit form automatically. A to-many with no writable edge — a list-only `ref`, a required foreign key (`db.isNullable: false` or `validation: { isRequired: true }`), or an edge across an explicit junction list — stays read-only with its reason.
1999
+
2000
+ On the **default** edit route a to-many renders as a relationship table rather than a multi-select, so that table's "Link existing" control — until now offered only for an edge across a junction list — now also links an existing related row by writing its own foreign key, under the related list's update access. Selecting a post on a user's edit page therefore updates that post's foreign key whether the field is left at its default display or demoted to `ui.itemView.displayMode: 'picker'`.
2001
+
2002
+ The edge writes commit before the record's own update and are not rolled back, so a record update that then fails reports the save as partial instead of as a plain failure.
2003
+
2004
+ Ids now cross the wire through one contract-driven coercion (ADR-0048), which reads each list's id type from the contract:
2005
+
2006
+ ```typescript
2007
+ import { parseListId } from '@opensaas/stack-core'
2008
+
2009
+ parseListId(config, 'Post', '12') // { ok: true, value: 12 } on an int-keyed list
2010
+ parseListId(config, 'Post', 'not-an-int') // { ok: false }
2011
+ parseListId(config, 'Post', '3000000000') // { ok: false } — outside the int4 column
2012
+ ```
2013
+
2014
+ Admin routing parses the URL's item id through it and **404s a malformed one**, so `/admin/post/not-an-int` on an integer-keyed list is a not-found rather than a query built on a `NaN`. The server actions parse their ids the same way.
2015
+
2016
+ Nav counts are read through the secured `aggregate` reducer, so a badge again reports the rows the session may see.
2017
+
2018
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Drive better-auth through a stack-authored Auth adapter over the Unsafe surface
2019
+
2020
+ `@opensaas/stack-auth` no longer hands better-auth `prismaAdapter`. It builds its
2021
+ own adapter with better-auth's `createAdapterFactory`, running on the Unsafe
2022
+ surface a Prisma 8 context carries: eight methods on the ORM lane, and
2023
+ `incrementOne` plus an unconditional `deleteMany` as single typed-SQL statements
2024
+ through the surface's own executors. `consumeOne` is `where(…).delete()` inside one
2025
+ transaction on the surface's transaction-bound lanes, answering the row only
2026
+ when the delete itself claimed it — the at-most-one guarantee better-auth asks
2027
+ for, held against concurrent replays of the same token. See ADR-0060.
2028
+
2029
+ `createAuth(config, rawOpensaasContext)` keeps its signature; nothing in an
2030
+ app's `lib/auth.ts` changes. Two new keys are refused at config time, alongside
2031
+ the existing `betterAuthOptions.database`:
2032
+
2033
+ ```typescript
2034
+ authPlugin({
2035
+ betterAuthOptions: {
2036
+ // both throw: the database mints auth ids, and the adapter implements no joins
2037
+ advanced: { database: { generateId: () => id, joins: true } },
2038
+ },
2039
+ })
2040
+ ```
2041
+
2042
+ `authPlugin` now pins `db.idField: 'uuid7'` on every list it injects, so auth
2043
+ ids are minted by the database like every other list's.
2044
+
2045
+ `@opensaas/stack-core` gains the engine-owned LIKE-pattern escaping the adapter
2046
+ lowers `contains` / `starts_with` / `ends_with` and insensitive `eq` through
2047
+ (`escapeLikeLiteral` and the four pattern builders, on
2048
+ `@opensaas/stack-core/internal`) — one escaper, shared with the secured
2049
+ surface's Where vocabulary.
2050
+
2051
+ Known limits of the adapter, all stated: no joins, no `createSchema` (so
2052
+ better-auth's CLI is unsupported against it), no better-auth transaction option
2053
+ yet, no issuer-scoped account uniqueness until the schema gap in [#986](https://github.com/OpenSaasAU/stack/issues/986) closes,
2054
+ and errors arrive as the driver's own rather than normalised.
2055
+
2056
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - The generated context constructs the Prisma 8 client from `contract.json`
2057
+
2058
+ Core gains `@opensaas/stack-core/client`, whose `resolveRuntimeConnection()` chooses how the
2059
+ runtime binds its connection, and the generated `.opensaas/context.ts` builds its client from it
2060
+ once per process — with the stack-owned origin tripwire in `middleware` and each declared pack's
2061
+ runtime façade in `extensions`.
2062
+
2063
+ ```typescript
2064
+ import { resolveRuntimeConnection } from '@opensaas/stack-core/client'
2065
+
2066
+ postgres<Contract>({
2067
+ contractJson,
2068
+ middleware: [originTripwire],
2069
+ ...resolveRuntimeConnection(config.db.client),
2070
+ })
2071
+ ```
2072
+
2073
+ Three branches, in order:
2074
+
2075
+ - `db.client.pg` — your own pool. The factory is called here and nowhere else, once, after the
2076
+ config promise resolves, so loading the config (the CLI's `generate`, tooling, a type check)
2077
+ never opens a connection.
2078
+ - A dev database (`opensaas dev`) — a single-connection pool with `verifyMarker: false`, both
2079
+ required by the socket-multiplexed dev database and applied on its provenance only.
2080
+ - `DATABASE_URL` — the connection string and Prisma's defaults, plus `db.client.poolOptions`.
2081
+
2082
+ With neither a connection variable nor a running dev database, the first use throws
2083
+ `DatabaseUrlUnresolvedError`, naming both remedies. That failure is not cached: a process that
2084
+ starts before its database does drops the memo and builds a client on the next call, so the dev
2085
+ server booting ahead of `opensaas dev` recovers on its own rather than serving a stale error for
2086
+ the rest of its life.
2087
+
2088
+ An explicit `db.client.pg` still wins over a running dev database, but now says so — binding your
2089
+ own pool there loses the single connection and `verifyMarker: false` that database requires, and
2090
+ `resolveRuntimeConnection` warns rather than rebinding silently.
2091
+
2092
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Drop transaction options and make database errors stack-owned
2093
+
2094
+ `context.transaction(fn)` takes no options and runs at the connection's default isolation level — Read Committed on PostgreSQL. `isolationLevel`, `maxWait`, `timeout`, the `TransactionIsolationLevel` union, `TransactionOptions` and `TransactionOptionsUnsupportedError` are deleted, so asking for an isolation level is a compile error at the call site rather than a value the client silently downgrades.
2095
+
2096
+ Every engine terminal now raises a stack-owned error in place of the driver's own, each with an `is*` predicate:
2097
+
2098
+ ```typescript
2099
+ import { isUniqueConstraintViolation, isSerializationFailure } from '@opensaas/stack-core'
2100
+
2101
+ try {
2102
+ await context.db.User.create({ data: { email } })
2103
+ } catch (error) {
2104
+ if (isUniqueConstraintViolation(error)) {
2105
+ // { email: 'This email is already in use' }
2106
+ return { fieldErrors: error.fieldErrors }
2107
+ }
2108
+ if (isSerializationFailure(error)) return retry()
2109
+ throw error
2110
+ }
2111
+ ```
2112
+
2113
+ A unique violation resolves through the constraint map the generator emits, so it names the OpenSaas **fields** the violated constraint covers. A constraint managed by hand in the database is not in that map and falls through to the generic `'A record with this value already exists'` with no fields — the map's limit, stated rather than hidden.
2114
+
2115
+ Errors raised at `COMMIT` are normalised the same way, at the transaction owner's settle and before the deferred-hook flush, so a `DEFERRABLE INITIALLY DEFERRED` constraint never escapes as a raw driver error and ADR-0028's precedence rule (transaction errors ahead of hook errors) keeps operating on a normalised value.
2116
+
2117
+ A `DatabaseError`'s message is always stack-authored; the driver's own text — which names columns, tables and constraint names — is on `cause`, for a server-side log rather than a browser. A failure the classification does not recognise carries `'The database refused this operation'`.
2118
+
2119
+ `context.serverAction` — the surface the admin UI drives — logs that `cause` to the server console before returning the stack-authored message to the client, so a database failure stays diagnosable to the operator without the driver's text ever reaching the browser.
2120
+
2121
+ An application's own error wins over the stack's. Catching a stack error and rethrowing your own with `{ cause }` reaches the caller as your error, not as the `UniqueConstraintViolation` underneath it.
2122
+
2123
+ `context.unsafe` is deliberately excluded and still rejects with the driver's own error, consistent with its bypassing everything else.
2124
+
2125
+ `DatabaseError.code` is removed along with every `P####` discriminant, the English-prose regex and the identifier stripping in `prisma-errors.ts`; `uniqueConstraintOf` and `UniqueConstraintInfo` are gone with them. Prisma 8 raises no such codes, so each was a string compare that would have failed silently. See ADR-0042.
2126
+
2127
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - `createMcpHandlers` takes the app's own context factory
2128
+
2129
+ The MCP route handler typed its `getContext` option as returning the engine's
2130
+ `AccessContext`, which the generated `getContext()` is deliberately not
2131
+ assignable to — the app-facing `Context` carries the secured `db` and none of
2132
+ the engine's plumbing. Wiring the documented route up therefore did not compile.
2133
+ It now takes `AnyStackContext` and narrows once with `engineContextOf`, the same
2134
+ boundary `AdminUI` and `createAuth` already sit on.
2135
+
2136
+ The documented wiring is unchanged, and now type-checks:
2137
+
2138
+ ```typescript
2139
+ // app/api/mcp/[[...transport]]/route.ts
2140
+ import { createMcpHandlers } from '@opensaas/stack-core/mcp'
2141
+ import { createBetterAuthMcpAdapter } from '@opensaas/stack-auth/mcp'
2142
+ import config from '@/opensaas.config'
2143
+ import { auth } from '@/lib/auth'
2144
+ import { getContext } from '@/.opensaas/context'
2145
+
2146
+ const { GET, POST, DELETE } = createMcpHandlers({
2147
+ config: await config,
2148
+ getSession: createBetterAuthMcpAdapter(auth),
2149
+ getContext,
2150
+ })
2151
+
2152
+ export { GET, POST, DELETE }
2153
+ ```
2154
+
2155
+ A caller already passing an engine-face context keeps working — `engineContextOf`
2156
+ returns such a value unchanged.
2157
+
2158
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Core derives the Prisma 8 contract from the config (ADR-0057)
2159
+
2160
+ `deriveContract(config)` turns a resolved config into plain contract data — models with columns from each field builder's structured descriptor, ids by `db.idField` strategy (a singleton derives an integer id defaulting to 1), `temporal` auto-timestamps, `db.indexes` resolved to columns with named entries adopted as exact constraint names, the relation graph with foreign-key ownership, the one-to-one pair (owning column + foreign key + unique constraint + `belongsTo`; inverse `hasOne`), synthetic back-relations for list-only refs, native enums, the namespaces beyond `public` (`db.schemas` unioned with every list's `db.schema`) and the declared extension packs. `assertRelationGraphAgrees(derived, emitted)` checks an emitted contract against that graph and throws `RelationGraphDivergenceError` naming the first divergence.
2161
+
2162
+ `@opensaas/stack-core/contract` adds `buildPrismaContract(data, { packs })`, which feeds the data into Prisma's contract builder in-process, and `toEmittedContract(contract)` for its JSON form:
2163
+
2164
+ ```typescript
2165
+ import { deriveContract, assertRelationGraphAgrees } from '@opensaas/stack-core'
2166
+ import { buildPrismaContract, toEmittedContract } from '@opensaas/stack-core/contract'
2167
+ import pgvector from '@prisma/orm-extension-pgvector/pack'
2168
+
2169
+ const data = deriveContract(config)
2170
+ const contract = buildPrismaContract(data, { packs: { pgvector } })
2171
+ assertRelationGraphAgrees(data, toEmittedContract(contract))
2172
+ ```
2173
+
2174
+ `db.nativeType` is honoured for every Postgres constructor the contract can express — `Text`, `VarChar(n)`, `Char(n)`, `Uuid`, `Integer`, `SmallInt`, `BigInt`, `Decimal(p, s)`, `DoublePrecision`, `Real`, `Boolean`, `Date`, `Timestamp(p)`, `Timestamptz(p)`, `Time(p)`, `Json`, `JsonB`, `ByteA` — each lowering to its own column (`Real` is `float4`, `Json` is `json` as distinct from the `jsonb` a `json()` field defaults to, and a precision reaches the DDL). A spelling outside that list, a wrong argument count (`VarChar` with no length) or a precision outside 0–6 is a generate-time error naming the list and field; nothing is silently aliased or dropped. `decimal()` now forwards `db.nativeType` like every other scalar builder.
2175
+
2176
+ A single-field unique `db.indexes` entry on the owning column of a one-to-one names the unique constraint that column already carries instead of being refused, and a relationship's default foreign-key index yields to a single-field entry the same way; a spelled-out `isIndexed` on the field remains a genuine duplicate.
2177
+
2178
+ New generate-time refusals, each naming the list, the entry and the fix: `undeclared-extension-pack` (a stored field typed by a pack `db.extensions` does not declare), `field-descriptor-error` (a field whose `getContractField` throws, such as a default the contract cannot carry), `reserved-field-name` (a field named `id`), `foreign-key-column-collision` (a field whose column is the `<field>Id` another relationship on the list owns), `synthetic-relation-collision` (a field named `from_<List>_<field>` where a list-only ref synthesises that back-relation) and `inverse-mismatch` (a bidirectional `ref` whose other end does not ref back). `validateExtensionPacks` and `validateFieldNames` are exported and run as part of `validateDatabaseConfig`; `validateRelations` picks up `inverse-mismatch`.
2179
+
2180
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Add `@opensaas/stack-core/testing`: a real, fully secured context over an in-process Postgres
2181
+
2182
+ `createTestDatabase(config)` derives the contract from a config, seeds every declared
2183
+ extension pack's contract space, applies the schema once through the control client's
2184
+ `dbUpdate`, and binds a single-connection Prisma 8 client with the stack's own
2185
+ `originTripwire` installed. `createTestContext(config, session)` is the single-call form.
2186
+ No test fakes the secured surface.
2187
+
2188
+ ```typescript
2189
+ import { createTestDatabase, createPlanRecorder } from '@opensaas/stack-core/testing'
2190
+
2191
+ const recorder = createPlanRecorder()
2192
+ let db: TestDatabase
2193
+
2194
+ beforeAll(async () => {
2195
+ db = await createTestDatabase(config, { middleware: [recorder.middleware] })
2196
+ }, 60_000)
2197
+ afterAll(async () => await db.close())
2198
+ beforeEach(async () => await db.truncate())
2199
+
2200
+ test('the engine scopes the read', async () => {
2201
+ const context = db.context({ userId: 'user-1' })
2202
+ // …
2203
+ expect(recorder.plans.map((plan) => plan.origin)).toEqual(['engine'])
2204
+ })
2205
+ ```
2206
+
2207
+ The map the engine reaches models through is checked as the harness builds it: a client
2208
+ exposing no collection for a model the contract declares throws
2209
+ `OrmCollectionMissingError`, naming the model, the namespace and the keys actually
2210
+ present, rather than building a context that would refuse every operation later.
2211
+
2212
+ Set `DATABASE_URL` to a Postgres server and the identical suite runs there, each file in a
2213
+ database of its own, named `opensaas_test_<YYYYMMDDHHMMSS>_<uuid>` after the exported
2214
+ `ESCAPE_DATABASE_PREFIX` so a run killed before `close()` leaves orphans that are
2215
+ identifiable by age and sweepable; set to anything else the variable is refused by name
2216
+ rather than dialled. `readDatabaseEscape()` lets a test whose guarantee PGlite cannot
2217
+ exercise skip visibly when the escape is unset.
2218
+
2219
+ PGlite, `@electric-sql/pglite-socket`, `@electric-sql/pglite-pgvector` and
2220
+ `@prisma/orm-toolchain` are optional peer dependencies, and `pg` — a real dependency of
2221
+ core, for `@opensaas/stack-core/client` — is imported lazily here too. Every one of them
2222
+ is loaded on demand by this subpath only, so a production install carries no WASM
2223
+ Postgres.
2224
+
2225
+ - [#1485](https://github.com/OpenSaasAU/stack/pull/1485) [`6cfe96c`](https://github.com/OpenSaasAU/stack/commit/6cfe96c248889a268b9505178db1da9b177dafe6) Thanks [@borisno2](https://github.com/borisno2)! - Rewrite public API docblocks (and the `opensaas generate` CLI description) that still described the generator's output in Prisma-schema-language terms (`@@map`/`@@schema`/`@@unique`/`@@index`/`multiSchema`/`@default(...)`/`@db.<type>`) — the Prisma 8 pipeline emits a TypeScript contract, not a `.prisma` schema (ADR-0040), and no such attributes are ever produced. Affected options include `ListConfig.db.map`/`db.schema`/`db.indexes`/`db.nativeType`, `SelectField.db.type`/`db.enumName`/`db.isNullable`, `RelationshipField.isIndexed`/`db.isNullable`, `DatabaseConfig.schemas`/`db.timestamps`, `OpenSaasConfig.output`, `Plugin.beforeGenerate`, and the equivalent auth-plugin model config (`AuthModelConfig.tableName`/`fields`/`schema`, `AuthConfig.schema`/`rateLimit`/`betterAuthOptions`). Docs now describe what the contract actually carries: a model's `table`/`namespace`, a column's `map`/type/nullability, a declared `enums` entry, and `unique`/`index` constraints.
2226
+
2227
+ - [#1495](https://github.com/OpenSaasAU/stack/pull/1495) [`cfb397a`](https://github.com/OpenSaasAU/stack/commit/cfb397ad72f1b27c854b0a765ebb249fbc7dab3e) Thanks [@borisno2](https://github.com/borisno2)! - `getContext`, `withSession` and `createTestContext` now refuse a session that holds `undefined` for one of its own keys
2228
+
2229
+ `session ?? null` only treats `null`/`undefined` themselves as anonymous — a non-null object is signed in even when every property on it is `undefined`. `getContext({ userId })` from an unguarded `userId?: string` builds exactly that object, and an access rule written as `session === null ? ... : true` took its signed-in branch for an anonymous caller ([#1397](https://github.com/OpenSaasAU/stack/issues/1397), the defect behind [#1387](https://github.com/OpenSaasAU/stack/issues/1387)).
2230
+
2231
+ All three entry points share one low-level `getContext`, so the one guard there closes this for each of them:
2232
+
2233
+ ```typescript
2234
+ import { getContext, InvalidSessionError } from '@opensaas/stack-core'
2235
+
2236
+ try {
2237
+ await getContext({ userId: undefined })
2238
+ } catch (error) {
2239
+ error instanceof InvalidSessionError // true
2240
+ }
2241
+ ```
2242
+
2243
+ Build the session from an optional identifier by omitting the key rather than setting it to `undefined`:
2244
+
2245
+ ```typescript
2246
+ const context = userId ? await getContext({ userId }) : await getContext()
2247
+ ```
2248
+
2249
+ The MCP runtime's own session-to-context translation is hardened the same way: a custom MCP session field resolved to `undefined` is dropped before it reaches `getContext`, rather than tripping the new refusal for a session that is genuinely signed in (`userId` is required and untouched, so the refusal still catches it if that one is ever `undefined`).
2250
+
2251
+ Note this doesn't close every way an object can reach `getContext` looking signed in — wrapping an already-resolved session under a key, `getContext({ session })`, still reads as signed in when that wrapped value is `null` rather than `undefined`, because `null` is a value, not a missing one. Don't wrap the session at all: branch on it before calling `getContext`, as above.
2252
+
2253
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - A Test context can exercise `file()` and `image()` fields
2254
+
2255
+ `createTestContext` built its context with no storage surface, so any write to a storage-backed field threw `No storage providers configured` — the Test context could not cover the storage package at all. It now takes one:
2256
+
2257
+ ```ts
2258
+ import { createTestContext } from '@opensaas/stack-core/testing'
2259
+ import { createStorageUtils } from '@opensaas/stack-storage/runtime'
2260
+
2261
+ // `config` is a promise whenever the config carries plugins, so resolve it
2262
+ // once and hand the same value to both.
2263
+ const resolved = await config
2264
+
2265
+ const harness = await createTestContext(resolved, null, {
2266
+ storage: createStorageUtils(resolved),
2267
+ })
2268
+
2269
+ const user = await harness.context.db.User.create({
2270
+ data: { name: 'Ada', avatar: new File([bytes], 'avatar.png', { type: 'image/png' }) },
2271
+ })
2272
+ ```
2273
+
2274
+ `createStorageUtils(config)` is new in `@opensaas/stack-storage/runtime` and is the supported way to build that surface. `StorageUtils` types its option and metadata arguments as `unknown`, because core is this package's dependency and cannot name its types; the factory is the one place that re-narrows them, so a consumer building a context by hand no longer writes that conversion itself.
2275
+
2276
+ `deleteImage` **refuses** a value that is not `ImageMetadata`, naming the keys it received, rather than resolving as a silent no-op. The generated context always calls `deleteImage`, so a harness that swallowed an unrecognised shape would be quieter than the application it stands in for — the one failure mode a test surface must not have.
2277
+
2278
+ Omitting the option is unchanged: a config with no storage still throws on a storage-backed write, exactly as an application with none does.
2279
+
2280
+ Two type predicates now check every member their consumers read, rather than a subset the compiler then takes on trust:
2281
+
2282
+ - `isImageMetadata` checked 2 of `ImageMetadata`'s 9 required members and omitted `storageProvider`, which `deleteImage` dereferences first — a bogus value surfaced as `Storage provider 'undefined' not found in config` from inside the provider registry. It now checks all nine, plus the shape of the optional `metadata` and `transformations`.
2283
+ - `isFileLike` narrows to `File` but checked only `arrayBuffer`, while the upload path also reads `name`, `type` and `size` — so a value carrying only `arrayBuffer` was stored with an `originalFilename` of `undefined`. It now checks all four.
2284
+
2285
+ - [#1497](https://github.com/OpenSaasAU/stack/pull/1497) [`dbb52c7`](https://github.com/OpenSaasAU/stack/commit/dbb52c79021880302e361d13570765d2fee4e4af) Thanks [@borisno2](https://github.com/borisno2)! - `createTestContext` and `createTestDatabase` (`@opensaas/stack-core/testing`) are now generic over the context they hand back. Name your app's own generated `Context` to get the same typed rows, `where`, `select` and `include` a generated `getContext()` gives, over the harness's own isolated database, instead of the engine's untyped `StackContext<AccessControlledDB>`:
2286
+
2287
+ ```typescript
2288
+ import { createTestContext } from '@opensaas/stack-core/testing'
2289
+ import type { Context } from '../.opensaas/types.js'
2290
+
2291
+ const harness = await createTestContext<Context>(config, { userId: 'user-1' })
2292
+ const post = await harness.context.db.Post.where({ id: { equals: postId } }).first()
2293
+ post?.title // typed, not `unknown`
2294
+ ```
2295
+
2296
+ Omitting the type parameter keeps the previous, untyped behavior — no existing call site needs to change.
2297
+
2298
+ - [#1793](https://github.com/OpenSaasAU/stack/pull/1793) [`4f65926`](https://github.com/OpenSaasAU/stack/commit/4f65926af88e62a053ac1c795e1b9e214744267b) Thanks [@borisno2](https://github.com/borisno2)! - A relationship edge a list or field `resolveInput` hook introduces is now trusted: the reachability query runs over the edges the caller supplied in `inputData`, so a hook can assign a relationship to a row the session cannot query without `sudo()`. A caller-supplied unreachable `connect` still returns `null`, even if a hook overwrites it (ADR-0075).
2299
+
2300
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Put `aggregate`, `nearest`, `combine`, `count`, `distinct`, `distinctOn`, `cursor` and `offset` on the typed read surface
2301
+
2302
+ These shipped on the engine's deliberately-untyped composed read alone, so a generated project could not call any of them — `context.db.Post.aggregate(…)` was `TS2339`, and the examples the previous two changesets published did not compile. They are now on `ListQuery` / `ListRefinement` with contract-derived types, the same way `select` and `include` already are.
2303
+
2304
+ ```typescript
2305
+ const { total } = await context.db.Post.where({ published: { equals: true } }).aggregate(
2306
+ (aggregate) => ({ total: aggregate.count() }),
2307
+ )
2308
+
2309
+ const users = await context.db.User.include('posts', (posts) =>
2310
+ posts.combine({
2311
+ published: posts.where({ published: { equals: true } }).count(),
2312
+ total: posts.count(),
2313
+ }),
2314
+ ).all()
2315
+ // each row: { …user, posts: { published: number; total: number } }
2316
+
2317
+ const hits = await context.db.Article.where({ published: true }).nearest(
2318
+ 'embedding',
2319
+ queryVector,
2320
+ {
2321
+ limit: 5,
2322
+ minScore: 0.8,
2323
+ },
2324
+ )
2325
+ for (const { item, score } of hits) console.log(item.title, score)
2326
+ ```
2327
+
2328
+ `nearest()` reads as `{ item, score }` (`NearestMatch`), with `item` honouring the read's own `select()` and includes, and its `field` names one of the list's vector columns — a list that declares none has no callable `nearest`. `distinct`, `distinctOn` and `cursor` name this list's stored columns, so a computed field or a misspelling is a compile error rather than a runtime refusal. A relation an include reduced reads as its count — `number` for `count()`, one number per key for `combine()` — in place of the rows; `.count()` and `.combine()` appear on a to-many refinement that has composed nothing but `where()`, so `ReducedToOneIncludeError` and `UnreducibleRefinementError` are compile errors too. `Aggregations` and `CountReduction` are exported, so a builder factored out of the call site can be named.
2329
+
2330
+ A singleton list carries `get` and the CRUD delegate and no composed read, which is what its runtime has always done — `context.db.Settings.where/all/first/aggregate/nearest/offset/distinct/distinctOn/cursor` type-checked and threw `TypeError` before.
2331
+
2332
+ `offset(count)` joins the top-level read, where it previously existed on an include refinement alone. It pages inside the Access Filter, and `all()` and `first()` both honour it — `first()` has no offset of its own, so `.orderBy(…).offset(10).first()` is the eleventh row. `aggregate()` and `nearest()` refuse a composed `offset` (and `aggregate()` a composed `limit`) rather than answer a different question in silence, the way both already refuse `distinct` and `cursor`; the refusal runs after the access check, so a denied caller still gets `0` or `[]`.
2333
+
2334
+ Each terminal now declares what it does with every member of a resolved plan, so a member it neither applies nor refuses is a compile error rather than a silent drop.
2335
+
2336
+ `groupBy`, the `*All` family, `*AndCount` and `upsert` remain absent: a method appears only where the engine knows how to scope it.
2337
+
2338
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Adding an edge across a junction is a create of the junction row, under that list's own create access
2339
+
2340
+ A many-to-many is an explicit junction list (ADR-0048), so an edge is one of its rows and adding one is a create — never a nested write on either parent. `context.serverAction({ listKey, action: 'addRelated', field, parentId, targetId })` names the **parent** list and its to-many field; the junction list, its back-reference and its far-endpoint field are resolved from the config on the server, so a caller can neither name a junction list of its own choosing nor set a column of the edge row beyond the two endpoints.
2341
+
2342
+ ```ts
2343
+ // Post.tags: relationship({ ref: 'PostTag.post', many: true })
2344
+ // PostTag : { post: relationship({ ref: 'Post.tags' }), tag: relationship({ ref: 'Tag.posts' }) }
2345
+ await context.serverAction({
2346
+ listKey: 'Post',
2347
+ action: 'addRelated',
2348
+ field: 'tags',
2349
+ parentId: post.id,
2350
+ targetId: tag.id,
2351
+ })
2352
+ // → { added: true, id } — a PostTag row, gated on PostTag's own create access
2353
+ ```
2354
+
2355
+ The create is evaluated against the junction list, so a caller denied `create` there cannot add the edge and the denial is the usual silent one: `{ added: false }` with a generic reason, nothing written, nothing raised. Both endpoints go through `connect`, so an endpoint the caller cannot read is indistinguishable from one that does not exist, and both are indistinguishable from that operation-level denial — one generic reason covers all three. A **field-level** denial on an endpoint stays loud and names the field, as it does for every create in the framework ([#568](https://github.com/OpenSaasAU/stack/issues/568)); this does not change that.
2356
+
2357
+ `resolveJunctionEdge(config, parentListKey, fieldName)` is exported for callers that need the same answer. It returns `null` — leaving the ordinary to-many treatment in place — for a list-only `ref`, a junction with a third foreign key or none, and a junction carrying any stored field of its own. That last rule is what keeps an ordinary two-parent child row (`Comment { body, article, author }`) from being read as an edge: it owns two foreign keys like a junction does, and no requiredness flag separates the two, so the column it carries is the only evidence. The cost is that a junction with a genuinely optional annotation column keeps its ordinary treatment too.
2358
+
2359
+ In the admin UI, a to-many section that is such an edge gains a **"Link"** control beside "+ Add", offered only when the junction list's own `create` access is not statically denied. The item form's to-many picker stays read-only — an edge can never ride in the parent's write payload — but its stated reason now points at that table rather than at another list's edit page. The item view renders such a field as the table itself rather than as a field of the details card, so the reason is what the create page and the standalone forms show; a field demoted to `ui.itemView.displayMode: 'picker'` has no table anywhere and keeps the original reason.
2360
+
2361
+ ### Patch Changes
2362
+
2363
+ - [#1731](https://github.com/OpenSaasAU/stack/pull/1731) [`2daa64f`](https://github.com/OpenSaasAU/stack/commit/2daa64f5722b6e85653a0cf834353db070541ab3) Thanks [@dependabot](https://github.com/apps/dependabot)! - Support Prisma 8.0.0-rc.13: read mutation-default refs by `entry`/`field`, and pass a `bigInt` field's literal default to the contract as a `bigint`.
2364
+
2365
+ - [#1782](https://github.com/OpenSaasAU/stack/pull/1782) [`df052c2`](https://github.com/OpenSaasAU/stack/commit/df052c26942001262ad90670ec60139b2fbc9689) Thanks [@dependabot](https://github.com/apps/dependabot)! - Upgrade to Prisma ORM 8.0.0-rc.17 (CLI rc.22); `opensaas db update --plan <id>` now consents with `--delete`/`--allow` per subject instead of `--confirm`.
2366
+ Run Prisma's `data-type-in-contract` upgrade script and `pnpm generate` to re-emit committed contracts.
2367
+
2368
+ - [#1856](https://github.com/OpenSaasAU/stack/pull/1856) [`05fc094`](https://github.com/OpenSaasAU/stack/commit/05fc0949071feb6c69cb735a82494421e1c7c189) Thanks [@borisno2](https://github.com/borisno2)! - Clamp admin `?pageSize=` and `relationshipOptions` `take` to 200 (non-integer `take` throws `ValidationError`); URL-encode the standalone `SearchBar` term.
2369
+
2370
+ - [#1935](https://github.com/OpenSaasAU/stack/pull/1935) [`33b9c7a`](https://github.com/OpenSaasAU/stack/commit/33b9c7a103e8716fb3fb26745b79a3ff77bd83af) Thanks [@borisno2](https://github.com/borisno2)! - Docs: point the `defaultValue` TSDoc at `prisma db update --dry-run`, since Prisma 8 has no `migrate diff`.
2371
+
2372
+ - [#1767](https://github.com/OpenSaasAU/stack/pull/1767) [`dcf3a89`](https://github.com/OpenSaasAU/stack/commit/dcf3a891161bedcab679f79f0332176ab4bafe67) Thanks [@borisno2](https://github.com/borisno2)! - Field-level `create`/`update` access now gates the keys the caller supplied, so a list's own `resolveInput` can set a field callers may not write.
2373
+
2374
+ - [#2020](https://github.com/OpenSaasAU/stack/pull/2020) [`49e0bdc`](https://github.com/OpenSaasAU/stack/commit/49e0bdc9dc30158253c5efca7eaee55a0e91db93) Thanks [@borisno2](https://github.com/borisno2)! - Refuse a hook-stripped, field-access-denied foreign key written as `authorId`, matching the `author: { connect }` spelling.
2375
+
2376
+ - [#1765](https://github.com/OpenSaasAU/stack/pull/1765) [`ef3060c`](https://github.com/OpenSaasAU/stack/commit/ef3060c89a6a122bade9a6a7bb3492c4877e6ab5) Thanks [@borisno2](https://github.com/borisno2)! - A caller's own `where()` on a to-one include no longer nulls the parent's foreign key. The column is narrowed on access grounds alone.
2377
+
2378
+ - [#1905](https://github.com/OpenSaasAU/stack/pull/1905) [`f55128a`](https://github.com/OpenSaasAU/stack/commit/f55128ade8aff8242b4cc060a354bc970742ce1b) Thanks [@borisno2](https://github.com/borisno2)! - Fix `NOT: [a, b]` in the Where vocabulary lowering to `NOT (a AND b)`, which widened access filters written the Prisma/Keystone way. It now excludes every branch, and `NOT: []` adds no constraint.
2379
+
2380
+ - [#2045](https://github.com/OpenSaasAU/stack/pull/2045) [`5b109f1`](https://github.com/OpenSaasAU/stack/commit/5b109f112ba7259ebc42ac4ac2598ff349e7266b) Thanks [@borisno2](https://github.com/borisno2)! - Fix concurrent first `get()` on an empty singleton throwing `UniqueConstraintViolation`; the losing caller now reads the winner's row.
2381
+
2382
+ - [#1754](https://github.com/OpenSaasAU/stack/pull/1754) [`0ef9495`](https://github.com/OpenSaasAU/stack/commit/0ef9495d0f7f53c0a84ac6e5fd0fe3f8da183e4b) Thanks [@borisno2](https://github.com/borisno2)! - Declared `createdAt`/`updatedAt` fields are now ordinary fields (access, hooks, defaults apply and writes persist); `id` and auto-timestamps in a write payload now throw instead of being silently dropped.
2383
+
2384
+ - [#1937](https://github.com/OpenSaasAU/stack/pull/1937) [`b3b9a36`](https://github.com/OpenSaasAU/stack/commit/b3b9a3695920385a044a970d6abab68b7df39f12) Thanks [@borisno2](https://github.com/borisno2)! - Clone object/array field `defaultValue`s when applying them so in-place mutation by a hook no longer leaks into later writes.
2385
+
2386
+ - [#2046](https://github.com/OpenSaasAU/stack/pull/2046) [`fbd9bd5`](https://github.com/OpenSaasAU/stack/commit/fbd9bd5675f1958507da0df01f697845a9332f0c) Thanks [@borisno2](https://github.com/borisno2)! - Fix `combine()` rows branches returning raw foreign keys of rows the session cannot read.
2387
+
2388
+ - [#1780](https://github.com/OpenSaasAU/stack/pull/1780) [`a0d613f`](https://github.com/OpenSaasAU/stack/commit/a0d613fe344e7cc6eca8d1b35171bbbfc0ae2a5b) Thanks [@borisno2](https://github.com/borisno2)! - Document why `createdAt` keeps its database `now()` default, and pin that no execution default is emitted for it.
2389
+
2390
+ - [#1845](https://github.com/OpenSaasAU/stack/pull/1845) [`b7aee49`](https://github.com/OpenSaasAU/stack/commit/b7aee491198c6dc7216e7323705ff36e1646e5c5) Thanks [@borisno2](https://github.com/borisno2)! - Fix a read-gate bypass: a caller-shaped `include` (`where`/`limit`/`offset`/`select`) on a declared dependency no longer changes what field `read` rules and `resolveOutput` hooks see.
2391
+
2392
+ - [#1692](https://github.com/OpenSaasAU/stack/pull/1692) [`274b0a5`](https://github.com/OpenSaasAU/stack/commit/274b0a57b3e2d307a9d5563b08f8a9d60b3ff7b4) Thanks [@borisno2](https://github.com/borisno2)! - Fix `delete` returning the raw deleted row: read-denied fields and password hashes are now filtered like create/update results.
2393
+
2394
+ - [#1728](https://github.com/OpenSaasAU/stack/pull/1728) [`6f1a94c`](https://github.com/OpenSaasAU/stack/commit/6f1a94c005b231ea78be8bb9ce0163937bf37fa3) Thanks [@borisno2](https://github.com/borisno2)! - Correct agent-facing docs on `needs` relation visibility, `createAuth`'s required context and `Session` typing.
2395
+
2396
+ - [#1548](https://github.com/OpenSaasAU/stack/pull/1548) [`5334468`](https://github.com/OpenSaasAU/stack/commit/5334468181b2716897c0fce29965fc590b1dc239) Thanks [@borisno2](https://github.com/borisno2)! - Fix the generated context's client singleton so "once per process" holds in every environment, not only outside production: two bundler-duplicated copies of `.opensaas/context.ts` now share one client through a process-wide registry instead of each opening its own pool (ADR-0070).
2397
+
2398
+ - [#1859](https://github.com/OpenSaasAU/stack/pull/1859) [`be9466e`](https://github.com/OpenSaasAU/stack/commit/be9466e947d04a8091030ffef2588ba5bec431b0) Thanks [@borisno2](https://github.com/borisno2)! - A list `resolveInput` that mutates `resolvedData` in place no longer mutates the caller's `data` or has its hook-set keys gated as caller input.
2399
+
2400
+ - [#1906](https://github.com/OpenSaasAU/stack/pull/1906) [`efad224`](https://github.com/OpenSaasAU/stack/commit/efad22409032faab300a566f310d4384c4f78aed) Thanks [@borisno2](https://github.com/borisno2)! - Fix root `update`/`delete` re-resolving the target under the row lock with the outer context, which deadlocked access rules that read `context.db` on a single-connection database.
2401
+
2402
+ - [#1699](https://github.com/OpenSaasAU/stack/pull/1699) [`28795bb`](https://github.com/OpenSaasAU/stack/commit/28795bb0b39c4a6f73c860d16c1b5240aa238f8f) Thanks [@borisno2](https://github.com/borisno2)! - Scope a `where` on a to-one foreign-key column by the related list's `query` access, and refuse `orderBy`/`distinct`/cursor on it when that access is not open, so a hidden id can no longer be probed.
2403
+
2404
+ - [#1698](https://github.com/OpenSaasAU/stack/pull/1698) [`7f287d4`](https://github.com/OpenSaasAU/stack/commit/7f287d48579a815c67441c8336b1372d9f41c61e) Thanks [@borisno2](https://github.com/borisno2)! - Fix foreign-key ids leaking when a relationship `read` rule is row-dependent: `select('<field>Id')` now reads the full row, and a bare read assembles multi-column fields before the rule runs.
2405
+
2406
+ - [#1899](https://github.com/OpenSaasAU/stack/pull/1899) [`2464809`](https://github.com/OpenSaasAU/stack/commit/24648098371f94ede164021bf8143f4e20102a8b) Thanks [@borisno2](https://github.com/borisno2)! - Fix `forUpdate()` returning stale or no-longer-accessible rows: locked rows are now re-read under the Access Filter after the lock is taken.
2407
+
2408
+ - [#1672](https://github.com/OpenSaasAU/stack/pull/1672) [`00c3760`](https://github.com/OpenSaasAU/stack/commit/00c3760449f890f5d365798f5b3b3e1367333762) Thanks [@borisno2](https://github.com/borisno2)! - Fix `context.db.<List>.create()` throwing unconditionally for a field carrying both a `defaultValue` and an unconditional field-level `create` deny (`access: { create: () => false }`) — the value `applyCreateDefaults` fills in for an omitted field was being rejected by the deny meant for the caller, not the field's own default. Adds an opt-in `FieldAccess.allowCreateDefault` flag: when set, a field's own declared default is exempted from its `create` deny for a session that omitted the field, while an explicit attempt to write the field is still refused. Off by default, so a session-dependent `create` rule (denies one session, allows another) still blocks the whole create for a denied session exactly as before.
2409
+
2410
+ - [#1576](https://github.com/OpenSaasAU/stack/pull/1576) [`17bb5d5`](https://github.com/OpenSaasAU/stack/commit/17bb5d5a3afa78007afdd80eaa5a09f27a408890) Thanks [@borisno2](https://github.com/borisno2)! - Fix a singleton's `get({ include })` silently including a relation whole when given a nested shape (e.g. `{ take: 5 }`) instead of a boolean. It is now refused with a `ValidationError` naming the offending key, and the type only admits `true`/`false` per relation.
2411
+
2412
+ - [#1851](https://github.com/OpenSaasAU/stack/pull/1851) [`b79436b`](https://github.com/OpenSaasAU/stack/commit/b79436b34e1f1ad84c70efc2c4aaad1a64e27717) Thanks [@borisno2](https://github.com/borisno2)! - Fix a slow, superseded embedding generation overwriting a newer one: the write is now skipped unless the source text still matches what was embedded (`writePluginOwnedField` accepts `onlyIfUnchanged`).
2413
+
2414
+ - [#1542](https://github.com/OpenSaasAU/stack/pull/1542) [`b1f838b`](https://github.com/OpenSaasAU/stack/commit/b1f838b2df2aae4e6edf2598b28b6bec2b8bfba7) Thanks [@borisno2](https://github.com/borisno2)! - Fix the test harness's `truncate()` opening a second `pg.Client` beside its declared `max: 1` pool; it now runs through the harness's own client instead.
2415
+
2416
+ - [#1714](https://github.com/OpenSaasAU/stack/pull/1714) [`71714f6`](https://github.com/OpenSaasAU/stack/commit/71714f6ea2859455af0203bea6fbd13371a80cb9) Thanks [@borisno2](https://github.com/borisno2)! - Refuse `Object.prototype` member names (`constructor`, `__proto__`, `toString`) as unqueryable fields, unknown payload keys, filter tokens and admin list URLs, and reject non-scalar cursor values.
2417
+
2418
+ - [#1465](https://github.com/OpenSaasAU/stack/pull/1465) [`0c33f68`](https://github.com/OpenSaasAU/stack/commit/0c33f68b5d9449b4cdaecc792815bbd64afd7e9f) Thanks [@borisno2](https://github.com/borisno2)! - Fix `context.unsafe.sql`/`.raw` degrading to `object` through the generated `Context`/`BaseContext`/`TransactionContext` types. The generated bundle now keys the Unsafe surface to the app's own Prisma 8 client, so a migration script gets Prisma's own typed SQL builder and raw tag with no cast.
2419
+
2420
+ - [#1908](https://github.com/OpenSaasAU/stack/pull/1908) [`b1ada12`](https://github.com/OpenSaasAU/stack/commit/b1ada12fffb087487562000b10f8146a0fb80743) Thanks [@borisno2](https://github.com/borisno2)! - `afterTransaction` on a root update or delete now receives the `originalItem` resolved under the row lock, not the pre-lock snapshot (`beforeTransaction` keeps the snapshot).
2421
+
2422
+ - [#1579](https://github.com/OpenSaasAU/stack/pull/1579) [`e5ea5b3`](https://github.com/OpenSaasAU/stack/commit/e5ea5b3bd803106ed00a892ddffcdc365f4cde1e) Thanks [@borisno2](https://github.com/borisno2)! - Fix a joined write's `afterTransaction` hook receiving the transaction-bound context instead of the base client (ADR-0028), which refused a compensating write issued after the enclosing transaction had settled — while preserving that write's own `sudo()`/`withSession()` elevation.
2423
+
2424
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - `opensaas dev` is the dev loop: it starts the Dev database, generates, reconciles and runs the app
2425
+
2426
+ Running `opensaas dev` in a project now starts the Dev database on a free loopback port
2427
+ (persisting under `.opensaas/dev-db`, with `vector` loaded when the config declares the pgvector
2428
+ pack), runs `generate`, runs `prisma db update` against it, and spawns the app — `next dev` by
2429
+ default:
2430
+
2431
+ ```bash
2432
+ opensaas dev # runs `next dev`
2433
+ opensaas dev -- vitest # runs your own command instead
2434
+ ```
2435
+
2436
+ The app child is handed **no** `DATABASE_URL` — one inherited from the environment is removed
2437
+ rather than merely left uninjected: it finds the database through the state file, so
2438
+ the generated runtime reports `'dev-database'` provenance and takes the single-connection binding.
2439
+ `DATABASE_URL` already set is the Database escape — no Dev database starts and the environment
2440
+ passes through untouched. The project's `.env` is loaded before that decision is made, the same
2441
+ file the generated `prisma.config.ts` and `next dev` load, so a `DATABASE_URL` written there is
2442
+ honoured rather than shadowed by a sidecar nothing uses; a shell variable still outranks the file.
2443
+ The database dies with the process; `opensaas.config.ts` is still watched, and the loop shuts the
2444
+ database down on every path that unwinds — a failed reconcile, a Prisma CLI that will not run, and
2445
+ Ctrl-C at the consent prompt included. A `generate` that refuses ends the process outright, past
2446
+ the reach of an async shutdown, so that path is covered synchronously instead: the app child is
2447
+ killed and the run's state file removed.
2448
+
2449
+ Every Prisma CLI spawn is asynchronous now (a `spawnSync` deadlocks the socket server the Dev
2450
+ database is served on), with stdin closed for `contract emit` and the terminal inherited for the
2451
+ boot `db update`, so a destructive plan stops at Prisma's own consent prompt and the app is never
2452
+ started.
2453
+
2454
+ - [#1715](https://github.com/OpenSaasAU/stack/pull/1715) [`d8d5822`](https://github.com/OpenSaasAU/stack/commit/d8d58220e809ef64d7c63ee26ce9f0f491ac836d) Thanks [@borisno2](https://github.com/borisno2)! - Refuse an MCP custom or plugin tool whose name collides with a built-in `list_<x>_<op>` tool or another custom tool, instead of advertising it twice and never running it.
2455
+
2456
+ - [#2022](https://github.com/OpenSaasAU/stack/pull/2022) [`d38788f`](https://github.com/OpenSaasAU/stack/commit/d38788fa5aa83308e307b25b606b8b654283fbcc) Thanks [@borisno2](https://github.com/borisno2)! - MCP `tools/call` now answers an unknown list with the same `Unknown tool` error as an unreachable one, so list names can't be enumerated.
2457
+
2458
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Make the secured-surface distinct, cursor and indistinguishability tests falsifiable — no runtime change. The `distinct` case now composes a caller `where` whose answers differ from the unfiltered ones on both the scoped and unscoped sides, and every refusal message is pinned to the literal `unqueryableKey` text beside its `ValidationError` class check.
2459
+
2460
+ - [#1460](https://github.com/OpenSaasAU/stack/pull/1460) [`21bd0d5`](https://github.com/OpenSaasAU/stack/commit/21bd0d53860d8ad2f801c65e83637e523adc19f6) Thanks [@borisno2](https://github.com/borisno2)! - Fix a relation that is both reduced (`.count()`/`.combine()`) and a live declared dependency of a computed field or field-level `read` rule: it now satisfies both instead of the dependency computing over the reduction's masked `[]`.
2461
+
2462
+ - [#1729](https://github.com/OpenSaasAU/stack/pull/1729) [`8d8a338`](https://github.com/OpenSaasAU/stack/commit/8d8a338ea4606b03ef859c4128b93b40a5fc9a21) Thanks [@borisno2](https://github.com/borisno2)! - Publish only `dist`, and docs; tarballs no longer include src, tests, compiled test files or build logs.
2463
+
2464
+ - [#1580](https://github.com/OpenSaasAU/stack/pull/1580) [`6b40b3a`](https://github.com/OpenSaasAU/stack/commit/6b40b3aaa6174530a990a8f258778993f9501c98) Thanks [@borisno2](https://github.com/borisno2)! - MCP `query`'s id boundary coercion (ADR-0048) now walks the whole `where` predicate — every `AND`/`OR`/`NOT` branch, a relation quantifier's nested predicate (against the related list's own id strategy), and a nested relation-entry `where` inside a `fields` projection — instead of only the top level. A malformed id anywhere in that tree now refuses the whole request, the same answer `update`/`delete` already give, rather than silently matching nothing (which would widen a result under `NOT`).
2465
+
2466
+ - [#1514](https://github.com/OpenSaasAU/stack/pull/1514) [`e6a7fb2`](https://github.com/OpenSaasAU/stack/commit/e6a7fb28b57c56743537804231ed40e9d36ca4df) Thanks [@borisno2](https://github.com/borisno2)! - `writePluginOwnedField` now refuses a virtual field by name, instead of falling through to a write the database rejects as an unknown column and the RAG plugin then misreports as retryable.
2467
+
2468
+ - [#1691](https://github.com/OpenSaasAU/stack/pull/1691) [`99d9870`](https://github.com/OpenSaasAU/stack/commit/99d98700398539b2e145a87b18ab6e6d4df6fac4) Thanks [@borisno2](https://github.com/borisno2)! - Fix MCP OAuth never authenticating: `createBetterAuthMcpAdapter` and `withMcpAuth` now verify the bearer JWT via `@better-auth/mcp` (signature, issuer, audience, expiry) instead of calling the removed `auth.api.getMcpSession`. They take `{ resource, baseURL }` in place of the auth instance. `createAuth()` now throws on a missing `auth.api.*` member instead of resolving `undefined`.
2469
+
2470
+ - [#2037](https://github.com/OpenSaasAU/stack/pull/2037) [`2ca5582`](https://github.com/OpenSaasAU/stack/commit/2ca5582ef53ce88bc59227526b676ab4065cbfae) Thanks [@borisno2](https://github.com/borisno2)! - Fix an explicit `undefined` on a `kind: 'columns'` field nulling every part column on update; it is now treated as omitted.
2471
+
2472
+ A `resolveInput` returning `undefined` for such a field now writes nothing; use `null` to clear it.
2473
+
2474
+ - [#2005](https://github.com/OpenSaasAU/stack/pull/2005) [`fb6a598`](https://github.com/OpenSaasAU/stack/commit/fb6a598b7c06f39d6d9ac26a8d8d9d6ae21aa4ce) Thanks [@borisno2](https://github.com/borisno2)! - Clarify the `removeRelated` server action docs: a disconnect that sends `parentId` is the stale-baseline guard, and omitting it disconnects unconditionally.
2475
+
2476
+ - [#2005](https://github.com/OpenSaasAU/stack/pull/2005) [`fb6a598`](https://github.com/OpenSaasAU/stack/commit/fb6a598b7c06f39d6d9ac26a8d8d9d6ae21aa4ce) Thanks [@borisno2](https://github.com/borisno2)! - `context.db` writes now `console.warn` once per list and operation when the context has no transaction to join and no opener of its own, so a `getContext` built without a `client` no longer drops rollback silently.
2477
+
2478
+ - [#1581](https://github.com/OpenSaasAU/stack/pull/1581) [`f097958`](https://github.com/OpenSaasAU/stack/commit/f097958cba46015072b7b118d1ca78471700571e) Thanks [@borisno2](https://github.com/borisno2)! - Named the `ctx.runtime` path a collection carries off both `unsafe.orm` and `AccessContext.ormHandle` in the Unsafe surface's `Known limits`, corrected prose that overclaimed `prepare()`/`runtime()` as unreachable rather than "not among the surface's own members", and added a test pinning the reachability and tripwire behavior of `ctx.runtime` and `runtime.connection()`.
2479
+
2480
+ - [#1707](https://github.com/OpenSaasAU/stack/pull/1707) [`ee0d3d3`](https://github.com/OpenSaasAU/stack/commit/ee0d3d3e20201e2ad3859f081597fb5e623518eb) Thanks [@borisno2](https://github.com/borisno2)! - Fix `decimal({ defaultValue })` failing schema apply: the default is now emitted in the normalised SQL form the verifier compares against.
2481
+
2482
+ - [#1775](https://github.com/OpenSaasAU/stack/pull/1775) [`c1b689a`](https://github.com/OpenSaasAU/stack/commit/c1b689ae2c8783426a684af19e7962346af15124) Thanks [@borisno2](https://github.com/borisno2)! - Restrict the Dev database data directory to `0700` and its state and lock files to `0600`.
2483
+
2484
+ - [#1850](https://github.com/OpenSaasAU/stack/pull/1850) [`a1dbf13`](https://github.com/OpenSaasAU/stack/commit/a1dbf1360fd2beef632b3575d82d464db6af136a) Thanks [@borisno2](https://github.com/borisno2)! - The Dev database now refuses connections without its per-boot password: PGlite is served on a 0700 unix socket and the TCP port is a cleartext-password front, with the password carried in the state-file URL.
2485
+
2486
+ - [#1713](https://github.com/OpenSaasAU/stack/pull/1713) [`2d5d159`](https://github.com/OpenSaasAU/stack/commit/2d5d159dab277af9b6e29f3b07ce69debeeacce5) Thanks [@borisno2](https://github.com/borisno2)! - `writePluginOwnedField` refuses a relationship field with `NoColumnsPluginFieldWriteError` instead of passing it to the ORM.
2487
+
2488
+ - [#1753](https://github.com/OpenSaasAU/stack/pull/1753) [`3e298af`](https://github.com/OpenSaasAU/stack/commit/3e298af86ebfa9c359fb4fbbd8fcde4262fb84c7) Thanks [@borisno2](https://github.com/borisno2)! - Security: admin `serverAction` and relationship actions no longer return a non-validation error's raw message to the client. Only `ValidationError`, `DatabaseError` and the engine's own refusals pass through; anything else is logged and replaced with a generic message. MCP shares the same predicate.
2489
+
2490
+ - [#1776](https://github.com/OpenSaasAU/stack/pull/1776) [`b784cd9`](https://github.com/OpenSaasAU/stack/commit/b784cd94e44f2a34420a125aff5c099c15e21ba0) Thanks [@borisno2](https://github.com/borisno2)! - `extendList` now throws when a plugin redeclares a field another plugin introduced, instead of silently discarding that field's access, hooks and options.
2491
+
2492
+ - [#2014](https://github.com/OpenSaasAU/stack/pull/2014) [`0a362c3`](https://github.com/OpenSaasAU/stack/commit/0a362c35ee77c90d5cbf3d0fcb24129dc4817179) Thanks [@borisno2](https://github.com/borisno2)! - Refuse a non-Postgres `DATABASE_URL` (such as a 0.43 `file:./dev.db`) with an error naming the variable and scheme, in the runtime lookup and before `opensaas dev` starts anything.
2493
+
2494
+ - [#1544](https://github.com/OpenSaasAU/stack/pull/1544) [`548dd00`](https://github.com/OpenSaasAU/stack/commit/548dd0014551b07c3ff3fefccb2945bb025c6864) Thanks [@borisno2](https://github.com/borisno2)! - Delete the dead to-one access tree, its visibility resolver and the post-query null-forcing (`access-filter.ts`), now that the native include-based scoping fully replaced them. Internal cleanup only — no behavior change.
2495
+
2496
+ - [#1965](https://github.com/OpenSaasAU/stack/pull/1965) [`d5577eb`](https://github.com/OpenSaasAU/stack/commit/d5577ebc8ec82337482eb759f87913300f198567) Thanks [@borisno2](https://github.com/borisno2)! - A nested include or order on a declared relation no longer leaks two-hop or read-denied data into a `resolveOutput` hook's `item`.
2497
+
2498
+ - [#1522](https://github.com/OpenSaasAU/stack/pull/1522) [`c322241`](https://github.com/OpenSaasAU/stack/commit/c322241a7a8a293ce6824df13dcb9765cd9479a2) Thanks [@borisno2](https://github.com/borisno2)! - Add a `typecheck` script to every package, covering `tests/**/*` alongside `src/**/*` (not just what `build` compiles), and fix the type errors it surfaced in existing test files.
2499
+
2500
+ - [#1841](https://github.com/OpenSaasAU/stack/pull/1841) [`405951c`](https://github.com/OpenSaasAU/stack/commit/405951cd67f1127701246364c873b457e39afd04) Thanks [@borisno2](https://github.com/borisno2)! - MCP now refuses malformed uuid/cuid ids in `where.id`, foreign-key columns and `connect.id` at the id boundary instead of letting them reach Postgres.
2501
+
2502
+ - [#1700](https://github.com/OpenSaasAU/stack/pull/1700) [`d94c528`](https://github.com/OpenSaasAU/stack/commit/d94c528ab490245a081d7e84b53287559f224866) Thanks [@borisno2](https://github.com/borisno2)! - Fix `create()`, `update()` and `delete()` results returning a to-one's `<field>Id` that a `first()` of the same row hides; write results now go through the same foreign-key narrowing as reads.
2503
+
2504
+ - [#1696](https://github.com/OpenSaasAU/stack/pull/1696) [`6b9e24e`](https://github.com/OpenSaasAU/stack/commit/6b9e24e348b711a92c9610df554f03098bde97c7) Thanks [@borisno2](https://github.com/borisno2)! - A computed field that `needs` a to-one relation no longer nulls that relation's foreign key on bare reads.
2505
+
2506
+ - [#1770](https://github.com/OpenSaasAU/stack/pull/1770) [`e70ab87`](https://github.com/OpenSaasAU/stack/commit/e70ab87f7bae9eccc0212f0d43d58b9dd427394c) Thanks [@borisno2](https://github.com/borisno2)! - Security fix: a `create`/`update`/`delete` result now respects operation-level `query` access. A session that cannot query the written row gets only the list's system fields back (the write still persists); `sudo()` is unchanged.
2507
+
2508
+ - [#1503](https://github.com/OpenSaasAU/stack/pull/1503) [`5c23069`](https://github.com/OpenSaasAU/stack/commit/5c23069861fda7ebfd77ac0726200800b597d60a) Thanks [@borisno2](https://github.com/borisno2)! - Fix a to-one relationship label filter emitting `contains` against `id` (and throwing a `ValidationError`) for a related list with no `name`/`title`/`ui.labelField`; the filter now declines instead.
2509
+
2510
+ - [#1876](https://github.com/OpenSaasAU/stack/pull/1876) [`558198e`](https://github.com/OpenSaasAU/stack/commit/558198e62ffbd5e58d82c97e82534e8ca8d233aa) Thanks [@borisno2](https://github.com/borisno2)! - `removeRelated` with a `parentId` now answers `denied` for a link the session cannot see, whether or not the guess matches, closing an existence oracle.
2511
+
2512
+ - [#1709](https://github.com/OpenSaasAU/stack/pull/1709) [`2b17424`](https://github.com/OpenSaasAU/stack/commit/2b1742453308c34e8294785e48f979bee25e75a3) Thanks [@borisno2](https://github.com/borisno2)! - Fix `serverAction` `removeRelated` with `parentId` revealing a hidden foreign key through differing refusal messages.
2513
+
2514
+ - [#1736](https://github.com/OpenSaasAU/stack/pull/1736) [`4cb0892`](https://github.com/OpenSaasAU/stack/commit/4cb0892c7ec815d8f75fd04c8f29f315e98f7c83) Thanks [@borisno2](https://github.com/borisno2)! - A root write's own transaction now carries a row-lock lane, so list- and field-level `resolveInput`, `validate`, `beforeOperation` and `afterOperation` hooks can call `forUpdate()` instead of throwing `RowLockUnavailableError`.
2515
+
2516
+ - [#1690](https://github.com/OpenSaasAU/stack/pull/1690) [`5432400`](https://github.com/OpenSaasAU/stack/commit/54324009f724168a02b3a5577b0877011748732e) Thanks [@borisno2](https://github.com/borisno2)! - `generate` now refuses any stored column whose physical name (`db.map` or `db.foreignKey.map`) equals a relation field name on the same list, closing a path that leaked a related row past its read rules.
2517
+
2518
+ - [#1716](https://github.com/OpenSaasAU/stack/pull/1716) [`f51ca12`](https://github.com/OpenSaasAU/stack/commit/f51ca12b793c2131e04f6d997af24eb42f2198f0) Thanks [@borisno2](https://github.com/borisno2)! - `generate` now refuses fields named `AND`/`OR`/`NOT` (and `some`/`every`/`none` on relationships) and any `db.idField` outside the three strategies; `opensaas init` no longer runs the project name through a shell.
2519
+
2520
+ - [#1546](https://github.com/OpenSaasAU/stack/pull/1546) [`721b7c0`](https://github.com/OpenSaasAU/stack/commit/721b7c0eeca000966c7a419e3946d34cef9b2bc1) Thanks [@borisno2](https://github.com/borisno2)! - Add a test guarding that a tripwire refusal mid-write rolls back the write's transaction and reaches the caller as `UnmarkedQueryError`, unwrapped.
2521
+
2522
+ - [#1539](https://github.com/OpenSaasAU/stack/pull/1539) [`cae8c1e`](https://github.com/OpenSaasAU/stack/commit/cae8c1e562bf6f780bd2d870948f407dbabbf4fe) Thanks [@borisno2](https://github.com/borisno2)! - Fix `resolvePrismaBinary`'s script detection to also match a `.mjs`/`.cjs` Prisma CLI entry point, not only `.js`. Test-only fixes: correct a `bundle-typecheck.test.ts` name that overstated its own coverage (`skipLibCheck` means it never checks `contract.d.ts` for errors), cover the `longIdentifierConfig` fixture in the contract structural-equivalence suite, and move a misplaced fixture docblock onto the export it describes.
2523
+
2524
+ - [#1513](https://github.com/OpenSaasAU/stack/pull/1513) [`bc2614f`](https://github.com/OpenSaasAU/stack/commit/bc2614f3ebd662737d22d5e47bf03f26a1aca5a6) Thanks [@borisno2](https://github.com/borisno2)! - `bindContextToTransaction` now spreads the source `AccessContext` and overrides only what a transaction rebind must change, instead of rebuilding it by listing every member by hand — a shape that silently drops whichever member the next one forgets to add to the list.
2525
+
2526
+ - [#1533](https://github.com/OpenSaasAU/stack/pull/1533) [`c3ce7b6`](https://github.com/OpenSaasAU/stack/commit/c3ce7b6f23240144ae424d47685c71c0e553b877) Thanks [@borisno2](https://github.com/borisno2)! - Refuse, at `pnpm generate` time, an explicit `defaultValue` a field's own create validation would reject (e.g. `text({ defaultValue: '', validation: { isRequired: true } })`). Previously the value was written onto the contract column unconditionally, so the column's default dropped the field from `CreateInput`'s required half while the create validator still rejected it — an omitted create type-checked and then threw `ValidationError` at runtime.
2527
+
2528
+ - [#1575](https://github.com/OpenSaasAU/stack/pull/1575) [`7ffacbf`](https://github.com/OpenSaasAU/stack/commit/7ffacbfe1cee35ae7d9922519e94a68c13d0b34b) Thanks [@dependabot](https://github.com/apps/dependabot)! - Fix Vitest 5 browser test shutdown running out of memory and preserve per-file coverage gates.
2529
+
2530
+ - [#1584](https://github.com/OpenSaasAU/stack/pull/1584) [`a2c8e59`](https://github.com/OpenSaasAU/stack/commit/a2c8e59e39d303c97dbdb51875261fff0169be8d) Thanks [@borisno2](https://github.com/borisno2)! - Fix a computed field (`{ kind: 'computed' }`, e.g. from a third-party field builder) that omits core's `virtual` flag: its `resolveOutput` now runs on read (it silently never ran before), and the generated `needs`/`NeedsItem` types are produced for it, matching a flagged `virtual()` field.
2531
+
2532
+ - [#1737](https://github.com/OpenSaasAU/stack/pull/1737) [`4af852c`](https://github.com/OpenSaasAU/stack/commit/4af852c8d166e80e9197a7ba97779ff784f42156) Thanks [@borisno2](https://github.com/borisno2)! - A `context.transaction()` owner now rolls back and rejects with the new `TransactionRolledBackError` (first failure on `cause`) when a joined `context.db` write threw or the database aborted the transaction, even if the callback caught the error. A callback that swallowed a child failure previously committed; it now rejects. `afterTransaction` receives `rolled-back`.
2533
+
2534
+ - [#1708](https://github.com/OpenSaasAU/stack/pull/1708) [`cf575b0`](https://github.com/OpenSaasAU/stack/commit/cf575b0330f8709096c6097e0a97e9a1ba1291e2) Thanks [@borisno2](https://github.com/borisno2)! - Remove pre-Prisma-8 residue: the dead `resolveForeignKeyVisibility` module, the never-thrown `RelationFilterAccessDeniedError` (now deprecated), and the `authPlugin` TSDoc's sqlite example.
2535
+
2536
+ - [#2049](https://github.com/OpenSaasAU/stack/pull/2049) [`e1e0831`](https://github.com/OpenSaasAU/stack/commit/e1e083177640d677bbc3865d2deeae21c718ac55) Thanks [@borisno2](https://github.com/borisno2)! - Fix `combine()` attaching a hidden row's nested counts to a shown row when Field Visibility drops rows from the related list.
2537
+
2538
+ - [#1567](https://github.com/OpenSaasAU/stack/pull/1567) [`f06fbf4`](https://github.com/OpenSaasAU/stack/commit/f06fbf4055f51946d89c72985176d54f43af217d) Thanks [@borisno2](https://github.com/borisno2)! - The write pipeline's per-write ORM handle reconciliation now derives the list-to-namespace shape once per context, reused on every write's transaction, instead of re-walking `config.lists` on each write.
2539
+
2540
+ - [#1957](https://github.com/OpenSaasAU/stack/pull/1957) [`daf9635`](https://github.com/OpenSaasAU/stack/commit/daf9635f44969051ad9ef4e30a403f7b0c2f0160) Thanks [@borisno2](https://github.com/borisno2)! - Fix relationship picker search redirecting away from the edit form: the `relationshipOptions` server action now returns `{ options }` instead of `{ success, data }`. Upgrade `@opensaas/stack-core` and `@opensaas/stack-ui` together.
2541
+
2542
+ - [#1562](https://github.com/OpenSaasAU/stack/pull/1562) [`6d8c6c7`](https://github.com/OpenSaasAU/stack/commit/6d8c6c78d590f0dc804578fd3f8f2b32b02677ce) Thanks [@borisno2](https://github.com/borisno2)! - Fix `packages/core/CLAUDE.md` documenting the plugin runtime's `sudo()` helper as returning `AccessContext` — it returns `StackContext`.
2543
+
2544
+ - [#1569](https://github.com/OpenSaasAU/stack/pull/1569) [`5cfa783`](https://github.com/OpenSaasAU/stack/commit/5cfa7832f48f905391c5a76b979a9ca93024d207) Thanks [@borisno2](https://github.com/borisno2)! - Remove `ListUniqueWhere`, `ListFilterArgs`, `ListWhere`, `ListOrderBy` and `ColumnFilter` — dead exports left over from a `findMany`/`findUnique`-style args surface `update`/`delete` no longer use (they take `ListIdentityWhere`, i.e. `{ id }`, and `findUnique` itself no longer exists).
2545
+
2546
+ - [#2041](https://github.com/OpenSaasAU/stack/pull/2041) [`10dbc3d`](https://github.com/OpenSaasAU/stack/commit/10dbc3ddbb2df3516a4c0d0b284688276ac29de7) Thanks [@borisno2](https://github.com/borisno2)! - MCP sessions no longer let a `__proto__` claim in an accepted JWT set the context session's prototype.
2547
+
2548
+ - [#1711](https://github.com/OpenSaasAU/stack/pull/1711) [`42b141b`](https://github.com/OpenSaasAU/stack/commit/42b141b644fbf90d3d976431557e15a90e9ce518) Thanks [@borisno2](https://github.com/borisno2)! - `update()` with an empty stored payload now returns the target row and fires `afterOperation`, instead of returning `null`.
2549
+
2550
+ - [#2038](https://github.com/OpenSaasAU/stack/pull/2038) [`defbeba`](https://github.com/OpenSaasAU/stack/commit/defbeba0f139501c23d63b34865dbdae43ecf16c) Thanks [@borisno2](https://github.com/borisno2)! - A singleton's `get()` auto-create no longer fails when a defaulted field denies `create` or is `write: 'hooks'`, and concurrent first `get()` calls resolve to the one row.
2551
+
2552
+ - [#1898](https://github.com/OpenSaasAU/stack/pull/1898) [`a8edbd1`](https://github.com/OpenSaasAU/stack/commit/a8edbd1e7276f8ca1e13747c2f1f4e4c354a782a) Thanks [@borisno2](https://github.com/borisno2)! - Fix the Dev database's `stop()` closing PGlite before the socket server's asynchronous client detach finished, which threw an unhandled `_IsTransactionBlock` error after shutdown.
2553
+
2554
+ - [#1695](https://github.com/OpenSaasAU/stack/pull/1695) [`407c1b8`](https://github.com/OpenSaasAU/stack/commit/407c1b842a35829c4cdfc3b0f4ff99b1e62ce032) Thanks [@borisno2](https://github.com/borisno2)! - `sudo()` bare reads no longer null to-one foreign keys by the session's own access, so they agree with a sudo include.
2555
+
2556
+ - [#1874](https://github.com/OpenSaasAU/stack/pull/1874) [`4435b33`](https://github.com/OpenSaasAU/stack/commit/4435b3340a7255ca63f80e53e5195a351647e299) Thanks [@borisno2](https://github.com/borisno2)! - A list MCP custom tool that omits `scopes` now requires the configured write scope when `mcp.scopes` is set; pass `scopes: []` to opt out.
2557
+
2558
+ - [#1712](https://github.com/OpenSaasAU/stack/pull/1712) [`c7284be`](https://github.com/OpenSaasAU/stack/commit/c7284be4eb17d27f3dd6b36feee604561df98986) Thanks [@borisno2](https://github.com/borisno2)! - MCP custom and plugin tool errors, `tools/list` failures and non-object `data` are now redacted or refused cleanly; throw `McpToolError` to return a message to the client.
2559
+
2560
+ - [#1694](https://github.com/OpenSaasAU/stack/pull/1694) [`96dfeee`](https://github.com/OpenSaasAU/stack/commit/96dfeee7648c0431cb956f15cd5ca4c2210b0afb) Thanks [@borisno2](https://github.com/borisno2)! - MCP `tools/call` now refuses disabled lists, disabled operations, and custom tools on disabled or query-denied lists, matching what `tools/list` advertises.
2561
+
2562
+ - [#1521](https://github.com/OpenSaasAU/stack/pull/1521) [`e11271b`](https://github.com/OpenSaasAU/stack/commit/e11271b523cf92f9d60236ea02715b1fa87c6028) Thanks [@borisno2](https://github.com/borisno2)! - Guard `typed-read-surface.test.ts`'s pgvector-dependent test so the Database escape skips it, rather than failing the whole file, on a server without the extension.
2563
+
2564
+ - [#1752](https://github.com/OpenSaasAU/stack/pull/1752) [`3cb2d50`](https://github.com/OpenSaasAU/stack/commit/3cb2d504e90128dfc7952b19bbea49eabab13f0d) Thanks [@borisno2](https://github.com/borisno2)! - `create`, `update` and `delete` no longer accept `select`/`include`, which were typed but never applied; passing either (or any unknown key) now throws a `ValidationError`. Read the row back with `.where({ id }).include(…).first()` instead.
2565
+
2566
+ - [#2015](https://github.com/OpenSaasAU/stack/pull/2015) [`79c7674`](https://github.com/OpenSaasAU/stack/commit/79c76749147114d91b1c76669882509489251316) Thanks [@borisno2](https://github.com/borisno2)! - Escape quotes and newlines in `select()` option values in the generated types, and refuse non-identifier field keys at generate time.
2567
+
2568
+ - [#1846](https://github.com/OpenSaasAU/stack/pull/1846) [`caf883a`](https://github.com/OpenSaasAU/stack/commit/caf883a88629ac5eeb41375e220d9c11427edaee) Thanks [@borisno2](https://github.com/borisno2)! - Fix a caught failing secured read inside a transaction silently rolling it back: read terminals now poison the transaction owner, so the call rejects with `TransactionRolledBackError`.
2569
+
2570
+ - [#1769](https://github.com/OpenSaasAU/stack/pull/1769) [`32b9afa`](https://github.com/OpenSaasAU/stack/commit/32b9afadab65cbe6445dcd15da8df54218880f7b) Thanks [@borisno2](https://github.com/borisno2)! - Security: a create/update naming a raw part column of a multi-column field (`avatar_url`, `doc_filename`) is refused with a `ValidationError`, sudo included, so the logical field's validation and hooks cannot be bypassed. Write the logical field, or use `context.unsafe`.
2571
+
2572
+ - [#1858](https://github.com/OpenSaasAU/stack/pull/1858) [`269165e`](https://github.com/OpenSaasAU/stack/commit/269165e1e6182b1e41f01c13a0e0c08ed5523644) Thanks [@borisno2](https://github.com/borisno2)! - Fix the relationship picker failing entirely when the session cannot read the related list's label field; it now orders by `id` and skips search.
2573
+
2574
+ - [#1710](https://github.com/OpenSaasAU/stack/pull/1710) [`8fe4ea2`](https://github.com/OpenSaasAU/stack/commit/8fe4ea2a52e2e0202c4568fca46d1da76a87652d) Thanks [@borisno2](https://github.com/borisno2)! - `isRequired` on `integer`, `decimal`, `bigInt` and `select` now rejects `null` on update with a field error instead of reaching the database.
2575
+
2576
+ - [#1861](https://github.com/OpenSaasAU/stack/pull/1861) [`b1fec28`](https://github.com/OpenSaasAU/stack/commit/b1fec28fa5c07fe5aa8d3ba15e07f269bf1c645b) Thanks [@borisno2](https://github.com/borisno2)! - `context.serverAction` create/update/delete now returns only `{ id }` in `data`, so fields redacted with `ui.valueForClientSerialization` no longer reach the browser.
2577
+
2578
+ - [#1455](https://github.com/OpenSaasAU/stack/pull/1455) [`27d91d5`](https://github.com/OpenSaasAU/stack/commit/27d91d54fcd79122dfe695b5dea94c14572a2b98) Thanks [@borisno2](https://github.com/borisno2)! - Fix MCP read path: a throwing field-level access rule no longer leaks its raw error text to the client, and no longer fails a `fields`-bearing query for a field the caller never named.
2579
+
2580
+ - [#1538](https://github.com/OpenSaasAU/stack/pull/1538) [`22f03bc`](https://github.com/OpenSaasAU/stack/commit/22f03bca2f190a9c1d854e22efe5beb3807da264) Thanks [@borisno2](https://github.com/borisno2)! - Fix three Dev database robustness gaps: `resolveDatabaseUrl()` now treats a state file whose pid is live but not this sidecar (a reboot or pid wrap) as stale; `startDevDatabase` refuses a second call against a `dataDir` already in use instead of racing it; and a relative `dataDir` now resolves against the same root as the state file.
2581
+
2582
+ - [#1487](https://github.com/OpenSaasAU/stack/pull/1487) [`12bd183`](https://github.com/OpenSaasAU/stack/commit/12bd183112000abe7d34487ee0f8c874b5623507) Thanks [@borisno2](https://github.com/borisno2)! - Fix a flaky test: `lower.test.ts`'s vector-lowering retry case no longer cold-imports the real ORM module inside the timed test body.
2583
+
2584
+ - [#1547](https://github.com/OpenSaasAU/stack/pull/1547) [`53f2d20`](https://github.com/OpenSaasAU/stack/commit/53f2d202d5a58bcdb4d016aef929ae68a5151ed4) Thanks [@borisno2](https://github.com/borisno2)! - Fix the test harness's escape to read `DIRECT_DATABASE_URL`/`DATABASE_URL` in the same order `resolveDatabaseUrl()` does, so a `DIRECT_DATABASE_URL`-only environment runs the suite against that server instead of silently falling back to PGlite.
2585
+
2586
+ - [#1502](https://github.com/OpenSaasAU/stack/pull/1502) [`d40c4bb`](https://github.com/OpenSaasAU/stack/commit/d40c4bb1700bc4f52203d4082cc13fb9efaa098a) Thanks [@borisno2](https://github.com/borisno2)! - Remove the dead `FindManyArgs`, `FindUniqueArgs` and `CountArgs` exports left behind by a prior delegate removal, and advertise/validate MCP `connect.id` at the related list's own id type instead of assuming every list is string-keyed.
2587
+
2588
+ - [#1466](https://github.com/OpenSaasAU/stack/pull/1466) [`95cb6dc`](https://github.com/OpenSaasAU/stack/commit/95cb6dc70a6c622c70c8cd74a14abb53f25bc95f) Thanks [@borisno2](https://github.com/borisno2)! - Fix three spots that assumed every list carries `createdAt`/`updatedAt` (timestamps are opt-in, ADR-0004): the migration generator no longer drops a source model's timestamp columns — it opts the list into `db.timestamps` when they match the auto-managed shape, or declares them as ordinary fields otherwise; the MCP fields projection no longer advertises or accepts `createdAt`/`updatedAt` on a list that doesn't have them; and the blog feature generator's scaffolded Post list now opts into `db.timestamps`, since its generated pages read `post.createdAt`.
2589
+
2590
+ - [#1609](https://github.com/OpenSaasAU/stack/pull/1609) [`04a00f4`](https://github.com/OpenSaasAU/stack/commit/04a00f4ae87611b879829b9d20fbfe9cdb656da2) Thanks [@borisno2](https://github.com/borisno2)! - Prevent production database discovery and tracing from following Dev state into the project root; pass an explicit state path when the dev loop serves a production build.
2591
+
2592
+ - [#1490](https://github.com/OpenSaasAU/stack/pull/1490) [`3d0d4db`](https://github.com/OpenSaasAU/stack/commit/3d0d4db7923a75cf77f665ef8f915edcf99a408d) Thanks [@borisno2](https://github.com/borisno2)! - Fix a flaky substring-over-serialised-JSON leak assertion in `select.test.ts` (same shape as the `include.test.ts` flake fixed in [#1479](https://github.com/OpenSaasAU/stack/issues/1479)), using a structural exact-value check instead.
2593
+
2594
+ - [#1586](https://github.com/OpenSaasAU/stack/pull/1586) [`80b3e20`](https://github.com/OpenSaasAU/stack/commit/80b3e204d20f60aded2d6d10cd9a04b8da5119da) Thanks [@borisno2](https://github.com/borisno2)! - Make an empty-value filter token (`role:` or a bare `""`) an explicit, tested no-op in `buildFilterWhere` instead of a silent drop that relied on JS falsy-string truthiness.
2595
+
2596
+ - [#1673](https://github.com/OpenSaasAU/stack/pull/1673) [`c267d3c`](https://github.com/OpenSaasAU/stack/commit/c267d3c1aa2423374ae1f0b9e24e9b4f8bdf4b7c) Thanks [@borisno2](https://github.com/borisno2)! - Fix a critical security issue ([#1619](https://github.com/OpenSaasAU/stack/issues/1619)): `image()`/`file()` fields trusted a caller-supplied metadata-shaped value (`{ filename, url, ... }`) verbatim, so cleanup would later delete whatever path it named through whatever provider it named — arbitrary file deletion via a traversal `filename`, and cross-row deletion by copying another row's metadata.
2597
+
2598
+ A metadata-shaped write is now accepted only when it deep-equals the field's own currently stored value (the admin form's resubmit-unchanged case), or when the write runs under `sudo()` (seed/migration scripts pointing a new row at an already-uploaded asset):
2599
+
2600
+ ```typescript
2601
+ // Non-sudo create with metadata-shaped input is refused — upload a File instead.
2602
+ await context.db.Doc.create({ data: { attachment: someMetadata } }) // throws
2603
+
2604
+ // Sudo may still point a new row at an existing asset.
2605
+ await context.sudo().db.Doc.create({ data: { attachment: someMetadata } })
2606
+
2607
+ // Non-sudo update succeeds only when the value matches what's already stored.
2608
+ await context.db.Doc.update({ where: { id }, data: { attachment: row.attachment } }) // OK
2609
+ await context.db.Doc.update({ where: { id }, data: { attachment: otherRowsMetadata } }) // throws
2610
+ ```
2611
+
2612
+ Cleanup (`cleanupOnDelete`/`cleanupOnReplace`) now always deletes through the field's own configured `storage` provider, never the `storageProvider` a stored value happens to name, and `LocalStorageProvider` resolves every `filename` it's given (`upload`, `download`, `delete`, `getUrl`) against `uploadDir`, refusing anything that isn't a plain filename strictly inside it. With `generateUniqueFilenames: false`, a traversal-shaped upload name is reduced to a safe basename instead of being written verbatim.
2613
+
2614
+ `ImageTransformationResult` (`@opensaas/stack-core`) gains an optional `filename` field, populated from the provider's own upload result, so `deleteImage` deletes a transformation variant by the key the upload recorded rather than by parsing it out of the stored `url`.
2615
+
2616
+ - [#1510](https://github.com/OpenSaasAU/stack/pull/1510) [`6eab4e2`](https://github.com/OpenSaasAU/stack/commit/6eab4e28e2a42168db2fb8bb99c94c1f22d527cd) Thanks [@borisno2](https://github.com/borisno2)! - Fix a stale item form's to-many deselect silently reverting a concurrent re-point of the related row. `removeRelated`'s disconnect now locks the row and compares its current back-reference against the form's baseline, refusing the unlink (with an error the form surfaces) instead of nulling a link someone else just wrote.
2617
+
2618
+ - [#1679](https://github.com/OpenSaasAU/stack/pull/1679) [`c63d79f`](https://github.com/OpenSaasAU/stack/commit/c63d79fd92c6265030eddae6dcfb4a5faa4a5a69) Thanks [@dependabot](https://github.com/apps/dependabot)! - Support `@prisma/orm-*` 8.0.0-rc.12: drop the removed `strategy` lowering key and keep `createdAt`'s database `now()` default, which rc.12's `createdAtString()` preset no longer emits.
2619
+
2620
+ - [#1875](https://github.com/OpenSaasAU/stack/pull/1875) [`105d10a`](https://github.com/OpenSaasAU/stack/commit/105d10a81700af5518ba9a4a6ca0405795fada76) Thanks [@borisno2](https://github.com/borisno2)! - A root `update`/`delete` now locks its target row before hooks run and re-resolves it under the lock, so a concurrent change that moves the row out of access scope returns `null` instead of writing.
2621
+
2622
+ - [`0c5d3aa`](https://github.com/OpenSaasAU/stack/commit/0c5d3aa37230c353218a164fa7c8352bbc9f6537) Thanks [@borisno2](https://github.com/borisno2)! - `generate` refuses a `db.extensions[].name` that is not an identifier or collides with a generated import, before writing anything, and escapes `from` in generated imports.
2623
+
2624
+ - [#2010](https://github.com/OpenSaasAU/stack/pull/2010) [`7d00071`](https://github.com/OpenSaasAU/stack/commit/7d00071e92b195bdbb2f1c3df6219b8db90ff58d) Thanks [@borisno2](https://github.com/borisno2)! - Refuse a non-identifier list key or `db.enumName` at generate time with an error naming it, instead of Prisma's parse error.
2625
+
2626
+ - [#1964](https://github.com/OpenSaasAU/stack/pull/1964) [`604b029`](https://github.com/OpenSaasAU/stack/commit/604b029d383573e000634660e43afd36fd247cfa) Thanks [@borisno2](https://github.com/borisno2)! - Refuse `count()` and `combine` count branches through a synthetic back-relation whose source field has a row-dependent `read` rule, closing a count oracle ([#1910](https://github.com/OpenSaasAU/stack/issues/1910)).
2627
+
2628
+ - [#1842](https://github.com/OpenSaasAU/stack/pull/1842) [`5d0ec1b`](https://github.com/OpenSaasAU/stack/commit/5d0ec1b3961fe63fad41a33096802faa4111507d) Thanks [@borisno2](https://github.com/borisno2)! - Fix a synthetic back-relation include (`from_<List>_<field>`) bypassing the source relationship field's `read` access rule.
2629
+
2630
+ - [#1451](https://github.com/OpenSaasAU/stack/pull/1451) [`d59945a`](https://github.com/OpenSaasAU/stack/commit/d59945a36ba6615823e22822f366fb2507fbad68) Thanks [@borisno2](https://github.com/borisno2)! - Fix `calendarDay` writing and filtering a JS `Date` against its now-string-codec column, which could silently drift the stored date by a day under a negative-UTC-offset server timezone.
2631
+
2632
+ - [#1504](https://github.com/OpenSaasAU/stack/pull/1504) [`d9b4b37`](https://github.com/OpenSaasAU/stack/commit/d9b4b3740df3573d090b140eb32daaec5c319485) Thanks [@borisno2](https://github.com/borisno2)! - Fix a filter token that can't be compiled or degraded to free text (e.g. an unsupported operator on a list with no free-text field) silently widening the result set instead of matching no rows.
2633
+
2634
+ - [#1479](https://github.com/OpenSaasAU/stack/pull/1479) [`9fe6917`](https://github.com/OpenSaasAU/stack/commit/9fe6917f37f4110740e2aa9ee174355699f8b36d) Thanks [@borisno2](https://github.com/borisno2)! - Fix an intermittent failure in `include.test.ts` caused by a substring assertion matching a UUID by chance.
2635
+
2636
+ - [#1498](https://github.com/OpenSaasAU/stack/pull/1498) [`d049f38`](https://github.com/OpenSaasAU/stack/commit/d049f3804cc2974b98c854ff4ecfd1660e6d5a75) Thanks [@borisno2](https://github.com/borisno2)! - Bypassing the secured read funnel (`visibleRows`) is now a compile error, and a related row deleted between the main read and its companion foreign-key existence check fails closed to `null` — pinned by a regression test rather than left to review.
2637
+
2638
+ - [#1467](https://github.com/OpenSaasAU/stack/pull/1467) [`2739ad8`](https://github.com/OpenSaasAU/stack/commit/2739ad8923ab3db893eefb718d21fcb2d079a519) Thanks [@borisno2](https://github.com/borisno2)! - Fix a list/field hook's `context.db` resolving through core's unkeyed default instead of the app's own generated `db` surface, so `context.db.typoedListName` compiled inside a hook and a real list lost its row type. `TypeInfo` now carries the generated `db`, and every hook-args type keys `context` to it.
2639
+
2640
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Fix a rejected lazy Prisma import in `secured/lower.ts` being cached permanently — a transient import failure no longer poisons every later secured read for the life of the process; the next call retries, and a successful import is still cached.
2641
+
2642
+ - [#1534](https://github.com/OpenSaasAU/stack/pull/1534) [`bb37e04`](https://github.com/OpenSaasAU/stack/commit/bb37e04003946eea4396efc90d42d067de6276e3) Thanks [@borisno2](https://github.com/borisno2)! - Fix a field-level `resolveOutput`/`resolveInput` hook typing `value` as `unknown` at the real `list<Lists.X.TypeInfo>({...})` instantiation. `BaseFieldConfig` and every field builder now take a second `TKey` type parameter pinning the field's own key, so e.g. a `text()` field's `resolveOutput` sees `string` instead of `unknown`, and a mismatched return type is a compile error ([#1306](https://github.com/OpenSaasAU/stack/issues/1306)).
2643
+
2644
+ Compatibility note: a third-party field builder that hasn't adopted the new `TKey` parameter (the single-parameter `BaseFieldConfig<TTypeInfo>` shape the docs previously showed) now fails to compile — not merely loses hook precision — when mounted inside a `list<Lists.X.TypeInfo>({...})`-typed config, even with no custom `hooks` declared. The no-explicit-`TypeInfo` authoring flow (`list({ fields: {...} })`) is unaffected either way. Every field builder in this monorepo (core, tiptap, rag, storage) is already updated.
2645
+
2646
+ - [#1506](https://github.com/OpenSaasAU/stack/pull/1506) [`aa9296c`](https://github.com/OpenSaasAU/stack/commit/aa9296cd3af11e3e0c1b13969d986915e7673c9a) Thanks [@borisno2](https://github.com/borisno2)! - Fix MCP `create`/`update` tools disclosing which fields a session may not write: a field withheld from the `data` schema now refuses with the byte-identical message a nonexistent field gets, instead of a distinct "field-level access denied" message.
2647
+
2648
+ - [#1459](https://github.com/OpenSaasAU/stack/pull/1459) [`3fb20e0`](https://github.com/OpenSaasAU/stack/commit/3fb20e05ce986e25d317910280cfd45abb034c8a) Thanks [@borisno2](https://github.com/borisno2)! - Redact raw error text from MCP `create`/`update`/`delete` tool responses when a field-level access rule throws while Field Visibility filters the write's own result, matching the fix already applied to the `query` path in [#1361](https://github.com/OpenSaasAU/stack/issues/1361).
2649
+
2650
+ - [#1481](https://github.com/OpenSaasAU/stack/pull/1481) [`4dd1dd0`](https://github.com/OpenSaasAU/stack/commit/4dd1dd0b555a6838a989d2ee43399c676742be0c) Thanks [@borisno2](https://github.com/borisno2)! - Fix `removeRelated`/`createRelated`/`linkRelated` refusing a non-owning back-reference (the inverse half of a one-to-one, or a synthetic `from_<List>_<field>` back-relation) by checking `many === true` instead of foreign-key ownership.
2651
+
2652
+ - [#1464](https://github.com/OpenSaasAU/stack/pull/1464) [`7242781`](https://github.com/OpenSaasAU/stack/commit/7242781e1d27e6e7a4a08ed63d7ecb544e20db6e) Thanks [@borisno2](https://github.com/borisno2)! - Fix a regression from the previous MCP redaction fix ([#1459](https://github.com/OpenSaasAU/stack/issues/1459)): `DatabaseError` (and its `UniqueConstraintViolation`/`SerializationFailure` subclasses) and `ResolveOutputCycleError` are safe, framework-authored messages and are now allowlisted again on the MCP `create`/`update`/`delete` path instead of being flattened to a generic "failed due to an internal error" message.
2653
+
2654
+ - [#1519](https://github.com/OpenSaasAU/stack/pull/1519) [`52b79a7`](https://github.com/OpenSaasAU/stack/commit/52b79a7519eadce9a2dc812e63a32df022f3c578) Thanks [@borisno2](https://github.com/borisno2)! - Fix `context.plugins` and the plugin data registry being plain objects keyed by an author-supplied plugin name — a plugin named `__proto__` corrupted the object's prototype, and a name like `constructor` shadowed an inherited member. Registries are now built null-prototype, and a reserved plugin name is now refused at config time with a clear error.
2655
+
2656
+ - [#1507](https://github.com/OpenSaasAU/stack/pull/1507) [`781b819`](https://github.com/OpenSaasAU/stack/commit/781b8196064835637b93e34ec31e6a3dc959ccae) Thanks [@borisno2](https://github.com/borisno2)! - MCP `tools/list` no longer advertises a `create` tool a session can never use: a row-independent `access.operation.create` denial now drops the tool, and a `db: { isNullable: false }` required field is now classified the same as `validation.isRequired`.
2657
+
2658
+ - [#1532](https://github.com/OpenSaasAU/stack/pull/1532) [`f9b4e2c`](https://github.com/OpenSaasAU/stack/commit/f9b4e2cd5ee2e6db5ad23ca3e13e07635291747d) Thanks [@borisno2](https://github.com/borisno2)! - Fail a package's vitest run with a named, actionable error when its `dist/` was not built from its current `src/`, instead of silently testing stale built output through a cross-package import or a spawned CLI binary.
2659
+
2660
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Fix `filterWritableFields` silently dropping a directly-written foreign-key column (`authorId`) instead of writing it, gated by the owning relationship field's write access exactly like `connect`.
2661
+
2662
+ - [#1566](https://github.com/OpenSaasAU/stack/pull/1566) [`6975d3e`](https://github.com/OpenSaasAU/stack/commit/6975d3e76cb0280d9960461698e079276b56f8c0) Thanks [@borisno2](https://github.com/borisno2)! - Delete the dead relationship-count module; `isToManyRelationshipField` moves to `fields/index.ts` with no change to its root export.
2663
+
2664
+ - [#1482](https://github.com/OpenSaasAU/stack/pull/1482) [`eedb0f7`](https://github.com/OpenSaasAU/stack/commit/eedb0f7b4b856fea9927c2a06f827d38fc28f75c) Thanks [@borisno2](https://github.com/borisno2)! - Render `decimal()` fields in the admin UI
2665
+
2666
+ `decimal()` had no registered UI component, so a field declared with it logged
2667
+ `No component registered for field type: decimal` and could not be edited at
2668
+ all. It now has a form component and reuses the existing integer list-table
2669
+ cell, registered under `decimal` in the usual registries — no wiring needed:
2670
+
2671
+ ```typescript
2672
+ // opensaas.config.ts
2673
+ fields: {
2674
+ price: decimal({ precision: 10, scale: 2 }),
2675
+ }
2676
+ ```
2677
+
2678
+ Prisma 8's numeric codec is a branded `string`, never a `decimal.js`
2679
+ `Decimal` — confirmed empirically by writing a value with more significant
2680
+ digits than a JS `number` can hold and reading it back. So the value read
2681
+ from and written to `context.db` is a plain numeric-text string
2682
+ (`'19.99'`) on both sides, full precision intact through the server/client
2683
+ boundary with no special encoding needed. `@opensaas/stack-core`'s
2684
+ `decimal()` doc comments, which described the pre-Prisma-8 `Decimal`
2685
+ assumption, are corrected to match.
2686
+
2687
+ `DecimalField` is exported for custom UIs:
2688
+
2689
+ ```typescript
2690
+ import { DecimalField } from '@opensaas/stack-ui/fields'
2691
+ ```
2692
+
2693
+ - [#1537](https://github.com/OpenSaasAU/stack/pull/1537) [`a4227e9`](https://github.com/OpenSaasAU/stack/commit/a4227e9dd8097a38ec80a430b725dc5f0838f8c2) Thanks [@borisno2](https://github.com/borisno2)! - Fix `CreateInput`/`UpdateInput` never offering a multi-column field's assembled logical key (`db: { columns: 'keystone' }`, and `@opensaas/stack-rag`'s `embedding()`), and fix its raw physical columns leaking onto the row, create and update types instead of being hidden behind it. The generated bundle now carries one more remainder fact — which physical columns a multi-column field owns — so `context.db.Article.create({ data: { hero: uploadedFile } })` type-checks and `article.hero_url` no longer does.
2694
+
2695
+ - [#2026](https://github.com/OpenSaasAU/stack/pull/2026) [`5cdda55`](https://github.com/OpenSaasAU/stack/commit/5cdda55589ea00c3bea0a8d586a758d50ef9dc4c) Thanks [@dependabot](https://github.com/apps/dependabot)! - Upgrade to Prisma ORM 8.0.0-rc.21 (CLI rc.29), and keep accepting a `Date` for a `timestamp()`/`calendarDay()` value in writes and `where` filters.
2696
+ Run `pnpm generate` to re-emit committed contracts, and pin your app's `@prisma/orm-*` to `8.0.0-rc.21` and `prisma` to `8.0.0-rc.29`.
2697
+
2698
+ - [#1420](https://github.com/OpenSaasAU/stack/pull/1420) [`7ebd6ee`](https://github.com/OpenSaasAU/stack/commit/7ebd6ee5f78f5773b566dc6cac66d73b640c3c03) Thanks [@borisno2](https://github.com/borisno2)! - Harden the test harness's pgvector probe: it now redials a server that is not accepting connections yet and throws once the deadline passes, so an unreachable server can never be recorded as one without pgvector
2699
+
2700
+ - [#1575](https://github.com/OpenSaasAU/stack/pull/1575) [`7ffacbf`](https://github.com/OpenSaasAU/stack/commit/7ffacbfe1cee35ae7d9922519e94a68c13d0b34b) Thanks [@dependabot](https://github.com/apps/dependabot)! - Avoid CI timeouts in password behavior tests by using low-cost bcrypt fixtures while retaining coverage of the production default cost.
2701
+
2702
+ - [#1560](https://github.com/OpenSaasAU/stack/pull/1560) [`b0317b4`](https://github.com/OpenSaasAU/stack/commit/b0317b475ecd2cff6f11fe42ef964c80696c60ec) Thanks [@borisno2](https://github.com/borisno2)! - Fix `UndefinedAccessFilterError`'s suggested sample code, which only used the first path segment and so rendered an invalid shape for a nested or composite condition (an `AND`/`OR` branch, an operator, or a relation quantifier).
2703
+
2704
+ - [#1518](https://github.com/OpenSaasAU/stack/pull/1518) [`bed0cc3`](https://github.com/OpenSaasAU/stack/commit/bed0cc3197cd4b1ab5aebf40eda6289ae8a955fd) Thanks [@borisno2](https://github.com/borisno2)! - Fix a stale test expectation in `filter.test.ts` that still asserted the pre-[#1504](https://github.com/OpenSaasAU/stack/issues/1504) `undefined` where for an undegradable filter token, causing the `test` job to fail on unrelated PRs.
2705
+
2706
+ - [#1587](https://github.com/OpenSaasAU/stack/pull/1587) [`0a3cba5`](https://github.com/OpenSaasAU/stack/commit/0a3cba5197d98ff780036a0805d660af84dfbc50) Thanks [@borisno2](https://github.com/borisno2)! - Fix a computed field (`{ kind: 'computed' }` with no `virtual` flag) whose value was written on `create`/`update` instead of skipped — the same bug [#1531](https://github.com/OpenSaasAU/stack/issues/1531) fixed on the read path, missed on the write path (`filterWritableFields`).
2707
+
2708
+ - [#1463](https://github.com/OpenSaasAU/stack/pull/1463) [`1ecc97e`](https://github.com/OpenSaasAU/stack/commit/1ecc97ec31580d778d138122f89798f4be651744) Thanks [@borisno2](https://github.com/borisno2)! - Fix a denied to-one relation's foreign-key column leaking the related row's id on a read that never included the relation.
2709
+
2710
+ - [#1735](https://github.com/OpenSaasAU/stack/pull/1735) [`8b7eb1f`](https://github.com/OpenSaasAU/stack/commit/8b7eb1f902b73e89579f4a7ca3256c8d8a3ef950) Thanks [@borisno2](https://github.com/borisno2)! - Security fix: an access rule returning a filter that constrains nothing (`{}`, `{ AND: [] }`, `{ orgId: {} }`, or an empty predicate under `every`) now throws `VacuousAccessFilterError` instead of matching every row. A rule that meant "allow all" must return `true`.
2711
+
2712
+ - [#1478](https://github.com/OpenSaasAU/stack/pull/1478) [`7adac1b`](https://github.com/OpenSaasAU/stack/commit/7adac1bfdbce5c49c8f09a3f69bd9684a77d4cc2) Thanks [@borisno2](https://github.com/borisno2)! - Fix `virtual()` and `resolveOutput` TSDoc examples to declare `needs` for the sibling/relation columns they read off `item`.
2713
+
2714
+ - [#1563](https://github.com/OpenSaasAU/stack/pull/1563) [`07999bb`](https://github.com/OpenSaasAU/stack/commit/07999bb4c6e7748f8b3434ce82db780dbf6a8e9f) Thanks [@borisno2](https://github.com/borisno2)! - Fix three MCP query-tool argument residuals: root `take`/`skip` are now type-checked like the nested selector, root `take: 0` is honoured as zero rows instead of falling back to 10, and the count-only projection path falls back to `0` instead of an unrecognised shape that could carry rows.
2715
+
2716
+ - [#1559](https://github.com/OpenSaasAU/stack/pull/1559) [`b84c28d`](https://github.com/OpenSaasAU/stack/commit/b84c28d2fd5088fdb56a7ba30e719e4f52b57d7d) Thanks [@borisno2](https://github.com/borisno2)! - Fix the row-lock terminal's name in error messages: it now reads `forUpdate().all()`/`forUpdate().first()`, matching the order that actually type-checks.
2717
+
3
2718
  ## 0.43.0
4
2719
 
5
2720
  ### Minor Changes
@@ -257,6 +2972,8 @@
257
2972
 
258
2973
  - [#1000](https://github.com/OpenSaasAU/stack/pull/1000) [`0b5b51e`](https://github.com/OpenSaasAU/stack/commit/0b5b51e52787ea9e945206a109a7a56dc38e78e5) Thanks [@borisno2](https://github.com/borisno2)! - Fix `P2002` unique-constraint errors losing per-field detail under Prisma 7 driver adapters (`@prisma/adapter-pg`, PGlite), where `meta.target` is left empty. The error handler now recovers the violated columns and constraint name from the adapter's error shape, and a new `uniqueConstraintOf(error)` helper exposes this to callers of `context.db.*` directly. Unique-violation messages under driver adapters change from the generic fallback back to field-specific text.
259
2974
 
2975
+ > **Superseded.** The code literal above is dead — the ORM raises no `P`-prefixed codes (ADR-0042). A unique violation now arrives as a stack-owned `UniqueConstraintViolation` carrying the same per-field detail, tested with `isUniqueConstraintViolation(error)`.
2976
+
260
2977
  - [#1001](https://github.com/OpenSaasAU/stack/pull/1001) [`52dfdd2`](https://github.com/OpenSaasAU/stack/commit/52dfdd2c051aa2f4b4cbd96a459213c34c3bf85c) Thanks [@borisno2](https://github.com/borisno2)! - Fix `include` on a to-one relationship throwing `PrismaClientValidationError` when the related list's `query` access resolves to a filter (Prisma only accepts a nested `where` on a to-many include). The relation is now fetched and access-scoped via a batched existence check instead, returning `null` for an excluded related row rather than throwing — a caller relying on the previous exception, or whose types assumed a non-null relation, should re-check nullability.
261
2978
 
262
2979
  ## 0.39.2
@@ -350,6 +3067,7 @@
350
3067
 
351
3068
  Three behavior changes to be aware of when upgrading:
352
3069
 
3070
+ > **Superseded in part.** The precedence rule below still holds, but the error it names does not: the ORM raises no `P`-prefixed codes, so a retry loop written against the code literal quoted below matches nothing (ADR-0042). A serialization failure is now a stack-owned error, tested with `isSerializationFailure(error)`.
353
3071
  - A `context.transaction()` call can now **reject** with `AfterTransactionError` even after its underlying transaction already committed, if a deferred `afterTransaction` hook throws. A transaction/serialization error (e.g. `P2034`) still takes precedence and propagates unwrapped, so an existing `P2034` retry loop is unaffected.
354
3072
  - The deferred `item` a joined write's `afterTransaction` receives on commit is the row **as that write persisted it**, captured at write time — not re-read at flush — so it can be stale if a later write in the same transaction touches the same record.
355
3073
  - Transaction-boundary hooks (`beforeTransaction`/`afterTransaction`) on a joined write now always receive a context bound to the base client, never the transaction client — matching what top-level writes already did.
@@ -1217,6 +3935,8 @@
1217
3935
 
1218
3936
  You can now run multiple access-checked `context.db.*` operations atomically in one transaction while preserving the access/hook boundary (unlike raw `prisma.$transaction`, which bypasses both). The callback receives a full context whose `db.*` operations enforce access control and run list/field hooks, but persist against a single interactive transaction — so a throw anywhere rolls the whole transaction back.
1219
3937
 
3938
+ > **Superseded — do not copy the example below.** This entry records 0.26.0 as it was released; the API it describes is gone. `context.transaction` now takes no options, so the `isolationLevel` argument does not exist (ADR-0042), and the ORM raises no `P`-prefixed error codes, so the `code` comparison in the retry loop below matches nothing — a caller who copies it gets a loop that silently never retries and rethrows every failure on the first pass. Today a serialization failure arrives as a stack-owned error, tested with `isSerializationFailure(error)`, and a capacity gate is written by taking a row lock on the contended parent with `.forUpdate()` before counting, rather than by retrying (ADR-0047). The transaction itself, and the access/hook boundary this entry is really about, still work as described.
3939
+
1220
3940
  Options (notably `isolationLevel`, plus `maxWait`/`timeout`) pass through to Prisma, and serialization failures (Prisma `P2034`) propagate to the caller so you own the retry loop. This makes concurrency-sensitive invariants such as a capacity gate enforceable:
1221
3941
 
1222
3942
  ```typescript