@opensaas/stack-core 0.43.0 → 0.44.0-alpha.2

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 +2753 -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 +1035 -611
  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 +629 -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 +294 -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 +153 -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 +462 -678
  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 +237 -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,2753 @@
1
1
  # @opensaas/stack-core
2
2
 
3
+ ## 0.44.0-alpha.2
4
+
5
+ ### Minor Changes
6
+
7
+ - [#2120](https://github.com/OpenSaasAU/stack/pull/2120) [`ccc2615`](https://github.com/OpenSaasAU/stack/commit/ccc2615a9c0cfdd5e94dcfd7af9e6eb1ab6b450e) Thanks [@borisno2](https://github.com/borisno2)! - Add `db.defaults.timestamp.nativeType`, a config-wide native type for every `timestamp()` column (plugin lists and the auto `createdAt` included). A field's own `db.nativeType` wins. `updatedAt` is not affected.
8
+
9
+ ```typescript
10
+ export default config({
11
+ db: { provider: 'postgresql', defaults: { timestamp: { nativeType: 'Timestamp(3)' } } },
12
+ lists: {},
13
+ })
14
+ ```
15
+
16
+ - [#2118](https://github.com/OpenSaasAU/stack/pull/2118) [`289ed00`](https://github.com/OpenSaasAU/stack/commit/289ed00fac642628d0b1d8db77a2eee0f3096101) Thanks [@borisno2](https://github.com/borisno2)! - Add list-level `db.foreignKeys` for composite (multi-column) foreign key constraints that reference a composite unique on the target. Constraint-only: no relationship or include semantics.
17
+
18
+ ```ts
19
+ db: {
20
+ foreignKeys: [
21
+ {
22
+ fields: ['enrolment', 'student', 'lessonTerm'],
23
+ references: { list: 'Enrolment', fields: ['id', 'student', 'lessonTerm'] },
24
+ onDelete: 'restrict',
25
+ },
26
+ ],
27
+ }
28
+ ```
29
+
30
+ `db.indexes` also accepts `'id'` so a composite unique can include the primary key.
31
+
32
+ ### Patch Changes
33
+
34
+ - [#2124](https://github.com/OpenSaasAU/stack/pull/2124) [`bcd16e1`](https://github.com/OpenSaasAU/stack/commit/bcd16e1e46f8ca9fecbb5431791dd4675c160b9e) Thanks [@borisno2](https://github.com/borisno2)! - Quote every import specifier the generator writes and refuse a `db.extensions[].from` that is not a package name.
35
+
36
+ ## 0.44.0-alpha.1
37
+
38
+ ### Minor Changes
39
+
40
+ - [#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.
41
+
42
+ ```typescript
43
+ db: {
44
+ indexes: [{ fields: ['twilioSid'], unique: true, where: `("twilioSid" <> ''::text)` }],
45
+ }
46
+ ```
47
+
48
+ - [#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.
49
+
50
+ - [#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.
51
+
52
+ ```typescript
53
+ export default config({ db: { provider: 'postgresql', idField: 'cuid' }, lists: {} })
54
+ ```
55
+
56
+ ### Patch Changes
57
+
58
+ - [#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.
59
+
60
+ - [#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.
61
+
62
+ - [#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.
63
+
64
+ - [#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'`.
65
+
66
+ - [#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.
67
+
68
+ - [#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.
69
+
70
+ - [#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.
71
+
72
+ - [#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`).
73
+
74
+ - [#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.
75
+
76
+ - [#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)).
77
+
78
+ - [#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.
79
+
80
+ - [#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.
81
+
82
+ - [#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.
83
+
84
+ ## 0.44.0-alpha.0
85
+
86
+ ### Minor Changes
87
+
88
+ - [#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
89
+
90
+ A write payload's `field: { connect: { id } }` is lowered onto the column the
91
+ row actually carries. The terminal issues the reachability query first — the
92
+ target list's `query` access ANDed with the identity criterion — then writes
93
+ the scalar foreign key, both inside the terminal's origin. `field: null`
94
+ clears the same column, which is what replaces nested `disconnect`
95
+ (ADR-0050).
96
+
97
+ ```typescript
98
+ await context.db.Post.create({ data: { title: 'Hello', author: { connect: { id: userId } } } })
99
+ await context.db.Post.update({ where: { id }, data: { author: null } })
100
+ ```
101
+
102
+ An unreadable target and one that does not exist are the same answer: the
103
+ write returns `null`, with no error and nothing written, so a foreign key
104
+ cannot become a probing oracle.
105
+
106
+ Three refusals name what a payload may carry on a relationship key:
107
+
108
+ - `NonOwningRelationInputError` — relation input on a field that owns no
109
+ foreign key (an inverse to-many, the non-owning half of a one-to-one, a
110
+ junction list's inverse, a synthetic back-relation). The generated input
111
+ types carry no member for those, so this is the runtime half of a compile
112
+ error.
113
+ - `MalformedRelationInputError` — an owning field carrying neither
114
+ `{ connect: { id } }` nor `null`.
115
+ - `RelationTargetMissingError` — a `connect` whose ref names a list the config
116
+ does not declare.
117
+
118
+ The relationship table's remove control follows the same rule: removing a row
119
+ through a to-one back-reference assigns `null` to it and the row survives,
120
+ while removing a junction row deletes it under that list's own delete access.
121
+
122
+ A relationship whose foreign key lives on the related row — a to-many, or the
123
+ non-owning half of a one-to-one — is not writable through the surfaces that
124
+ carry a payload for a single row, so neither surface offers it any more:
125
+
126
+ - The admin item form renders it read-only, stating that the related record
127
+ holds the link, instead of a picker whose selection had nowhere to go. An
128
+ item form ignores a change for any field it rendered read-only, so a field
129
+ component that does not honour the read mode it is handed cannot stage a
130
+ value the submit transform would then have to drop.
131
+ - The standalone `ItemCreateForm` / `ItemEditForm` take optional `listKey` and
132
+ `config` props. Given both, they mark the non-owning half of a one-to-one
133
+ the same way — a field config alone cannot answer which end holds the
134
+ column, so without them that end still renders a picker whose selection the
135
+ engine refuses at save.
136
+ - The MCP create/update tools omit it from the advertised `data` properties,
137
+ so a client cannot spell a call that could only fail.
138
+
139
+ On the end that does hold the column, the MCP schema now advertises `null`
140
+ alongside `connect`, so both spellings of an edge the engine accepts are
141
+ describable through the tool surface — and only those: the object form
142
+ requires `connect`, requires `id` within it, and admits no other key, matching
143
+ what the engine lowers rather than leaving the difference to prose.
144
+
145
+ - [#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
146
+
147
+ `checkAccess`, `mergeFilters` and `checkCreateAccess` — the operation-level
148
+ access primitives — are now supported API on `@opensaas/stack-core`, with TSDoc. A
149
+ package that reads outside `context.db` (a vector search issuing its own SQL, a
150
+ plugin composing a filter) imports them instead of carrying a copy that drifts
151
+ from the engine's own evaluation (ADR-0038, ADR-0057):
152
+
153
+ ```typescript
154
+ import { checkAccess, mergeFilters } from '@opensaas/stack-core'
155
+
156
+ const result = await checkAccess(config.lists.Post.access?.operation?.query, {
157
+ session: context.session,
158
+ context,
159
+ })
160
+
161
+ // `null` is the Silent failure signal: denied, so do not query at all.
162
+ const where = mergeFilters(callerWhere, result)
163
+ if (where === null) return []
164
+ ```
165
+
166
+ An absent rule denies. A filter result is ANDed with the caller's `where`, never
167
+ merged key-by-key, so it can only ever narrow what the caller asked for. Gate a
168
+ `create` with `checkCreateAccess`, which refuses a filter result rather than
169
+ reading it as an allow (ADR-0030). All three scope rows, not fields: field-level
170
+ `read` access runs inside `context.db`, so a caller reading outside it is
171
+ responsible for field visibility itself.
172
+
173
+ `@opensaas/stack-rag` drops its own copies of both — the ones ADR-0038 names as
174
+ the reason this export exists — and calls core's. Behaviour is unchanged;
175
+ `buildAccessControlFilter`, `mergeAccessFilter` and `prismaFilterToSQL` keep
176
+ their signatures.
177
+
178
+ - [#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`
179
+
180
+ 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.
181
+
182
+ ```typescript
183
+ // Before
184
+ const posts = await context.prisma.post.findMany()
185
+
186
+ // After — the ORM lane, behind a transparent proxy that marks every call
187
+ const posts = await context.unsafe.orm.public.Post.all()
188
+
189
+ // Rows, streamed, from a typed SQL plan
190
+ const rows = context.unsafe.query(context.unsafe.sql.public.Post.select('id').build())
191
+ for await (const row of rows) {
192
+ // consumed after the scope closed, still marked
193
+ }
194
+
195
+ // Statistics from a raw statement
196
+ const stats = await context.unsafe.execute(
197
+ context.unsafe.raw.sql`UPDATE "public"."Post" SET "published" = true`.affectedCount().build(),
198
+ )
199
+ ```
200
+
201
+ `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.
202
+
203
+ 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.
204
+
205
+ 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.
206
+
207
+ - [#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
208
+
209
+ `extendList`'s hook merge copied only `resolveInput`, `validateInput`, `beforeOperation`
210
+ and `afterOperation`. When a list declared any hook itself, every other kind a plugin
211
+ added — `validate`, `beforeTransaction`, `afterTransaction` — was dropped on the floor, so
212
+ the plugin's side of the list silently stopped running:
213
+
214
+ ```typescript
215
+ Article: list({
216
+ fields: { content: searchable(text()) },
217
+ // Before: this one hook made ragPlugin's afterTransaction disappear, and the
218
+ // row was persisted with a null embedding, with nothing said.
219
+ hooks: { resolveInput: async ({ resolvedData }) => resolvedData },
220
+ })
221
+ ```
222
+
223
+ All hook kinds now merge, the list's own running first and the plugin's after it — the
224
+ order `resolveInput` already used.
225
+
226
+ - [#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
227
+
228
+ `splitMultiColumnFields` — the phase that turns a multi-column field's logical value into
229
+ its physical columns — dropped the key and continued when field-level write access denied
230
+ it, so the write "succeeded" while doing less than asked. `filterWritableFields` has
231
+ thrown for a denied single-column field since [#568](https://github.com/OpenSaasAU/stack/issues/568); this brings the multi-column path in
232
+ line with it.
233
+
234
+ ```typescript
235
+ // A field whose write is denied — @opensaas/stack-storage's multi-column
236
+ // image()/file(), or @opensaas/stack-rag's embedding()
237
+ await context.db.Article.update({
238
+ where: { id },
239
+ data: { contentEmbedding: myVector },
240
+ })
241
+ // Before: resolved successfully, and the vector was discarded.
242
+ // Now: throws ValidationError
243
+ // 'Cannot update "contentEmbedding": field-level access denied.'
244
+ ```
245
+
246
+ Sudo is unchanged: `checkFieldAccess` returns `true` under sudo, so an elevated write never
247
+ reaches the throw. A caller that relied on the silent drop to pass a denied field through
248
+ an ordinary write must stop sending the key, or write under `sudo()`.
249
+
250
+ - [#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
251
+
252
+ 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.
253
+
254
+ - `@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.
255
+ - `@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.
256
+
257
+ An app on this line installs the family alongside the stack:
258
+
259
+ ```bash
260
+ pnpm add @prisma/orm-postgres@8.0.0-rc.8
261
+ pnpm add -D prisma@8.0.0-rc.12
262
+ ```
263
+
264
+ 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.
265
+
266
+ - [#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
267
+
268
+ 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`.
269
+
270
+ 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`).
271
+
272
+ - [#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
273
+
274
+ 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.
275
+
276
+ ```typescript
277
+ config({
278
+ db: { provider: 'postgresql' },
279
+ lists: {},
280
+ onAfterTransactionError: ({ error, status, listKey, operation }) => {
281
+ logger.error({ error, status, listKey, operation }, 'afterTransaction failed')
282
+ },
283
+ })
284
+ ```
285
+
286
+ Migration: `AfterTransactionError` is no longer thrown or exported, so code matching `error.name === 'AfterTransactionError'` should move that handling into `onAfterTransactionError`.
287
+
288
+ - [#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
289
+
290
+ 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.
291
+
292
+ ```typescript
293
+ import { transitionGuard } from '@opensaas/stack-core'
294
+
295
+ hooks: {
296
+ validate: transitionGuard({
297
+ field: 'state',
298
+ discriminator: 'action',
299
+ initial: { EDIT: ['PREPARED'] },
300
+ allowed: { EDIT: { PREPARED: ['DISPATCHING'] } },
301
+ }),
302
+ }
303
+ ```
304
+
305
+ - [#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
306
+
307
+ `@opensaas/stack-rag` was built and documented while the secured write surface could not
308
+ execute on the Prisma 8 collection, so the plugin's escalated write threw on every
309
+ invocation. That surface now executes, and generation with it:
310
+ `context.db.Article.create({ data: { content } })` commits the row, and once that
311
+ transaction settles the plugin embeds the **persisted** source text and writes the vector
312
+ and its metadata past that field's own write denial. Writing the source text again
313
+ regenerates it; a write that leaves the source text alone does not, because the
314
+ `sourceHash` on the stored metadata short-circuits.
315
+
316
+ Everything written for the inert surface is gone with it:
317
+
318
+ - `generation-failure.ts` no longer classifies "the secured write surface has not been
319
+ ported" as a standing defect. The predicate matched
320
+ `findUnique is not a function` / `Unknown column "data"`, neither of which the write
321
+ pipeline can now raise, and the branch logged
322
+ `EMBEDDING GENERATION IS NOT RUNNING … No config change works around it` — a false
323
+ statement to a user. A provider `type` no factory answers to is still reported as
324
+ standing; everything else is still reported per occurrence as transient.
325
+ - The write denial and the search helpers are tested through `context.db` rather than
326
+ through `hookPipeline`, and every vector under assertion is one the generation hook
327
+ produced from source text written through the same surface. `allowManualWrites` is
328
+ asserted by reading the columns back rather than by inspecting resolved data.
329
+
330
+ `hookPipeline` is no longer exported from `@opensaas/stack-core/internal`. It was added
331
+ there so `@opensaas/stack-rag` could prove its write denial one layer below
332
+ `context.db`, which was the deepest seam that then existed; nothing depends on it now.
333
+ That path carries no semver guarantee and the export was never released.
334
+
335
+ `allowManualWrites` remains the deliberate opt-out for an application that maintains its
336
+ own vectors — it is not a workaround for anything:
337
+
338
+ ```typescript
339
+ manualVector: embedding({ dimensions: 1536, allowManualWrites: true })
340
+ ```
341
+
342
+ Core's multi-column write-access gate is now also proven through `context.db`: a denied
343
+ create or update throws naming the field and leaves the per-part columns untouched, a
344
+ granted one writes both, `sudo()` bypasses the gate, and clearing the field with `null`
345
+ clears both columns.
346
+
347
+ - [#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
348
+
349
+ The Write Pipeline decided whether to open a transaction by probing the client
350
+ for `$transaction` — the Prisma 7 name, which no Prisma 8 object carries. The
351
+ guard was constant-false, so every write ran with no transaction and no
352
+ rollback guarantee: a multi-statement write that failed partway, or a hook that
353
+ threw after the database call, left its rows committed.
354
+
355
+ The transaction capability is now an explicit signal rather than a probed
356
+ method name. `getContext` resolves a `TransactionOpener` from the Prisma 8
357
+ client it is handed, and puts it on the context; a context that is already
358
+ bound to an open transaction — `context.transaction()`'s callback, a hook's
359
+ rebound context — carries none, so a joined write still joins the enclosing
360
+ transaction rather than opening a second one (ADR-0028). `context.transaction()`
361
+ opens through the same opener, so both paths share one mechanism.
362
+
363
+ The generated context now hands `getContext` the ORM handle rather than the
364
+ client, which is what the engine reaches models through:
365
+
366
+ ```typescript
367
+ // .opensaas/context.ts (generated)
368
+ getOpensaasContext(
369
+ config,
370
+ ormHandleFor(config, db),
371
+ session,
372
+ storage,
373
+ false,
374
+ undefined,
375
+ undefined,
376
+ db,
377
+ )
378
+ ```
379
+
380
+ `requireOrmHandle(config, orm)` is exported from `@opensaas/stack-core` for a
381
+ caller that builds a context over a Prisma 8 client of its own, and throws
382
+ `OrmHandleUnresolvableError` naming the list whose collection the client does
383
+ not expose.
384
+
385
+ A context built over a Prisma 8 client whose collections do not cover the
386
+ config now refuses at construction rather than quietly downgrading its writes
387
+ to non-transactional. This widens the blast radius of contract drift: before,
388
+ a list the client couldn't reach only errored when that list was actually
389
+ used (`OrmModelMissingError`, lazily, per operation) while every other list
390
+ kept working; now the whole context fails to build — no list is usable —
391
+ the moment any one of them is unresolvable. Reviewers judged that the right
392
+ trade for [#1262](https://github.com/OpenSaasAU/stack/issues/1262): a context that can silently downgrade every write's
393
+ atomicity is a worse failure mode than refusing outright, and contract drift
394
+ this severe should fail loudly rather than only on the paths a test happens
395
+ to exercise.
396
+
397
+ `context.transaction()` over a client that can neither open a transaction nor
398
+ join one throws `TransactionUnavailableError` instead of running the callback
399
+ with no atomicity. A context assembled from a hand-built ORM double —
400
+ `getContext` called without its `client` argument — still writes directly
401
+ against that double, with no such terminal to refuse from; it now warns once
402
+ per list and operation via `console.warn` instead of staying silent.
403
+
404
+ - [#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:
405
+
406
+ ```typescript
407
+ import { getPluginData } from '@opensaas/stack-core'
408
+ import type { NormalizedAuthConfig } from '@opensaas/stack-auth'
409
+
410
+ const resolvedConfig = await config
411
+ const authConfig = getPluginData<NormalizedAuthConfig>(resolvedConfig, 'auth')
412
+ ```
413
+
414
+ `@opensaas/stack-auth`'s `buildBetterAuthOptions` and the core MCP handler's plugin-tool lookup both adopt it in place of their own casts.
415
+
416
+ - [#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
417
+
418
+ `.opensaas/types.ts` no longer re-derives every scalar type, nullability and
419
+ relation arity by hand. It writes one `Remainder` entry per list — the four
420
+ facts the emitted Contract artifacts cannot carry — and names one interface per
421
+ shape extending a generic `@opensaas/stack-core` now exports, keyed by the
422
+ emitted `Contract`:
423
+
424
+ ```typescript
425
+ export type Remainder = {
426
+
427
+ computed: { displayName: string }
428
+ output: { secret: import('@opensaas/stack-core/internal').HashedPassword }
429
+ input: Record<never, never>
430
+ needs: { displayName: 'name' }
431
+ }
432
+ Settings: {
433
+ computed: Record<never, never>
434
+ output: Record<never, never>
435
+ input: Record<never, never>
436
+ needs: Record<never, never>
437
+ singleton: true
438
+ }
439
+ }
440
+
441
+ export interface User extends Stack$Row<Stack$Contract, Remainder, 'User'> {}
442
+ export interface UserCreateInput extends Stack$CreateInput<Stack$Contract, Remainder, 'User'> {}
443
+ export interface UserUpdateInput extends Stack$UpdateInput<Stack$Contract, Remainder, 'User'> {}
444
+ export interface UserList extends Stack$SecuredList<Stack$Contract, Remainder, 'User'> {}
445
+
446
+ export interface Context<TSession extends Stack$Session = Stack$Session> extends Stack$StackContext<
447
+ DB,
448
+ TSession,
449
+ Stack$PluginServices
450
+ > {}
451
+ ```
452
+
453
+ Everything the file imports is aliased behind `Stack$`, so a list may be named
454
+ `Row`, `Contract` or `Session` without shadowing the generic its own interface
455
+ is declared from. Only what is used is imported, so a bundle compiled under
456
+ `noUnusedLocals` stays clean.
457
+
458
+ `Post`, `PostCreateInput`, `PostUpdateInput`, `Context`, `BaseContext`,
459
+ `TransactionContext` and `Lists.Post.TypeInfo` keep their names, so imports do
460
+ not change. What changes is what they mean:
461
+
462
+ - **An included to-one relation reads `| null`, a to-many `[]`** — by arity
463
+ alone, whatever the foreign key's nullability. Access control can scope the
464
+ related row away, so code that dereferenced a required relation without a
465
+ check now fails `tsc`.
466
+ - **A virtual field's `resolveOutput` hook receives exactly its declared
467
+ `needs` plus the list's system fields.** Reading an undeclared column is a
468
+ compile error for any hook authored under `list<Lists.Post.TypeInfo>`:
469
+
470
+ ```typescript
471
+ excerpt: virtual({
472
+ type: 'string',
473
+ needs: ['content'],
474
+ hooks: {
475
+ resolveOutput: ({ item }) => item.content.slice(0, 100), // compiles
476
+ // resolveOutput: ({ item }) => item.title, // tsc error
477
+ },
478
+ })
479
+ ```
480
+
481
+ The set is the one `deriveDependencyTable` resolves for the runtime
482
+ (ADR-0051), not the declaration as written, so **a `needs` naming a
483
+ relationship yields a different `item` type than before**: it now carries the
484
+ foreign-key column this side owns as well as the relation, matching what the
485
+ widening actually fetches.
486
+
487
+ ```typescript
488
+ byline: virtual({
489
+ type: 'string',
490
+ needs: ['author'],
491
+ hooks: {
492
+ // `authorId` is now on `item`; previously only `author` was.
493
+ resolveOutput: ({ item }) => `${item.author?.name ?? '?'} (${item.authorId})`,
494
+ },
495
+ })
496
+ ```
497
+
498
+ A `needs` entry naming a field the list does not have is dropped rather than
499
+ typed, the list's system fields are its actual ones (a list with
500
+ `db.timestamps: false` carries only `id`), and only a **virtual** field gets
501
+ this narrowed `item` — a stored field's `resolveOutput` still sees the whole
502
+ row, which is what the runtime hands it.
503
+
504
+ - **A write input is checked against the contract's columns.** A system-filled
505
+ column (`id`, `createdAt`, `updatedAt`) is not writable, a non-nullable column
506
+ with no default is required on create, and an unknown key is rejected.
507
+ - **Every write terminal admits silent denial.** `create` returns
508
+ `Row | null`, and `createMany` / `updateMany` — which run one secured write
509
+ per item — return `(Row | null)[]`, so a partially denied batch is visible in
510
+ the type. Code that used a create result without checking now fails `tsc`:
511
+
512
+ ```typescript
513
+ const post = await context.db.post.create({ data })
514
+ if (!post) return { error: 'Access denied' }
515
+ ```
516
+
517
+ - Every per-list `GetPayload`, `Select`, `Include`, `WhereInput`, `*Args`,
518
+ `VirtualFields`, `TransformedFields` and `{List}Crud` type is gone;
519
+ `CustomDB` is now `DB`.
520
+
521
+ Resolving a list's model off the ORM client now **throws**
522
+ `OrmModelMissingError` where the client carries no delegate for it. The
523
+ previous behaviour degraded silently in one place: a nested write's
524
+ pre-existing-id capture treated a missing parent delegate as "no pre-existing
525
+ ids", so a disconnect that should have been reported instead ran against an
526
+ empty set. A real client always carries the delegate, so this surfaces on test
527
+ doubles — give the double the model, or use a client whose model keys match the
528
+ config's list names in `getDbKey` form (`AuthUser` → `authUser`):
529
+
530
+ ```typescript
531
+ // Before: a double missing `post` silently captured nothing
532
+ const prisma = { user: userDouble }
533
+ // After: give it the delegate the config declares
534
+ const prisma = { user: userDouble, post: postDouble }
535
+ ```
536
+
537
+ `PrismaClientLike = any` is deleted. `context.prisma` is `OrmClient`, a
538
+ structural interface, and `AccessContext`, `StackContext` and
539
+ `AccessControlledDB` lose their `TPrisma` type parameter — drop the argument:
540
+
541
+ ```typescript
542
+ // Before
543
+ function render(context: AccessContext<unknown>) {}
544
+ // After
545
+ function render(context: AccessContext) {}
546
+ ```
547
+
548
+ `OrmClient`, `OrmRow` and `OrmOperationArgs` are deliberately untyped
549
+ (`Record<string, unknown>` and an index signature). The unsecured surface's
550
+ shape depends on the config's list names, so the typed surface is the generated
551
+ bundle's `DB` and `Row`; `unknown` here forces a narrow at each use where the
552
+ `any` it replaces did not. Use `context.db` when you want types.
553
+
554
+ `StackContext`'s first parameter is now the generated `db` surface, not the
555
+ client, and refuses one: a stale `StackContext<MyPrismaClient>` fails its
556
+ constraint rather than silently meaning `db: MyPrismaClient`.
557
+
558
+ `pnpm generate` now refuses two configs it used to emit uncompilable code for:
559
+ a virtual field with no declared `outputType`, and two lists whose generated
560
+ names collide (`Post` and `PostList` both want `PostList`). Both errors name the
561
+ list and field involved.
562
+
563
+ The bundle's type-only import of the emitted declarations is now
564
+ `'../prisma/contract.d.js'`. `'../prisma/contract.d.ts'` resolved to the
565
+ Contract module sitting beside it, so `Contract` was not among the exports the
566
+ import found; re-run `pnpm generate`.
567
+
568
+ - [#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
569
+
570
+ A field whose access rule the session alone decides — a rule that never reaches
571
+ into the row or the payload — and which denies, no longer appears in what MCP
572
+ advertises: not in the `query` tool's `fields` projection at either level, and
573
+ not in the `create`/`update` tools' `data` schemas. A rule that does reach into
574
+ the row stays advertised, because it may pass for rows the session owns.
575
+
576
+ ```typescript
577
+ Memo: list({
578
+ fields: {
579
+ title: text(),
580
+ // Row-independent: never advertised to a non-admin session.
581
+ internal: text({ access: { read: () => false, update: () => false } }),
582
+ // Row-dependent: stays advertised to everyone.
583
+ ownerNotes: text({
584
+ access: { read: ({ session, item }) => item?.ownerId === session?.userId },
585
+ }),
586
+ },
587
+ })
588
+ ```
589
+
590
+ A list whose `create` needs a field the session can never write no longer
591
+ advertises a `create` tool at all, rather than offering one that refuses every
592
+ call. Naming a field the schema withheld — including a relation whose target
593
+ list this session cannot reach — is refused with the same message an unknown
594
+ field name gets, so the refusal discloses nothing the schema held back.
595
+
596
+ A field rule that throws while `tools/list` decides whether to advertise the
597
+ field costs that one field its advertisement rather than the whole listing, and
598
+ is reported on the server console. The rule still throws when the field is
599
+ actually read or written.
600
+
601
+ Classification runs per session and is not cached. No configuration is
602
+ required — the behaviour follows from the field-level access rules already in
603
+ your config.
604
+
605
+ - [#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
606
+
607
+ The Prisma 7 read names outlived the client that could serve them: every one of
608
+ them type-checked and then threw `TypeError: … is not a function`, under `sudo`
609
+ too. Reaching for one is now a compile error rather than a runtime failure.
610
+
611
+ ```typescript
612
+ // Before
613
+ const posts = await context.db.Post.findMany({ where: { published: { equals: true } } })
614
+ const post = await context.db.Post.findUnique({ where: { id } })
615
+ const first = await context.db.Post.findFirst({ where: { slug: { equals: slug } } })
616
+ const total = await context.db.Post.count()
617
+
618
+ // After
619
+ const posts = await context.db.Post.where({ published: { equals: true } }).all()
620
+ const post = await context.db.Post.where({ id }).first()
621
+ const first = await context.db.Post.where({ slug: { equals: slug } }).first()
622
+ const { total } = await context.db.Post.aggregate((aggregate) => ({ total: aggregate.count() }))
623
+ ```
624
+
625
+ A singleton's `get()` is unchanged in shape and now resolves through the same
626
+ composed read an ordinary list reads through, so its operation access, Access
627
+ Filter, Field Visibility and related-list `query` access are the engine's rather
628
+ than a second copy of them.
629
+
630
+ Its auto-create is also tightened on a security path. `get()` previously fired
631
+ the auto-create for any `query` rule that did not answer a strict `false`, so a
632
+ rule that answered a **filter** — a first-class form, used to scope a read —
633
+ fell through it. On an absent row that created the singleton and handed it to a
634
+ session the filter excluded; on a present row it reached the singleton-create
635
+ constraint's unscoped row count and threw
636
+ `Cannot create: … is a singleton list with an existing record`, turning a read
637
+ whose whole design is silent failure into an existence oracle. The auto-create
638
+ now fires only for a rule that answered a strict `true` (or under `sudo`), and
639
+ the created row is handed back through the composed read rather than raw. Every
640
+ other form — `false`, a filter, a missing rule — answers the same `null` an
641
+ absent row answers, writes nothing, and raises nothing; a rule that throws still
642
+ propagates.
643
+
644
+ If you relied on a filter-returning `query` rule auto-creating a singleton, give
645
+ that list a `query` rule that answers `true` and scope it with the Access Filter
646
+ on the fields instead.
647
+
648
+ - [#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
649
+
650
+ 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:
651
+
652
+ - `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.
653
+
654
+ ```typescript
655
+ // Before
656
+ export default config({
657
+ output: { buildTarget: 'node' },
658
+ // ...
659
+ })
660
+
661
+ // After
662
+ export default config({
663
+ // ...
664
+ })
665
+ ```
666
+
667
+ A plain-Node consumer imports the bundle entry directly:
668
+
669
+ ```typescript
670
+ const { rawOpensaasContext } = await import('./.opensaas/context.ts')
671
+ ```
672
+
673
+ - 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).
674
+
675
+ 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.
676
+
677
+ `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.
678
+
679
+ - [#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`
680
+
681
+ 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.
682
+
683
+ `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.
684
+
685
+ ```typescript
686
+ // Before
687
+ const plugin = {
688
+ runtime: (context) => ({
689
+ getAuditTrail: (listName: string) =>
690
+ context.prisma.auditLog.findMany({ where: { listName } }),
691
+ }),
692
+ }
693
+
694
+ // After
695
+ const plugin = {
696
+ runtime: (context) => ({
697
+ getAuditTrail: (listName: string) =>
698
+ context.ormHandle.auditLog.findMany({ where: { listName } }),
699
+ }),
700
+ }
701
+ ```
702
+
703
+ 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.
704
+
705
+ `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`.
706
+
707
+ - [#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).
708
+
709
+ ```typescript
710
+ export default config({
711
+ db: {
712
+ provider: 'postgresql',
713
+ idField: 'uuid7', // the default; 'cuid2' | 'int autoincrement'
714
+ extensions: [{ name: 'pgvector', from: '@prisma/orm-extension-pgvector' }],
715
+ client: {
716
+ pg: () => new Pool({ connectionString: process.env.DATABASE_URL }), // a lazy factory
717
+ },
718
+ },
719
+ lists: {
720
+ Invoice: list({
721
+ fields: {
722
+ customer: relationship({ ref: 'Customer.invoices', db: { onDelete: 'restrict' } }),
723
+ },
724
+ db: {
725
+ idField: 'int autoincrement',
726
+ indexes: [{ fields: ['customer'], name: 'Invoice_customer_idx' }],
727
+ },
728
+ }),
729
+ },
730
+ })
731
+
732
+ // A plugin declares the pack its field types need; the same name from the same
733
+ // package merges, the same name from a different package throws.
734
+ init: async (context) => {
735
+ context.addExtension({ name: 'pgvector', from: '@prisma/orm-extension-pgvector' })
736
+ }
737
+ ```
738
+
739
+ `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.
740
+
741
+ `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`.
742
+
743
+ - [#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
744
+
745
+ 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.
746
+
747
+ ```typescript
748
+ const result = await context.transaction(async (tx) => {
749
+ // The lock comes BEFORE both reads below. `null` here is denied-or-gone —
750
+ // either way there is no gate to run.
751
+ const held = await tx.db.Slot.where({ id: { equals: slotId } })
752
+ .forUpdate()
753
+ .first()
754
+ if (held === null) return { booked: false }
755
+
756
+ // BOTH sides of the gate are read after the lock, each in its own statement.
757
+ // `held`'s own columns are the row as of BEFORE the lock was granted, so
758
+ // `held.capacity` can be stale; this re-read cannot be, because no one else
759
+ // can commit an update to a row this transaction holds.
760
+ const slot = await tx.db.Slot.where({ id: { equals: slotId } }).first()
761
+ const { taken } = await tx.db.Booking.where({ slotId: { equals: slotId } }).aggregate(
762
+ (aggregate) => ({ taken: aggregate.count() }),
763
+ )
764
+ if (slot === null || taken >= slot.capacity) return { booked: false }
765
+
766
+ return { booked: true, item: await tx.db.Booking.create({ data: { slotId, holder } }) }
767
+ })
768
+ ```
769
+
770
+ **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.
771
+
772
+ `.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.
773
+
774
+ 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.
775
+
776
+ `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.
777
+
778
+ 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.
779
+
780
+ `tx.advisoryLock(key)` joins it on the transaction context, for an invariant that is not a row:
781
+
782
+ ```typescript
783
+ await context.transaction(async (tx) => {
784
+ await tx.advisoryLock(`checkout:${cartId}`)
785
+ // …
786
+ })
787
+ ```
788
+
789
+ 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.
790
+
791
+ See ADR-0047 and ADR-0062.
792
+
793
+ - [#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.
794
+
795
+ 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.
796
+
797
+ 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):
798
+
799
+ ```sql
800
+ ALTER TABLE "Post" RENAME COLUMN "author" TO "authorId";
801
+ ```
802
+
803
+ 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.
804
+
805
+ 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:
806
+
807
+ ```typescript
808
+ await context.db.User.include('posts', (posts) => posts.include('author')).all()
809
+ ```
810
+
811
+ - [#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
812
+
813
+ Nested `set`, `updateMany` and `deleteMany` under a relationship key used to
814
+ reach the database as an unchecked pass-through: the target list's access was
815
+ never consulted, no hooks ran, and an unscoped `where` could reach rows well
816
+ outside the parent's own subtree. Nested `disconnect` could name a target row
817
+ the caller could not read.
818
+
819
+ Both are closed here by ADR-0050 rather than by per-kind access machinery:
820
+ `create`, `update`, `delete`, `connectOrCreate`, `disconnect`, `set`,
821
+ `updateMany` and `deleteMany` under a relationship key are refused with
822
+ `NestedRelationInputError`. `connect` is not among them — it lowers onto a
823
+ foreign-key column the row being written owns, and survives unchanged. The
824
+ refusal is unconditional — `sudo()` does not lift it — which is strictly
825
+ stronger than the interim non-sudo-only refusal [#1385](https://github.com/OpenSaasAU/stack/issues/1385) shipped on the previous
826
+ line.
827
+
828
+ Clearing an edge is `null` on the relationship field **that owns the foreign
829
+ key**. On a field that owns none — a to-many, the non-owning half of a
830
+ one-to-one, a synthetic back-relation — `null` is refused in turn with
831
+ `NonOwningRelationInputError`, exactly as `connect` is there, so clearing that
832
+ edge is an update against the target list:
833
+
834
+ ```typescript
835
+ // `Author.posts` owns no column, so the write goes to `Post`:
836
+ await context.db.Post.update({ where: { id: postId }, data: { author: null } })
837
+ ```
838
+
839
+ Every other refused kind is likewise a write against the target list, wrapped in
840
+ `context.transaction()` when it must land atomically.
841
+
842
+ See `rugged-terminals-persist.md` for the full write-surface change.
843
+
844
+ - [#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
845
+
846
+ 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.
847
+
848
+ 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.
849
+
850
+ 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.
851
+
852
+ `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:
853
+
854
+ ```jsonc
855
+ {
856
+ "where": { "title": { "contains": "release" }, "comments": { "some": { "approved": true } } },
857
+ "orderBy": { "title": "asc" },
858
+ "fields": {
859
+ "title": true,
860
+ "comments": {
861
+ "fields": { "body": true },
862
+ "where": { "approved": true },
863
+ "take": 5,
864
+ "count": true,
865
+ },
866
+ },
867
+ }
868
+ ```
869
+
870
+ 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.
871
+
872
+ `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.
873
+
874
+ 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.
875
+
876
+ - [#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
877
+
878
+ `@opensaas/stack-core/dev-database` exports `startDevDatabase()`, which starts an
879
+ in-process PGlite behind a socket server on a free loopback TCP port and publishes
880
+ it in a state file (URL and pid) under the Generated bundle directory, so that the
881
+ app, a seed script and a second-terminal `db update` all find it through the same
882
+ lookup instead of an injected variable (ADR-0063). PGlite and its socket and
883
+ pgvector packages are optional peers, imported only when the primitive is called.
884
+
885
+ ```typescript
886
+ import { startDevDatabase } from '@opensaas/stack-core/dev-database'
887
+
888
+ const database = await startDevDatabase({
889
+ dataDir: '.opensaas/dev-db',
890
+ extensions: ['vector'],
891
+ })
892
+ // ... database.url, database.port
893
+ await database.stop()
894
+ ```
895
+
896
+ `stop()` is idempotent — a `SIGINT` handler and a `finally` may both call it — and drops
897
+ the state file only once the socket server and PGlite are actually released. A failure
898
+ anywhere in startup tears down whatever was already constructed, so no port is left
899
+ bound. An IPv6 `host` is bracketed into the published URL.
900
+
901
+ `resolveDatabaseUrl()` now returns `{ url, provenance }` rather than a bare string,
902
+ and consults the dev database state file when the environment names no connection.
903
+ `provenance` is `'env'` for `DATABASE_URL`/`DIRECT_DATABASE_URL` and `'dev-database'`
904
+ for the state file; with neither it throws, naming both remedies. Callers that want
905
+ just the string take `.url`; `findDatabaseUrl()`, which the generated
906
+ `prisma.config.ts` uses, is unchanged in shape and still non-throwing.
907
+
908
+ ```typescript
909
+ // Before
910
+ const url = resolveDatabaseUrl()
911
+
912
+ // After
913
+ const { url, provenance } = resolveDatabaseUrl()
914
+ ```
915
+
916
+ - [#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
917
+
918
+ `context.db.<List>` is now spelled the way the config spells the list — `context.db.AuthUser`, not
919
+ `context.db.authUser` — and `getDbKey()` is deleted (`getUrlKey()` and `getListKeyFromUrl()` stay).
920
+ Every call site through the secured surface, and every ORM handle the engine reaches a model
921
+ through, moves to the list key.
922
+
923
+ ```typescript
924
+ // Before
925
+ const posts = await context.db.blogPost.findMany()
926
+
927
+ // After
928
+ const posts = await context.db.BlogPost.findMany()
929
+ ```
930
+
931
+ The same member is now also a query value: `.where(...)` composes an immutable read and `.all()` /
932
+ `.first()` are the terminals that run it. A terminal resolves operation-level `query` access, adds
933
+ the access filter as a second entry in the collection's own filter list (nothing is hand-merged),
934
+ enters the engine origin around the ORM call, applies Field Visibility, and returns `[]` / `null`
935
+ on denial — indistinguishable from an empty result.
936
+
937
+ ```typescript
938
+ const mine = await context.db.Post.where({ published: true }).all()
939
+ const first = await context.db.Post.where({ authorId: session.userId }).first()
940
+ ```
941
+
942
+ `where` takes an equality predicate (`{ column: value }` or `{ column: { equals: value } }`); an
943
+ operator the engine does not lower yet is refused rather than passed through.
944
+
945
+ The three read members belong to a list you can query for many rows, so a singleton list does not
946
+ carry them — `get()` stays the way to read one. That matches the type the generator has always
947
+ emitted for a singleton.
948
+
949
+ Code the CLI writes into your project moves to the list key with everything else: the feature
950
+ generator's blog and auth pages (`context.db.Post.findMany(…)`), and the Keystone migration guide,
951
+ which now says list names are PascalCase.
952
+
953
+ A predicate whose condition is `undefined` is still skipped rather than refused, matching Prisma's
954
+ `undefined`-means-omitted semantics — so an access filter spelled `({ session }) => ({ authorId:
955
+ session?.userId })` constrains nothing for an anonymous caller, while the explicit `{ equals:
956
+ undefined }` spelling of the same rule is refused. Making the lowering total is the closed Where
957
+ vocabulary's job ([#1147](https://github.com/OpenSaasAU/stack/issues/1147)). Relation-valued `needs` are likewise not yet widened on `all()`/`first()`
958
+ the way `findMany` widens them ([#1149](https://github.com/OpenSaasAU/stack/issues/1149)).
959
+
960
+ - [#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
961
+
962
+ `validateConfigFields` — the check `pnpm generate` runs over every stored field before it
963
+ reads any contract — used to require the PSL-shaped `getPrismaType` and `getTypeScriptType`
964
+ from every non-virtual field. Those two describe one Prisma column and one TypeScript type,
965
+ and neither is read by anything on the contract-era generators: columns come from
966
+ `getContractField`, and the emitted types come from `outputType`/`inputType`, else from
967
+ the column's own codec. Both members are removed from the field-builder contract in this
968
+ same release.
969
+
970
+ For a field spanning several columns of different types there was no honest single
971
+ `getPrismaType` to give, so the gate was forcing field packages to declare a plausible but
972
+ false one purely to pass it — `@opensaas/stack-rag`'s `embedding()` is a `vector(n)` column
973
+ plus a `jsonb` column, and had to claim `Json?`.
974
+
975
+ `getContractField` is now what satisfies the gate for a stored field, with no PSL method in
976
+ the picture at all. `getZodSchema` is still required of it — no contract supplies
977
+ validation — and a field with no single column to be typed from must also declare
978
+ `outputType`. That is decided by the descriptor: `kind: 'columns'`, or `kind: 'computed'`
979
+ whether or not the builder also sets the `virtual` flag core's own `virtual()` sets
980
+ alongside it. A relationship field needs only `getContractField`. A stored field that
981
+ declares no contract now fails the gate outright: there is no PSL pair left to satisfy it
982
+ with.
983
+
984
+ ```typescript
985
+ // A field package can now describe its columns once, to the contract:
986
+ export function myField(): MyField {
987
+ return {
988
+ type: 'myField',
989
+ getZodSchema: () => /* … */,
990
+ getContractField: (fieldName) => ({ kind: 'columns', columns: [/* … */] }),
991
+ outputType: "import('@my/pkg').MyValue | null",
992
+ inputType: "import('@my/pkg').MyValue | null",
993
+ }
994
+ }
995
+ ```
996
+
997
+ This affects field packages, not applications: a field package migrates by describing its
998
+ columns to `getContractField` once, and no application config has to be edited.
999
+
1000
+ - [#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
1001
+
1002
+ `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.
1003
+
1004
+ ```typescript
1005
+ const users = await context.db.User.include('posts', (posts) =>
1006
+ posts
1007
+ .where({ published: { equals: true } })
1008
+ .orderBy({ createdAt: 'desc' })
1009
+ .limit(5),
1010
+ ).all()
1011
+ ```
1012
+
1013
+ 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`.
1014
+
1015
+ 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.
1016
+
1017
+ Naming the same relation twice in one read throws `DuplicateIncludeError` — neither merging the two refinements nor letting one win is a safe silent answer.
1018
+
1019
+ 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>[]`.
1020
+
1021
+ - [#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
1022
+
1023
+ `@opensaas/stack-core/origin` is the one component a declared surface installs to mark the
1024
+ queries it executes, and the one the ORM refuses unmarked queries with (ADR-0059). The
1025
+ generated context and the test harness install the same value.
1026
+
1027
+ ```ts
1028
+ import { originTripwire, withOrigin, preserveOrigin } from '@opensaas/stack-core/origin'
1029
+
1030
+ // Installed once, where the client is constructed.
1031
+ const client = postgres({ contractJson, middleware: [originTripwire] })
1032
+
1033
+ // A surface that materialises enters the origin around exactly its ORM call,
1034
+ // with the await inside — hooks therefore run outside the mark. The terminal
1035
+ // returns Prisma's `AsyncIterableResult`, a `PromiseLike` rather than a
1036
+ // `Promise`, which is what `withOrigin` accepts.
1037
+ const rows: Post[] = await withOrigin('engine', () => orm.Post.where({ id }).all())
1038
+
1039
+ // A surface that hands a lazy result back wraps it, so `then`, `toArray`,
1040
+ // `first`, `firstOrThrow` and the async iterator's `next` each re-enter the
1041
+ // scope and the query executes marked wherever the caller consumes it. The
1042
+ // caller's own continuations still run under the caller's origin.
1043
+ return preserveOrigin('unsafe', client.runtime().query(plan))
1044
+ ```
1045
+
1046
+ Any plan compiled with no origin in scope throws `UnmarkedQueryError` from `beforeCompile`,
1047
+ in every environment — there is no warn mode and no dev-only mode. The store carries
1048
+ `'engine' | 'unsafe'` and nothing else: no session, no policy. Scoping a query to a session
1049
+ stays an ordinary rebind of the secured context.
1050
+
1051
+ - [#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
1052
+
1053
+ The READMEs now document the API the packages actually ship, replacing the
1054
+ Prisma 7 spellings that no longer resolve.
1055
+
1056
+ Reads compose on `context.db` keyed by the list's PascalCase config key and end
1057
+ in a terminal, rather than calling a Prisma delegate:
1058
+
1059
+ ```ts
1060
+ const posts = await context.db.Post.where({ status: { equals: 'published' } })
1061
+ .orderBy({ createdAt: 'desc' })
1062
+ .limit(20)
1063
+ .all()
1064
+
1065
+ const post = await context.db.Post.where({ id }).first()
1066
+ if (!post) return null
1067
+ ```
1068
+
1069
+ `findMany`, `findUnique`, `findFirst` and `count()` are gone; the terminals are
1070
+ `all()`, `first()`, `aggregate()` and `nearest()`. A denied read is silent, so
1071
+ every `first()` result is a null check.
1072
+
1073
+ Writes take an args object with an identity-only `where`, and a relationship is
1074
+ set with `connect` or cleared with `null`:
1075
+
1076
+ ```ts
1077
+ const updated = await context.db.Post.update({
1078
+ where: { id },
1079
+ data: { title, author: { connect: { id: authorId } } },
1080
+ })
1081
+ ```
1082
+
1083
+ The database config documented in each README is the one `DatabaseConfig`
1084
+ carries — `provider: 'postgresql'`, `idField`, `timestamps`, `schemas`,
1085
+ `extensions` and `client`. `prismaClientConstructor`, `db.url` and
1086
+ `extendPrismaSchema` are gone, and the connection is resolved from the
1087
+ environment rather than named in the config.
1088
+
1089
+ Review round two swept each README against the built `.d.ts` rather than against
1090
+ another doc, and corrected what the grep-shaped sweep had missed:
1091
+
1092
+ - The UI README's theming block documented bare `--background`/`--primary` HSL
1093
+ triplets under a `.dark` class. The shipped contract is `--color-*` tokens in
1094
+ `oklch()`, resolved through `light-dark()` and switched by `data-theme` — the
1095
+ stylesheet's own header says the design exists "without a duplicated `.dark`
1096
+ block". Its primitives list also omitted eight real exports (`Textarea`,
1097
+ `Popover`, `Calendar`, `TimePicker`, `DateTimePicker`, `Combobox`, `Badge`,
1098
+ `Avatar`), and two samples read `config.lists` without awaiting `config`.
1099
+ - The tiptap README reused a filter-returning `AccessControl` rule as
1100
+ **field-level** `access.update`. `FieldAccess` types those slots as
1101
+ boolean-returning, so that is a type error and a runtime
1102
+ `InvalidFieldAccessResultError`, not a scoped update.
1103
+ - The storage README's upload route was the last copy still casting
1104
+ `formData.get(...) as string` / `as 'file' | 'image'` off a
1105
+ `FormDataEntryValue | null`.
1106
+ - The auth README's Account shape named `providerId: 'credentials'`; better-auth
1107
+ 1.7 uses `'credential'` for email/password, and the model carries `issuer`.
1108
+ - The Vercel Blob README passed `cacheControl` to `vercelBlobStorage()`. The
1109
+ provider option is `cacheControlMaxAge` (a number of seconds);
1110
+ `VercelBlobStorageConfig` carries an index signature, so the wrong spelling
1111
+ type-checked and was silently ignored.
1112
+
1113
+ Round three corrected what round two's sweeps could not see, each having keyed
1114
+ on where a construct sat rather than on what it was:
1115
+
1116
+ - The Vercel Blob README's **options listing** still named `cacheControl` 112
1117
+ lines above the call site round two fixed, so the page contradicted itself and
1118
+ the half a reader consults first was the wrong half.
1119
+ - Sixteen hook samples across the docs and the core, cli and example READMEs
1120
+ destructured a member the `delete` branch of its args union does not carry, so
1121
+ the destructure failed before any in-body `operation` guard could narrow. Three
1122
+ more named an argument on no branch at all: `value` and `inputValue` on
1123
+ `resolveInput`/`afterOperation`, and `session` on `ResolveInputHookArgs`.
1124
+ - The core README carried a third instance of the field-access class — a bare
1125
+ `text({ access: … })` excerpt with no enclosing `fields: {` — plus
1126
+ `query: true` where `OperationAccess.query` takes a function, a
1127
+ `ValidationError` built from a string where the constructor takes `string[]`,
1128
+ and a stale claim that `password()` is excluded from reads.
1129
+ - The cli README's "What it does" block under `opensaas db update` described
1130
+ `opensaas dev`, and called `migrate` a command group when it has no
1131
+ subcommands.
1132
+
1133
+ - [#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.
1134
+
1135
+ - [#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)).
1136
+
1137
+ 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.
1138
+
1139
+ 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.
1140
+
1141
+ ```typescript
1142
+ // With Author.query denying this session, both are now null.
1143
+ await context.db.Post.create({ data: { title: 't', author: { connect: { id } } } })
1144
+ await context.db.Post.create({ data: { title: 't', authorId: id } })
1145
+ ```
1146
+
1147
+ 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.
1148
+
1149
+ 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.
1150
+
1151
+ ```typescript
1152
+ // Refused: two spellings of one edge.
1153
+ await context.db.Post.create({ data: { author: { connect: { id: a } }, authorId: b } })
1154
+ ```
1155
+
1156
+ - [#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
1157
+
1158
+ 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.
1159
+
1160
+ ```typescript
1161
+ import type { BaseFieldConfig } from '@opensaas/stack-core/extend'
1162
+
1163
+ export function embedding(dimensions: number): BaseFieldConfig<TypeInfo> {
1164
+ return {
1165
+ type: 'embedding',
1166
+ getContractField: (fieldName) => ({
1167
+ kind: 'column',
1168
+ name: fieldName,
1169
+ type: { pack: 'pgvector', type: 'Vector', args: [dimensions] },
1170
+ nullable: true,
1171
+ }),
1172
+ // ...getZodSchema and the rest of the builder
1173
+ }
1174
+ }
1175
+
1176
+ text().getContractField('title', 'Post', config)
1177
+ // { kind: 'column', name: 'title', type: { pack: 'pg', type: 'text' }, nullable: true }
1178
+
1179
+ relationship({ ref: 'User.posts' }).getContractField('author', 'Post', config)
1180
+ // { kind: 'relation', target: 'User', inverse: { field: 'posts', synthetic: false }, many: false,
1181
+ // foreignKey: { name: 'authorId', map: 'author', nullable: true, unique: false, index: true,
1182
+ // references: { list: 'User', field: 'id' } } }
1183
+ ```
1184
+
1185
+ 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.
1186
+
1187
+ 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.
1188
+
1189
+ `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.
1190
+
1191
+ ```typescript
1192
+ total: virtual({
1193
+ type: 'number',
1194
+ needs: ['price', 'quantity'],
1195
+ hooks: { resolveOutput: ({ item }) => item.price * item.quantity },
1196
+ })
1197
+ ```
1198
+
1199
+ - [#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
1200
+
1201
+ An embedding is write-denied to application code, so the RAG plugin's generation hook
1202
+ wrote it through `sudo().db.<list>.update()`. That is an ordinary secured write, so it
1203
+ re-ran the list's **whole** hook pipeline carrying the embedding column and nothing else —
1204
+ and a list-level `resolveInput` that derives one field from other input, the pattern
1205
+ `CLAUDE.md` documents, then recomputed the derived field from values that were not there:
1206
+
1207
+ ```typescript
1208
+ Article: list({
1209
+ fields: {
1210
+ title: text(),
1211
+ body: text(),
1212
+ content: text(),
1213
+ contentEmbedding: embedding({ sourceField: 'content', dimensions: 3 }),
1214
+ },
1215
+ hooks: {
1216
+ // Ran a second time on the plugin's write, with `title` and `body` absent
1217
+ resolveInput: ({ resolvedData }) => ({
1218
+ ...resolvedData,
1219
+ content: [resolvedData.title, resolvedData.body].join(' '),
1220
+ }),
1221
+ },
1222
+ })
1223
+ ```
1224
+
1225
+ `create({ data: { title: 'red', body: 'hot' } })` committed `content: 'red hot'` and then
1226
+ overwrote it with `' '` — the join of two `undefined`s — and embedded that. No error, no
1227
+ log: the row and its vector were both silently wrong. The write threw on every invocation
1228
+ before the Write Pipeline landed, so this was only reachable once generation began running.
1229
+
1230
+ The plugin's write no longer goes through `context.db`. Core owns it as a single-field
1231
+ write, `writePluginOwnedField`, exported from `@opensaas/stack-core/extend` for any plugin
1232
+ that injects a field it computes:
1233
+
1234
+ ```typescript
1235
+ import { writePluginOwnedField } from '@opensaas/stack-core/extend'
1236
+
1237
+ runtime: (context) => ({
1238
+ [WRITE_VECTOR]: async (listName, id, fieldName, value) =>
1239
+ await writePluginOwnedField({ context, listName, id, fieldName, value }),
1240
+ })
1241
+ ```
1242
+
1243
+ It splits the value through the field's own `splitColumns` exactly as the Write Pipeline
1244
+ does, issues one scoped `UPDATE`, and runs no hook.
1245
+
1246
+ It reaches no field but the one named, and that is enforced rather than asked of the
1247
+ caller: the field is resolved against the config the context was built from, so the
1248
+ columns written are that field's own and the caller passes no layout. A list or a field
1249
+ the config does not declare — including one named for a key it inherits from
1250
+ `Object.prototype`, which a bare lookup answers for — is refused by name, as is a context
1251
+ carrying no config, as is an `undefined` value, which would otherwise wipe a multi-column
1252
+ field and no-op a single-column one, two outcomes for one input. This narrows the escalated
1253
+ `db` update it replaces, which could write any column on the row, but it is not a privilege
1254
+ boundary: a plugin holding `context.ormHandle` can already write anything, and this refuses
1255
+ the mistake rather than the intent.
1256
+
1257
+ It takes the `AccessContext` `Plugin.runtime` receives as its first argument; the
1258
+ `StackContext` `getContext` returns carries no ORM handle and is refused by name. That
1259
+ second argument, `sudo`, is now declared as the `StackContext` it always was — a plugin
1260
+ reaching `sudo().db` is unaffected, one reaching `ormHandle` off it was already getting
1261
+ `undefined` and now fails to compile. See ADR-0068.
1262
+
1263
+ A write refused by name is a wiring defect that fails identically on every row, so the RAG
1264
+ plugin's failure log now reports all three refusals — and `WriteCollectionMissingError`
1265
+ beside them — as the standing defect they are, rather than telling the reader to retry a
1266
+ write that can never succeed.
1267
+
1268
+ What changes for an application: a list hook no longer fires a second time when the plugin
1269
+ writes a generated column, so one logical change now fires one side effect. Nothing about
1270
+ `context.db` changes — an application write runs the pipeline exactly as before, and
1271
+ `embedding({ allowManualWrites: true })` still writes through it.
1272
+
1273
+ - [#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
1274
+
1275
+ `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.
1276
+
1277
+ 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`:
1278
+
1279
+ ```typescript
1280
+ // prisma/contract.ts — generated
1281
+ import { defineContract, nativeEnum, pg } from '@prisma/orm-postgres/contract-builder'
1282
+ import pgvector from '@prisma/orm-extension-pgvector/pack'
1283
+
1284
+ export const contract = defineContract({ extensions: { pgvector } }, ({ field, model, rel }) => {
1285
+ // ...
1286
+ })
1287
+ ```
1288
+
1289
+ `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:
1290
+
1291
+ ```typescript
1292
+ // prisma.config.ts — generated
1293
+ import { existsSync } from 'node:fs'
1294
+ import { join } from 'node:path'
1295
+ import { definePrismaConfig } from 'prisma/config'
1296
+ import { defineConfig } from '@prisma/orm-postgres/config'
1297
+ import { findDatabaseUrl } from '@opensaas/stack-core'
1298
+ import pgvector from '@prisma/orm-extension-pgvector/control'
1299
+
1300
+ const envFile = join(import.meta.dirname, '.env')
1301
+ if (existsSync(envFile)) process.loadEnvFile(envFile)
1302
+
1303
+ export default definePrismaConfig({
1304
+ orm: defineConfig({
1305
+ contract: './prisma/contract.ts',
1306
+ output: './prisma',
1307
+ extensions: [pgvector],
1308
+ db: { connection: findDatabaseUrl() },
1309
+ }),
1310
+ })
1311
+ ```
1312
+
1313
+ 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.
1314
+
1315
+ The generated `.opensaas/context.ts` constructs its client from the committed `contract.json` rather than from a generated client package:
1316
+
1317
+ ```typescript
1318
+ postgres<Contract>({ contractJson, url: resolveDatabaseUrl() })
1319
+ ```
1320
+
1321
+ 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.
1322
+
1323
+ 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.
1324
+
1325
+ `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.
1326
+
1327
+ - [#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' }`
1328
+
1329
+ 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.
1330
+
1331
+ ```typescript
1332
+ state: select({ options, defaultValue: 'new', access: { write: 'hooks' } })
1333
+ ```
1334
+
1335
+ - [#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
1336
+
1337
+ **Third-party field packages must migrate.** The generator emits a TypeScript
1338
+ contract module, not PSL (ADR-0040), and reads a field's TypeScript face from
1339
+ `outputType`/`inputType` (ADR-0052). Nothing consulted the PSL-shaped members
1340
+ any more, so they are gone from `BaseFieldConfig` and from every builder:
1341
+
1342
+ - `getPrismaType`
1343
+ - `getPrismaColumns`
1344
+ - `getPrismaRelation`
1345
+ - `getTypeScriptType`
1346
+ - `getTypeScriptImports`
1347
+ - `resultExtension`
1348
+ - `VirtualField.outputType` (the required `string` narrowing; the optional
1349
+ `outputType: TypeDescriptor` on `BaseFieldConfig` is what a virtual field
1350
+ declares now)
1351
+
1352
+ The `PrismaRelationResult`, `MultiColumnPrismaResult` and `ResultExtensionConfig`
1353
+ types they were shaped by are removed with them.
1354
+
1355
+ Migrating a field builder — describe the column instead of the PSL line:
1356
+
1357
+ ```ts
1358
+ // Before
1359
+ export function slug(options?: Omit<SlugField, 'type'>): SlugField {
1360
+ return {
1361
+ type: 'slug',
1362
+ ...options,
1363
+ getZodSchema: () => z.string().optional(),
1364
+ getPrismaType: () => ({ type: 'String', modifiers: '? @unique' }),
1365
+ getTypeScriptType: () => ({ type: 'string', optional: true }),
1366
+ }
1367
+ }
1368
+
1369
+ // After
1370
+ export function slug(options?: Omit<SlugField, 'type'>): SlugField {
1371
+ return {
1372
+ type: 'slug',
1373
+ ...options,
1374
+ getZodSchema: () => z.string().optional(),
1375
+ getContractField: (fieldName) => ({
1376
+ kind: 'column',
1377
+ name: fieldName,
1378
+ type: { pack: 'pg', type: 'text' },
1379
+ nullable: true,
1380
+ unique: true,
1381
+ }),
1382
+ }
1383
+ }
1384
+ ```
1385
+
1386
+ A field whose TypeScript face differs from its column's codec type declares it
1387
+ directly, rather than through `resultExtension` or `getTypeScriptType`:
1388
+
1389
+ ```ts
1390
+ // Before
1391
+ resultExtension: { outputType: "import('@my/pkg').Metadata | null" },
1392
+ getTypeScriptType: () => ({ type: 'Metadata | null', optional: true }),
1393
+ getTypeScriptImports: () => [{ names: ['Metadata'], from: '@my/pkg' }],
1394
+
1395
+ // After — the import is inline, so no separate import declaration is needed
1396
+ outputType: "import('@my/pkg').Metadata | null",
1397
+ inputType: "File | import('@my/pkg').Metadata | null",
1398
+ ```
1399
+
1400
+ A field spanning several physical columns returns `{ kind: 'columns', columns }`
1401
+ from `getContractField` and keeps `getColumnNames`/`assembleColumns`/`splitColumns`.
1402
+
1403
+ **The generate-time gate moved with the contract.** `validateFieldConfig` now
1404
+ requires `getContractField` and `getZodSchema` from a stored field (a
1405
+ relationship only the former), and additionally `outputType` from a field that
1406
+ has no single column to be typed from — one whose descriptor is
1407
+ `kind: 'columns'` or `kind: 'computed'`. Both are read off the descriptor, so a
1408
+ `computed` field carries the obligation whether or not its builder also sets the
1409
+ `virtual` flag that core's own `virtual()` sets alongside it. That closes a hole
1410
+ where such a field passed
1411
+ the gate, generated successfully, and left every consumer reading it as
1412
+ `unknown` (issue [#1292](https://github.com/OpenSaasAU/stack/issues/1292)). `FieldConfigValidationError.missingMethod` is renamed
1413
+ to `missingMember` to carry `outputType` alongside the two methods.
1414
+
1415
+ `validateFieldConfig`'s signature changed with it: `listKey` and a new fourth
1416
+ `config` argument are both **required**, because they are what
1417
+ `getContractField` takes and reading the descriptor is what makes the rule
1418
+ decidable. The optional `getColumnNames` is not consulted — it is a separate
1419
+ member that only travels with `kind: 'columns'` by convention, so reading it
1420
+ would both miss a `columns` field that does not implement it ([#1292](https://github.com/OpenSaasAU/stack/issues/1292)'s hole) and
1421
+ wrongly demand `outputType` from a single-column field that does.
1422
+ `FieldConfigValidationError.listKey` is likewise no longer optional.
1423
+
1424
+ The gate swallows a throw out of `getContractField`: that is a field's own
1425
+ refusal seam (`embedding()` throws there for an impossible `dimensions`).
1426
+ `opensaas generate` runs this gate first of all, and its config-surface step —
1427
+ `validateDatabaseConfig` → `validateExtensionPacks` — re-reads every descriptor
1428
+ straight afterwards and reports the throw as a `field-descriptor-error` refusal
1429
+ carrying the field's own message, so the run still fails with
1430
+ `List "<List>": fields.<field> cannot describe its contract column — <message>`
1431
+ rather than a raw stack trace. Derivation is never reached.
1432
+
1433
+ `inputType` is never required by the generator. On a single-column field its
1434
+ absence means the column's own input type; a `kind: 'columns'` field has no
1435
+ single column for that to name, so it should declare `inputType` alongside
1436
+ `outputType` — every multi-column field in this repo does, and what the
1437
+ generator emits for one that does not is untested.
1438
+
1439
+ **A field-level hook's value type is resolved from the field key, and is
1440
+ `unknown` when there is no single key to resolve.** `FieldHooks`'
1441
+ `resolveInput`/`resolveOutput` positions used to be typed from the deleted
1442
+ `getTypeScriptType`. `FieldHooks<TTypeInfo, 'title'>` now resolves to the
1443
+ field's statically declared `outputType`, or else to the property the generated
1444
+ `Lists.<List>.Item` carries for it.
1445
+
1446
+ But `BaseFieldConfig.hooks` cannot pin a field key — a builder is written
1447
+ before it knows where it is mounted — so through the config surface
1448
+ (`list<Lists.Post.TypeInfo>({ fields: { title: text({ hooks }) } })`) the
1449
+ instantiation is `FieldHooks<TTypeInfo>`, whose key is the union of every field
1450
+ on the list, and the value type is **`unknown`**: the same open type as before
1451
+ this change. Resolving that union would type each field's hook by the whole
1452
+ row, so a `text()` hook would accept a `Date` and reject its own `string`. An
1453
+ honestly `unknown` type is better than a confidently wrong one; narrowing it
1454
+ needs the field key threaded into `BaseFieldConfig`, tracked in issue [#1306](https://github.com/OpenSaasAU/stack/issues/1306).
1455
+
1456
+ Two related limits, for the same reason: `lists.ts` emits `Fields` as the field
1457
+ _interfaces_, on which `outputType` is optional, so a declared face never
1458
+ survives into a generated `TypeInfo` — the declared branch is reachable only
1459
+ from a hand-authored one. And a virtual field's hook value stays `unknown`,
1460
+ since it has no declared face there and no column in the stored row.
1461
+
1462
+ `db.keystoneCompat`'s implicit empty-string text default is now carried by
1463
+ `text()`'s contract column, where the deleted `getPrismaType` used to emit it —
1464
+ but only where the field's own create validator accepts **both** the omission
1465
+ that default is there to fill **and** the `''` it inserts. Both questions are
1466
+ asked of the schema rather than restated, so the column and the validator
1467
+ cannot drift apart:
1468
+
1469
+ - a column default drops the column from the required half of the generated
1470
+ `CreateInput`, so carrying one where the validator refuses an omission would
1471
+ type-check a `create` that then threw `ValidationError`;
1472
+ - and the value a column default inserts is never seen by validation — the
1473
+ database supplies it — so carrying one where the validator refuses `''`
1474
+ would store a row the config forbids on every omitted `create`. That is the
1475
+ outcome an explicit `defaultValue: ''` already gets right: it is filled by
1476
+ `applyCreateDefaults` before validation and correctly rejected. The two
1477
+ spellings of "this column defaults to an empty string" now agree.
1478
+
1479
+ **Known limit: the flag is therefore inert for
1480
+ `validation: { isRequired: true }` text — Keystone's commonest text column —
1481
+ and for `validation: { length: { min: N } }` with `N` above zero.** Keystone 6
1482
+ renders both as `NOT NULL DEFAULT ''`, so a migrating project sees
1483
+ `DROP DEFAULT` for them in `migrate diff`. Setting `defaultValue: ''` by hand
1484
+ is refused at runtime for the same reason, so the field's validation has to be
1485
+ relaxed alongside it. Full parity would need the flag to relax the create
1486
+ validator itself, which `getZodSchema` has no config to read; that is a
1487
+ separate change. A column made non-null through `db: { isNullable: false }`
1488
+ alone still gets the default, as does one carrying only a `length.max`.
1489
+
1490
+ Relatedly, `text()` no longer treats `validation: { length: { min: 0 } }` as
1491
+ `min(1)`. A zero minimum now means no minimum, so `''` validates — which is
1492
+ what the option says, and what lets such a column keep its compat default
1493
+ without the column and the validator disagreeing. `isRequired` still imposes a
1494
+ floor of `min(1)` on a field that declares `length: { min: 0 }` or no minimum
1495
+ at all, and never lowers a larger declared one — `isRequired` with
1496
+ `length: { min: 5 }` is still `min(5)`.
1497
+
1498
+ **Test coverage that thinned.** Three assertions were lost rather than ported,
1499
+ and are recorded here so the change is not silent:
1500
+
1501
+ - `select()`'s "falls back to a capitalized `fieldName` when `listName` is not
1502
+ provided" — `getContractField` is always given a `listKey`.
1503
+ - The quoted-vs-unquoted PSL default rendering for a string versus an enum
1504
+ `select()` — the contract carries one `{ kind: 'literal' }` for both.
1505
+ - The per-field `getTypeScriptType` blocks in `tests/field-types.test.ts`
1506
+ became `expect(field.outputType).toBeUndefined()` — "declares no override",
1507
+ which is weaker than the old "text is `string`, optional when not required".
1508
+ Column nullability is still asserted on the same fields, and the codec now
1509
+ owns the type (ADR-0052), so the fact has moved rather than vanished.
1510
+
1511
+ - [#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`
1512
+
1513
+ 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.
1514
+
1515
+ ```typescript
1516
+ Ledger: list({
1517
+ access: { operation: { create: isAdmin, update: isAdmin, delete: isAdmin } },
1518
+ ui: {
1519
+ hideCreate: true,
1520
+ hideDelete: ({ session }) => session?.role !== 'OWNER',
1521
+ itemView: { defaultFieldMode: 'read' },
1522
+ },
1523
+ })
1524
+ ```
1525
+
1526
+ `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.
1527
+
1528
+ - [#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.
1529
+
1530
+ - [#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
1531
+
1532
+ The breaks below are real and are documented in full. They ship on `minor`,
1533
+ as every other changeset on this line does: before 1.0, a minor release is
1534
+ where breaking changes go.
1535
+
1536
+ A read on the secured surface is narrowed with `.select(...fields)`, which the
1537
+ engine honours exactly: it widens the query by the declared dependency sets of
1538
+ the computed fields the read will return and by anything a row-dependent field
1539
+ `read` rule has to see, then strips `widened ∖ caller` as a recursive set
1540
+ difference at every nesting level. `.select()` replaces on call rather than
1541
+ accumulating, names this list's own fields only, and a computed field is
1542
+ selectable whether or not the columns it reads were named. An `.include()`
1543
+ refinement carries its own `.select()`.
1544
+
1545
+ ```typescript
1546
+ // `wordCount` declares `needs: ['body']`. The engine reads `body`, computes the
1547
+ // field, and `body` is not in the result — the caller did not ask for it.
1548
+ const rows = await context.db.Post.select('wordCount')
1549
+ .include('author', (author) => author.select('name'))
1550
+ .all()
1551
+ ```
1552
+
1553
+ `.select()` is on the generated typed surface, so a projected read's row type
1554
+ is exactly the keys it named plus the list's system fields — an unselected
1555
+ column, and anything the engine widened the query by, is a compile error rather
1556
+ than an absent value. A relation named in `.select()` is refused at compile
1557
+ time and, at runtime, with `RelationSelectError` (now exported from the package
1558
+ root).
1559
+
1560
+ `.limit(count)` joins the composed read as well, bounding `.all()`.
1561
+
1562
+ Relation-valued `needs` are now folded into the read on the new terminals, so
1563
+ `.all()` / `.first()` and the legacy read path agree on a computed field with a
1564
+ relation dependency.
1565
+
1566
+ Two behaviours change on every read path, per ADR-0051:
1567
+
1568
+ - **A `resolveOutput` hook's `item` is exactly its own declared dependency set
1569
+ plus the list's system fields.** A hook that reads a key it did not declare in
1570
+ `needs` now finds nothing there. Migration: find `resolveOutput` hooks whose
1571
+ `item` reads a key absent from that field's `needs`, and declare it.
1572
+ - **A declaration outranks a caller-facing `read` denial** on the same column or
1573
+ relation. The value reaches the hook and is still stripped before the caller
1574
+ sees it, so adding a `read` rule elsewhere can no longer silently change a
1575
+ computed field's value — and `needs: ['passwordHash']` is a deliberate way to
1576
+ surface a denied column's derived value.
1577
+
1578
+ `defineFragment`, `runQuery`, `runQueryOne`, `ResultOf`, `RelationSelector`,
1579
+ `QueryArgs`, `Fragment`, `FieldSelection`, `buildInclude`, `pickFields` and the
1580
+ `query:` argument on `findMany` / `findFirst` / `findUnique` are removed.
1581
+
1582
+ Migration:
1583
+
1584
+ ```typescript
1585
+ // Before
1586
+ const postFragment = defineFragment<Post>()({ id: true, title: true } as const)
1587
+ const posts = await context.db.post.findMany({ query: postFragment, where: { published: true } })
1588
+
1589
+ // After
1590
+ const posts = await context.db.Post.where({ published: { equals: true } })
1591
+ .select('title')
1592
+ .all()
1593
+ ```
1594
+
1595
+ A nested fragment or `RelationSelector` becomes an `.include()` refinement:
1596
+
1597
+ ```typescript
1598
+ // Before
1599
+ defineFragment<Post>()({
1600
+ id: true,
1601
+ comments: { query: commentFragment, where: { approved: true }, take: 5 },
1602
+ } as const)
1603
+
1604
+ // After
1605
+ context.db.Post.select('title').include('comments', (comments) =>
1606
+ comments
1607
+ .where({ approved: { equals: true } })
1608
+ .limit(5)
1609
+ .select('body'),
1610
+ )
1611
+ ```
1612
+
1613
+ - [#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
1614
+
1615
+ `context.db.<List>.where(...)` now accepts the whole vocabulary — `equals`,
1616
+ `not`, `in`, `notIn`, `lt`, `lte`, `gt`, `gte`, `contains`, the `AND`/`OR`/`NOT`
1617
+ combinators, and `some`/`every`/`none` on a relation of any cardinality — plus a
1618
+ new scalar-only `.orderBy()`. Everything lowers onto the ORM's predicate lambda
1619
+ in one place (ADR-0055).
1620
+
1621
+ ```typescript
1622
+ const posts = await context.db.Post.where({
1623
+ OR: [{ title: { contains: 'release' } }, { views: { gte: 100 } }],
1624
+ some: { handle: { equals: 'ada' } } },
1625
+ })
1626
+ .orderBy({ views: 'desc' })
1627
+ .all()
1628
+ ```
1629
+
1630
+ - `contains` is engine-escaped and case-insensitive, so `contains: '50%'` matches
1631
+ a literal per-cent sign rather than binding a wildcard.
1632
+ - `equals: null` lowers to `IS NULL`, `not: null` to `IS NOT NULL`.
1633
+ - A relation predicate scopes the `EXISTS` by the related list's own `query`
1634
+ access. `some` and `none` ask about the rows the caller may see; `every` asks
1635
+ whether every row the caller may see matches, so a row the caller cannot see
1636
+ never decides the parent's membership. A related list the session cannot
1637
+ query is the empty set: `some` is false, `none` and `every` are true.
1638
+ - An Access Filter that scopes by a relation is expanded into the related list's
1639
+ own Access Filter. A filter that expands into itself — directly, or through
1640
+ another list — throws `AccessFilterRecursionError` naming the chain, rather
1641
+ than recursing until the process runs out of memory. An acyclic chain deeper
1642
+ than ten lists is refused the same way. Failing closed is deliberate: a
1643
+ truncated Access Filter is a widened read.
1644
+ - An unknown key or operator is a `ValidationError` naming the list and the key,
1645
+ under `sudo` too. A key the session cannot read is refused with the identical
1646
+ message a key the list does not declare gets, so the refusal is not an
1647
+ existence oracle; a denied caller still gets the Silent failure first and sees
1648
+ no validation error at all.
1649
+
1650
+ **Lowering is now total.** A condition that resolved to `undefined` is refused
1651
+ rather than dropped, on both spellings. An access rule written as
1652
+ `({ session }) => ({ authorId: session?.userId })` used to match every row for an
1653
+ anonymous caller; it now throws. Spell the denial:
1654
+
1655
+ ```typescript
1656
+ // Before — silently matched everything when session was null
1657
+ query: ({ session }) => ({ authorId: session?.userId })
1658
+
1659
+ // After
1660
+ query: ({ session }) => (session ? { authorId: { equals: session.userId } } : false)
1661
+ ```
1662
+
1663
+ The same refusal now covers the clause `mergeFilters` folds in, so the guarantee
1664
+ holds on every surface rather than only on `.where().all()/.first()`: an access
1665
+ filter carrying an `undefined` condition anywhere (including nested under an
1666
+ operator or inside an `AND`/`OR` branch) throws the new, exported
1667
+ `UndefinedAccessFilterError`. A caller's own `where` is untouched — this applies
1668
+ only to what an access rule returns.
1669
+
1670
+ **Also changed:** the filter engine's `FilterCondition` is a Where vocabulary
1671
+ value; a to-one relationship's label filter emits `some` rather than `is`; a
1672
+ to-many count filter shrinks to presence (`orders:0` → `none`, `orders:>0` /
1673
+ `orders:>=1` → `some`, any other comparison degrades to free text);
1674
+ and read-path key validation rejects an operator outside the vocabulary
1675
+ (`startsWith`, `endsWith`, `mode`, `search` and the array/JSON operators are
1676
+ gone).
1677
+
1678
+ **Removed exports.** These have no replacement — the behaviour they carried is
1679
+ either gone or now expressed in the Where vocabulary:
1680
+
1681
+ | Removed | What to do instead |
1682
+ | --------------------------------------------- | -------------------------------------------------------------- |
1683
+ | `RELATIONSHIP_COUNT_FILTER_KEY` | Nothing — the count-filter marker no longer exists. |
1684
+ | `RelationshipCountFilterMarker` | Nothing — same. |
1685
+ | `resolveRelationshipCountFilters` | Nothing — a count filter shrinks to `some`/`none` when parsed. |
1686
+ | `resolveRelationshipLabelFilters` | Nothing — a to-one label filter emits `some` directly. |
1687
+ | `isToOneRelationshipField` | Read `many` off the relationship field config. |
1688
+ | `ColumnEquality`, `UnsupportedPredicateError` | Gone with the predicate builder they belonged to. |
1689
+
1690
+ **Newly exported:** `UndefinedAccessFilterError` and, from the secured surface,
1691
+ `AccessFilterRecursionError`.
1692
+
1693
+ - [#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`
1694
+
1695
+ `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.
1696
+
1697
+ Migration: `getSession: (headers) => …` becomes `getSession: (req) => … req.headers …`.
1698
+
1699
+ - [#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
1700
+
1701
+ ```typescript
1702
+ mcp: { enabled: true, scopes: { read: 'mcp:read', write: 'mcp:write' } }
1703
+ ```
1704
+
1705
+ `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.
1706
+
1707
+ - [#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
1708
+
1709
+ `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).
1710
+
1711
+ ```ts
1712
+ // .opensaas/tables.ts
1713
+ export const dependencyTable: DependencyTable = {
1714
+ Post: {
1715
+ systemFields: ['id', 'createdAt', 'updatedAt'],
1716
+ fields: {
1717
+ byline: { columns: ['authorId', 'title'], relations: ['author'] },
1718
+ },
1719
+ },
1720
+ Category: { systemFields: ['id'], fields: {} }, // db.timestamps: false
1721
+ }
1722
+
1723
+ export const constraintMap: ConstraintMap = {
1724
+ User_email_key: { list: 'User', fields: ['email'] },
1725
+ Profile_user_key: { list: 'Profile', fields: ['user'] },
1726
+ }
1727
+ ```
1728
+
1729
+ Core exports `deriveDependencyTable(config)`, `deriveConstraintMap(config, contract)` and `deriveGeneratedTables(config, contract)` for anything that needs the same facts.
1730
+
1731
+ 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.
1732
+
1733
+ 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.
1734
+
1735
+ **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.
1736
+
1737
+ 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.
1738
+
1739
+ - [#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
1740
+
1741
+ 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.
1742
+
1743
+ ```ts
1744
+ import { richText } from '@opensaas/stack-tiptap/fields'
1745
+ import type { Lists } from '@/.opensaas/lists'
1746
+
1747
+ Article: list<Lists.Article.TypeInfo>({
1748
+ fields: {
1749
+ // now infers TTypeInfo from the surrounding list, so the field's own
1750
+ // hooks see `listKey: 'Article'` and the list's field keys
1751
+ content: richText({ validation: { isRequired: true } }),
1752
+ },
1753
+ })
1754
+ ```
1755
+
1756
+ No call-site change is required: the parameter is inferred, and an untyped `list({ … })` keeps the previous default.
1757
+
1758
+ 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.
1759
+
1760
+ 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.
1761
+
1762
+ `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.
1763
+
1764
+ **`TiptapField` also no longer reports an edit nobody made.** Two Tiptap calls emit an `update` by default, and this component forwarded both to `onChange`:
1765
+
1766
+ - `setContent(content)` — `emitUpdate` defaults to `true`, so mounting with a `null` value pushed `{"type":"doc","content":[{"type":"paragraph"}]}` into form state;
1767
+ - `setEditable(editable)` — its second argument is `emitUpdate`, also defaulted to `true`, so merely becoming editable counted as a content change.
1768
+
1769
+ 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`.
1770
+
1771
+ `formatFieldName` is now exported from `@opensaas/stack-core/extend`, the third-party field-authoring surface:
1772
+
1773
+ ```ts
1774
+ import { formatFieldName } from '@opensaas/stack-core/extend'
1775
+
1776
+ formatFieldName('internalNotes') // 'Internal Notes'
1777
+ ```
1778
+
1779
+ `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.
1780
+
1781
+ `@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.
1782
+
1783
+ - [#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
1784
+
1785
+ `create`, `update` and `delete` now reach the database through the Prisma 8
1786
+ collection itself — `collection.create(row)`, `collection.where(…).update(row)`,
1787
+ `collection.where(…).delete()` — instead of the Prisma 7 delegate names. Every
1788
+ write still opens a transaction, and the phase order is unchanged: operation
1789
+ access outside the transaction, then hooks, validation, writable-field
1790
+ filtering, persistence, after-hooks and Field Visibility.
1791
+
1792
+ `update` and `delete` target a row by its identity and nothing else. The engine
1793
+ lowers `id` alone into a write's predicate, so a `where` naming another column —
1794
+ a secondary unique one included — is now a compile error against
1795
+ `ListIdentityWhere`, and a thrown caller-shape error at runtime for a payload
1796
+ that arrived untyped. It never silently writes nothing:
1797
+
1798
+ ```typescript
1799
+ // Compile error, and a throw at runtime: `email` selects no row to write.
1800
+ await context.db.User.update({ where: { email: 'a@b.com' }, data: { name: 'Ada' } })
1801
+
1802
+ // Find the row, then write it by its id.
1803
+ const user = await context.db.User.findUnique({ where: { email: 'a@b.com' } })
1804
+ if (user) await context.db.User.update({ where: { id: user.id }, data: { name: 'Ada' } })
1805
+ ```
1806
+
1807
+ `update` and `delete` now merge the list's Access Filter into the predicate of
1808
+ the write itself, beside the row's identity, so the statement acts on the same
1809
+ rows the read would return:
1810
+
1811
+ ```typescript
1812
+ Post: list({
1813
+ access: {
1814
+ operation: {
1815
+ update: ({ session }) => ({ authorId: { equals: session?.userId } }),
1816
+ },
1817
+ },
1818
+ })
1819
+
1820
+ // Runs `UPDATE … WHERE id = … AND "authorId" = …`; a row the filter excludes
1821
+ // answers `null`, denied-or-gone, exactly as a denied read does.
1822
+ await context.db.Post.update({ where: { id }, data: { title: 'edited' } })
1823
+ ```
1824
+
1825
+ Because the filter is lowered through the same Where vocabulary a read uses, an
1826
+ Access Filter must now name fields the list declares — a rule that scoped by an
1827
+ undeclared column is refused rather than silently passed through.
1828
+
1829
+ Nested relation input leaves the write payload, `connect` excepted (ADR-0050).
1830
+ `create`/`update`/`delete`/`connectOrCreate`/`disconnect`/`set`/`updateMany`/`deleteMany`
1831
+ under a relationship key are a compile error against the generated input types
1832
+ and a `NestedRelationInputError` at runtime; `{ connect: { id } }` survives,
1833
+ because it lowers onto a foreign-key column the row being written owns.
1834
+
1835
+ `disconnect` has a direct replacement on the side that owns that column — assign
1836
+ `null` to the relationship field, which is the same column and the same
1837
+ lowering. On a field owning no column, `null` is refused in turn with
1838
+ `NonOwningRelationInputError`, so that edge is cleared by an update against the
1839
+ target list. The remaining kinds have no replacement in the payload at all:
1840
+ write the related rows yourself and wrap them in `context.transaction` when they
1841
+ must land together:
1842
+
1843
+ ```typescript
1844
+ await context.transaction(async (tx) => {
1845
+ const author = await tx.db.Author.create({ data: { name: 'Ada' } })
1846
+ await tx.db.Post.create({ data: { title: 'Notes', authorId: author.id } })
1847
+ })
1848
+ ```
1849
+
1850
+ `connect` is the one spelling ADR-0050 keeps, and the engine lowers it onto the
1851
+ column the row carries — see `amber-keys-reach.md` for the reachability query it
1852
+ issues first. An owning field carrying neither `{ connect: { id } }` nor `null`
1853
+ is refused by name with a `MalformedRelationInputError` naming the list and the
1854
+ field, rather than reaching the driver as a column value and failing as a raw
1855
+ type error that names neither. Every refusal on this surface is checked against
1856
+ both the caller's payload and the data a `resolveInput` hook produced, and each
1857
+ recognises a synthetic `from_<List>_<field>` back-relation key rather than
1858
+ mistaking it for a column of this list.
1859
+
1860
+ `afterTransaction` no longer reports `committed` for a write that persisted
1861
+ nothing. A write whose predicate matched no row — the row dropped by a
1862
+ `beforeOperation` hook, say — answers `null` to the caller and `rolled-back` to
1863
+ the bracket, so a compensator keyed on `committed` never acts on a write that
1864
+ did not happen.
1865
+
1866
+ `context.db.<List>.createMany` and `updateMany` are removed — both ran one
1867
+ secured write per item, which `context.transaction` expresses directly — and
1868
+ `packages/core/src/context/nested-operations.ts` is deleted with them.
1869
+
1870
+ - [#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
1871
+
1872
+ `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.
1873
+
1874
+ ```typescript
1875
+ const { total } = await context.db.Post.where({ published: { equals: true } }).aggregate(
1876
+ (aggregate) => ({ total: aggregate.count() }),
1877
+ )
1878
+ ```
1879
+
1880
+ 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:
1881
+
1882
+ ```typescript
1883
+ const users = await context.db.User.include('posts', (posts) =>
1884
+ posts.combine({
1885
+ published: posts.where({ published: { equals: true } }).count(),
1886
+ total: posts.count(),
1887
+ }),
1888
+ ).all()
1889
+ // each row: { …user, posts: { published: number; total: number } }
1890
+ ```
1891
+
1892
+ `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.
1893
+
1894
+ `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.
1895
+
1896
+ `groupBy`, the `*All` family, `*AndCount` and `upsert` remain absent from the surface: a method appears only where the engine knows how to scope it.
1897
+
1898
+ - [#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
1899
+
1900
+ `packages/core/tests/` is gone. Every suite that stood the engine up on a hand-built
1901
+ object of `vi.fn()` per-model delegates has been rewritten against the Test context —
1902
+ an in-process Postgres per Vitest worker, honouring the `DATABASE_URL` escape
1903
+ (ADR-0057) — and the rest moved beside the module it covers, so the whole corpus now
1904
+ lives under `packages/core/src/`.
1905
+
1906
+ The suites are named for the glossary term they protect: Silent failure, Access Filter,
1907
+ Field Visibility, the Where vocabulary, the Declared dependency set, the Write Pipeline,
1908
+ the Row lock and the Engine stamp.
1909
+
1910
+ Nothing about writing a test against `@opensaas/stack-core/testing` changes:
1911
+
1912
+ ```typescript
1913
+ import { createTestContext } from '@opensaas/stack-core/testing'
1914
+
1915
+ const harness = await createTestContext(config, { userId: 'u1' })
1916
+ await harness.context.db.Post.create({ data: { title: 'ship it' } })
1917
+ expect(await harness.context.db.Post.all()).toHaveLength(1)
1918
+ await harness.close()
1919
+ ```
1920
+
1921
+ ADR-0002's per-glob coverage ratchet is re-baselined once against the new corpus and
1922
+ still enforced by `pnpm --filter @opensaas/stack-core test:coverage`. No threshold was
1923
+ lowered and no path was excluded.
1924
+
1925
+ - [#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.
1926
+
1927
+ `@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:
1928
+
1929
+ ```typescript
1930
+ import { readPluginOwnedRow } from '@opensaas/stack-core/extend'
1931
+
1932
+ const row = await readPluginOwnedRow({ context, listName: 'Article', id })
1933
+ ```
1934
+
1935
+ - [#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
1936
+
1937
+ 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:
1938
+
1939
+ ```tsx
1940
+ import { getContext, config } from '@/.opensaas/context'
1941
+
1942
+ export default async function AdminPage() {
1943
+ return (
1944
+ <AdminUI context={await getContext()} config={await config} serverAction={serverAction} />
1945
+ )
1946
+ }
1947
+ ```
1948
+
1949
+ 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).
1950
+
1951
+ **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`.
1952
+
1953
+ Two engine fixes the first Next app on Prisma 8 exposed:
1954
+
1955
+ - 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.
1956
+ - 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)).
1957
+
1958
+ 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.
1959
+
1960
+ - [#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
1961
+
1962
+ `context.db.<List>.where(…).nearest(field, vector, { limit, minScore })` runs one
1963
+ scoped similarity query over a native `Vector(n)` column and returns
1964
+ `{ item, score }`. The ranking, the `limit` and the `minScore` bound all sit
1965
+ inside the query alongside the Access Filter, so top-K is computed over the rows
1966
+ the session may see rather than filtered down afterwards, and the raw distance is
1967
+ never exposed. Searching requires read access to the embedding field: ordering by
1968
+ a vector measures its contents, so a session that cannot read it is refused with
1969
+ the message an undeclared key gets.
1970
+
1971
+ ```typescript
1972
+ const hits = await context.db.Article.where({ published: true }).nearest(
1973
+ 'embedding',
1974
+ queryVector,
1975
+ {
1976
+ limit: 5,
1977
+ minScore: 0.8,
1978
+ },
1979
+ )
1980
+
1981
+ for (const { item, score } of hits) {
1982
+ console.log(item.title, score)
1983
+ }
1984
+ ```
1985
+
1986
+ The database owns the ordering. `score` is the same distance function recomputed
1987
+ from the row's own vector, in float64 over a float4 column, so two tied rows can
1988
+ arrive in an order their scores do not reproduce — read it as the similarity, not
1989
+ as the sort key. A column that does not read back as a vector raises
1990
+ `VectorDecodeError` naming the list and field, rather than scoring `NaN`.
1991
+
1992
+ A field declares its vector column through the new `getVectorColumn` member of
1993
+ `BaseFieldConfig`, which core reads to know the column, its dimension and the
1994
+ distance function (`cosine`, `l2` or `inner_product`) — a descriptor naming any
1995
+ other distance function is refused:
1996
+
1997
+ ```typescript
1998
+ getVectorColumn: (fieldName) => ({
1999
+ column: fieldName,
2000
+ dimensions: 1536,
2001
+ distanceFunction: 'cosine',
2002
+ })
2003
+ ```
2004
+
2005
+ - [#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
2006
+
2007
+ 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.
2008
+
2009
+ The related-row writes go through two server actions, both keyed on the related list:
2010
+
2011
+ ```typescript
2012
+ // Link an existing related row to the parent (new)
2013
+ await serverAction({
2014
+ listKey: 'Post',
2015
+ action: 'linkRelated',
2016
+ id: postId,
2017
+ field: 'author',
2018
+ parentId: userId,
2019
+ })
2020
+
2021
+ // Unlink it again (unchanged)
2022
+ await serverAction({
2023
+ listKey: 'Post',
2024
+ action: 'removeRelated',
2025
+ mode: 'disconnect',
2026
+ id: postId,
2027
+ field: 'author',
2028
+ })
2029
+ ```
2030
+
2031
+ 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.
2032
+
2033
+ 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'`.
2034
+
2035
+ 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.
2036
+
2037
+ Ids now cross the wire through one contract-driven coercion (ADR-0048), which reads each list's id type from the contract:
2038
+
2039
+ ```typescript
2040
+ import { parseListId } from '@opensaas/stack-core'
2041
+
2042
+ parseListId(config, 'Post', '12') // { ok: true, value: 12 } on an int-keyed list
2043
+ parseListId(config, 'Post', 'not-an-int') // { ok: false }
2044
+ parseListId(config, 'Post', '3000000000') // { ok: false } — outside the int4 column
2045
+ ```
2046
+
2047
+ 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.
2048
+
2049
+ Nav counts are read through the secured `aggregate` reducer, so a badge again reports the rows the session may see.
2050
+
2051
+ - [#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
2052
+
2053
+ `@opensaas/stack-auth` no longer hands better-auth `prismaAdapter`. It builds its
2054
+ own adapter with better-auth's `createAdapterFactory`, running on the Unsafe
2055
+ surface a Prisma 8 context carries: eight methods on the ORM lane, and
2056
+ `incrementOne` plus an unconditional `deleteMany` as single typed-SQL statements
2057
+ through the surface's own executors. `consumeOne` is `where(…).delete()` inside one
2058
+ transaction on the surface's transaction-bound lanes, answering the row only
2059
+ when the delete itself claimed it — the at-most-one guarantee better-auth asks
2060
+ for, held against concurrent replays of the same token. See ADR-0060.
2061
+
2062
+ `createAuth(config, rawOpensaasContext)` keeps its signature; nothing in an
2063
+ app's `lib/auth.ts` changes. Two new keys are refused at config time, alongside
2064
+ the existing `betterAuthOptions.database`:
2065
+
2066
+ ```typescript
2067
+ authPlugin({
2068
+ betterAuthOptions: {
2069
+ // both throw: the database mints auth ids, and the adapter implements no joins
2070
+ advanced: { database: { generateId: () => id, joins: true } },
2071
+ },
2072
+ })
2073
+ ```
2074
+
2075
+ `authPlugin` now pins `db.idField: 'uuid7'` on every list it injects, so auth
2076
+ ids are minted by the database like every other list's.
2077
+
2078
+ `@opensaas/stack-core` gains the engine-owned LIKE-pattern escaping the adapter
2079
+ lowers `contains` / `starts_with` / `ends_with` and insensitive `eq` through
2080
+ (`escapeLikeLiteral` and the four pattern builders, on
2081
+ `@opensaas/stack-core/internal`) — one escaper, shared with the secured
2082
+ surface's Where vocabulary.
2083
+
2084
+ Known limits of the adapter, all stated: no joins, no `createSchema` (so
2085
+ better-auth's CLI is unsupported against it), no better-auth transaction option
2086
+ yet, no issuer-scoped account uniqueness until the schema gap in [#986](https://github.com/OpenSaasAU/stack/issues/986) closes,
2087
+ and errors arrive as the driver's own rather than normalised.
2088
+
2089
+ - [#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`
2090
+
2091
+ Core gains `@opensaas/stack-core/client`, whose `resolveRuntimeConnection()` chooses how the
2092
+ runtime binds its connection, and the generated `.opensaas/context.ts` builds its client from it
2093
+ once per process — with the stack-owned origin tripwire in `middleware` and each declared pack's
2094
+ runtime façade in `extensions`.
2095
+
2096
+ ```typescript
2097
+ import { resolveRuntimeConnection } from '@opensaas/stack-core/client'
2098
+
2099
+ postgres<Contract>({
2100
+ contractJson,
2101
+ middleware: [originTripwire],
2102
+ ...resolveRuntimeConnection(config.db.client),
2103
+ })
2104
+ ```
2105
+
2106
+ Three branches, in order:
2107
+
2108
+ - `db.client.pg` — your own pool. The factory is called here and nowhere else, once, after the
2109
+ config promise resolves, so loading the config (the CLI's `generate`, tooling, a type check)
2110
+ never opens a connection.
2111
+ - A dev database (`opensaas dev`) — a single-connection pool with `verifyMarker: false`, both
2112
+ required by the socket-multiplexed dev database and applied on its provenance only.
2113
+ - `DATABASE_URL` — the connection string and Prisma's defaults, plus `db.client.poolOptions`.
2114
+
2115
+ With neither a connection variable nor a running dev database, the first use throws
2116
+ `DatabaseUrlUnresolvedError`, naming both remedies. That failure is not cached: a process that
2117
+ starts before its database does drops the memo and builds a client on the next call, so the dev
2118
+ server booting ahead of `opensaas dev` recovers on its own rather than serving a stale error for
2119
+ the rest of its life.
2120
+
2121
+ An explicit `db.client.pg` still wins over a running dev database, but now says so — binding your
2122
+ own pool there loses the single connection and `verifyMarker: false` that database requires, and
2123
+ `resolveRuntimeConnection` warns rather than rebinding silently.
2124
+
2125
+ - [#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
2126
+
2127
+ `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.
2128
+
2129
+ Every engine terminal now raises a stack-owned error in place of the driver's own, each with an `is*` predicate:
2130
+
2131
+ ```typescript
2132
+ import { isUniqueConstraintViolation, isSerializationFailure } from '@opensaas/stack-core'
2133
+
2134
+ try {
2135
+ await context.db.User.create({ data: { email } })
2136
+ } catch (error) {
2137
+ if (isUniqueConstraintViolation(error)) {
2138
+ // { email: 'This email is already in use' }
2139
+ return { fieldErrors: error.fieldErrors }
2140
+ }
2141
+ if (isSerializationFailure(error)) return retry()
2142
+ throw error
2143
+ }
2144
+ ```
2145
+
2146
+ 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.
2147
+
2148
+ 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.
2149
+
2150
+ 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'`.
2151
+
2152
+ `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.
2153
+
2154
+ 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.
2155
+
2156
+ `context.unsafe` is deliberately excluded and still rejects with the driver's own error, consistent with its bypassing everything else.
2157
+
2158
+ `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.
2159
+
2160
+ - [#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
2161
+
2162
+ The MCP route handler typed its `getContext` option as returning the engine's
2163
+ `AccessContext`, which the generated `getContext()` is deliberately not
2164
+ assignable to — the app-facing `Context` carries the secured `db` and none of
2165
+ the engine's plumbing. Wiring the documented route up therefore did not compile.
2166
+ It now takes `AnyStackContext` and narrows once with `engineContextOf`, the same
2167
+ boundary `AdminUI` and `createAuth` already sit on.
2168
+
2169
+ The documented wiring is unchanged, and now type-checks:
2170
+
2171
+ ```typescript
2172
+ // app/api/mcp/[[...transport]]/route.ts
2173
+ import { createMcpHandlers } from '@opensaas/stack-core/mcp'
2174
+ import { createBetterAuthMcpAdapter } from '@opensaas/stack-auth/mcp'
2175
+ import config from '@/opensaas.config'
2176
+ import { auth } from '@/lib/auth'
2177
+ import { getContext } from '@/.opensaas/context'
2178
+
2179
+ const { GET, POST, DELETE } = createMcpHandlers({
2180
+ config: await config,
2181
+ getSession: createBetterAuthMcpAdapter(auth),
2182
+ getContext,
2183
+ })
2184
+
2185
+ export { GET, POST, DELETE }
2186
+ ```
2187
+
2188
+ A caller already passing an engine-face context keeps working — `engineContextOf`
2189
+ returns such a value unchanged.
2190
+
2191
+ - [#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)
2192
+
2193
+ `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.
2194
+
2195
+ `@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:
2196
+
2197
+ ```typescript
2198
+ import { deriveContract, assertRelationGraphAgrees } from '@opensaas/stack-core'
2199
+ import { buildPrismaContract, toEmittedContract } from '@opensaas/stack-core/contract'
2200
+ import pgvector from '@prisma/orm-extension-pgvector/pack'
2201
+
2202
+ const data = deriveContract(config)
2203
+ const contract = buildPrismaContract(data, { packs: { pgvector } })
2204
+ assertRelationGraphAgrees(data, toEmittedContract(contract))
2205
+ ```
2206
+
2207
+ `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.
2208
+
2209
+ 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.
2210
+
2211
+ 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`.
2212
+
2213
+ - [#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
2214
+
2215
+ `createTestDatabase(config)` derives the contract from a config, seeds every declared
2216
+ extension pack's contract space, applies the schema once through the control client's
2217
+ `dbUpdate`, and binds a single-connection Prisma 8 client with the stack's own
2218
+ `originTripwire` installed. `createTestContext(config, session)` is the single-call form.
2219
+ No test fakes the secured surface.
2220
+
2221
+ ```typescript
2222
+ import { createTestDatabase, createPlanRecorder } from '@opensaas/stack-core/testing'
2223
+
2224
+ const recorder = createPlanRecorder()
2225
+ let db: TestDatabase
2226
+
2227
+ beforeAll(async () => {
2228
+ db = await createTestDatabase(config, { middleware: [recorder.middleware] })
2229
+ }, 60_000)
2230
+ afterAll(async () => await db.close())
2231
+ beforeEach(async () => await db.truncate())
2232
+
2233
+ test('the engine scopes the read', async () => {
2234
+ const context = db.context({ userId: 'user-1' })
2235
+ // …
2236
+ expect(recorder.plans.map((plan) => plan.origin)).toEqual(['engine'])
2237
+ })
2238
+ ```
2239
+
2240
+ The map the engine reaches models through is checked as the harness builds it: a client
2241
+ exposing no collection for a model the contract declares throws
2242
+ `OrmCollectionMissingError`, naming the model, the namespace and the keys actually
2243
+ present, rather than building a context that would refuse every operation later.
2244
+
2245
+ Set `DATABASE_URL` to a Postgres server and the identical suite runs there, each file in a
2246
+ database of its own, named `opensaas_test_<YYYYMMDDHHMMSS>_<uuid>` after the exported
2247
+ `ESCAPE_DATABASE_PREFIX` so a run killed before `close()` leaves orphans that are
2248
+ identifiable by age and sweepable; set to anything else the variable is refused by name
2249
+ rather than dialled. `readDatabaseEscape()` lets a test whose guarantee PGlite cannot
2250
+ exercise skip visibly when the escape is unset.
2251
+
2252
+ PGlite, `@electric-sql/pglite-socket`, `@electric-sql/pglite-pgvector` and
2253
+ `@prisma/orm-toolchain` are optional peer dependencies, and `pg` — a real dependency of
2254
+ core, for `@opensaas/stack-core/client` — is imported lazily here too. Every one of them
2255
+ is loaded on demand by this subpath only, so a production install carries no WASM
2256
+ Postgres.
2257
+
2258
+ - [#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.
2259
+
2260
+ - [#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
2261
+
2262
+ `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)).
2263
+
2264
+ All three entry points share one low-level `getContext`, so the one guard there closes this for each of them:
2265
+
2266
+ ```typescript
2267
+ import { getContext, InvalidSessionError } from '@opensaas/stack-core'
2268
+
2269
+ try {
2270
+ await getContext({ userId: undefined })
2271
+ } catch (error) {
2272
+ error instanceof InvalidSessionError // true
2273
+ }
2274
+ ```
2275
+
2276
+ Build the session from an optional identifier by omitting the key rather than setting it to `undefined`:
2277
+
2278
+ ```typescript
2279
+ const context = userId ? await getContext({ userId }) : await getContext()
2280
+ ```
2281
+
2282
+ 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`).
2283
+
2284
+ 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.
2285
+
2286
+ - [#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
2287
+
2288
+ `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:
2289
+
2290
+ ```ts
2291
+ import { createTestContext } from '@opensaas/stack-core/testing'
2292
+ import { createStorageUtils } from '@opensaas/stack-storage/runtime'
2293
+
2294
+ // `config` is a promise whenever the config carries plugins, so resolve it
2295
+ // once and hand the same value to both.
2296
+ const resolved = await config
2297
+
2298
+ const harness = await createTestContext(resolved, null, {
2299
+ storage: createStorageUtils(resolved),
2300
+ })
2301
+
2302
+ const user = await harness.context.db.User.create({
2303
+ data: { name: 'Ada', avatar: new File([bytes], 'avatar.png', { type: 'image/png' }) },
2304
+ })
2305
+ ```
2306
+
2307
+ `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.
2308
+
2309
+ `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.
2310
+
2311
+ Omitting the option is unchanged: a config with no storage still throws on a storage-backed write, exactly as an application with none does.
2312
+
2313
+ Two type predicates now check every member their consumers read, rather than a subset the compiler then takes on trust:
2314
+
2315
+ - `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`.
2316
+ - `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.
2317
+
2318
+ - [#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>`:
2319
+
2320
+ ```typescript
2321
+ import { createTestContext } from '@opensaas/stack-core/testing'
2322
+ import type { Context } from '../.opensaas/types.js'
2323
+
2324
+ const harness = await createTestContext<Context>(config, { userId: 'user-1' })
2325
+ const post = await harness.context.db.Post.where({ id: { equals: postId } }).first()
2326
+ post?.title // typed, not `unknown`
2327
+ ```
2328
+
2329
+ Omitting the type parameter keeps the previous, untyped behavior — no existing call site needs to change.
2330
+
2331
+ - [#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).
2332
+
2333
+ - [#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
2334
+
2335
+ 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.
2336
+
2337
+ ```typescript
2338
+ const { total } = await context.db.Post.where({ published: { equals: true } }).aggregate(
2339
+ (aggregate) => ({ total: aggregate.count() }),
2340
+ )
2341
+
2342
+ const users = await context.db.User.include('posts', (posts) =>
2343
+ posts.combine({
2344
+ published: posts.where({ published: { equals: true } }).count(),
2345
+ total: posts.count(),
2346
+ }),
2347
+ ).all()
2348
+ // each row: { …user, posts: { published: number; total: number } }
2349
+
2350
+ const hits = await context.db.Article.where({ published: true }).nearest(
2351
+ 'embedding',
2352
+ queryVector,
2353
+ {
2354
+ limit: 5,
2355
+ minScore: 0.8,
2356
+ },
2357
+ )
2358
+ for (const { item, score } of hits) console.log(item.title, score)
2359
+ ```
2360
+
2361
+ `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.
2362
+
2363
+ 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.
2364
+
2365
+ `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 `[]`.
2366
+
2367
+ 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.
2368
+
2369
+ `groupBy`, the `*All` family, `*AndCount` and `upsert` remain absent: a method appears only where the engine knows how to scope it.
2370
+
2371
+ - [#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
2372
+
2373
+ 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.
2374
+
2375
+ ```ts
2376
+ // Post.tags: relationship({ ref: 'PostTag.post', many: true })
2377
+ // PostTag : { post: relationship({ ref: 'Post.tags' }), tag: relationship({ ref: 'Tag.posts' }) }
2378
+ await context.serverAction({
2379
+ listKey: 'Post',
2380
+ action: 'addRelated',
2381
+ field: 'tags',
2382
+ parentId: post.id,
2383
+ targetId: tag.id,
2384
+ })
2385
+ // → { added: true, id } — a PostTag row, gated on PostTag's own create access
2386
+ ```
2387
+
2388
+ 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.
2389
+
2390
+ `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.
2391
+
2392
+ 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.
2393
+
2394
+ ### Patch Changes
2395
+
2396
+ - [#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`.
2397
+
2398
+ - [#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`.
2399
+ Run Prisma's `data-type-in-contract` upgrade script and `pnpm generate` to re-emit committed contracts.
2400
+
2401
+ - [#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.
2402
+
2403
+ - [#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`.
2404
+
2405
+ - [#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.
2406
+
2407
+ - [#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.
2408
+
2409
+ - [#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.
2410
+
2411
+ - [#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.
2412
+
2413
+ - [#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.
2414
+
2415
+ - [#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.
2416
+
2417
+ - [#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.
2418
+
2419
+ - [#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.
2420
+
2421
+ - [#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.
2422
+
2423
+ - [#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.
2424
+
2425
+ - [#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.
2426
+
2427
+ - [#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.
2428
+
2429
+ - [#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).
2430
+
2431
+ - [#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.
2432
+
2433
+ - [#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.
2434
+
2435
+ - [#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.
2436
+
2437
+ - [#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.
2438
+
2439
+ - [#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.
2440
+
2441
+ - [#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.
2442
+
2443
+ - [#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.
2444
+
2445
+ - [#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`).
2446
+
2447
+ - [#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.
2448
+
2449
+ - [#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.
2450
+
2451
+ - [#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.
2452
+
2453
+ - [#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).
2454
+
2455
+ - [#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.
2456
+
2457
+ - [#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
2458
+
2459
+ Running `opensaas dev` in a project now starts the Dev database on a free loopback port
2460
+ (persisting under `.opensaas/dev-db`, with `vector` loaded when the config declares the pgvector
2461
+ pack), runs `generate`, runs `prisma db update` against it, and spawns the app — `next dev` by
2462
+ default:
2463
+
2464
+ ```bash
2465
+ opensaas dev # runs `next dev`
2466
+ opensaas dev -- vitest # runs your own command instead
2467
+ ```
2468
+
2469
+ The app child is handed **no** `DATABASE_URL` — one inherited from the environment is removed
2470
+ rather than merely left uninjected: it finds the database through the state file, so
2471
+ the generated runtime reports `'dev-database'` provenance and takes the single-connection binding.
2472
+ `DATABASE_URL` already set is the Database escape — no Dev database starts and the environment
2473
+ passes through untouched. The project's `.env` is loaded before that decision is made, the same
2474
+ file the generated `prisma.config.ts` and `next dev` load, so a `DATABASE_URL` written there is
2475
+ honoured rather than shadowed by a sidecar nothing uses; a shell variable still outranks the file.
2476
+ The database dies with the process; `opensaas.config.ts` is still watched, and the loop shuts the
2477
+ database down on every path that unwinds — a failed reconcile, a Prisma CLI that will not run, and
2478
+ Ctrl-C at the consent prompt included. A `generate` that refuses ends the process outright, past
2479
+ the reach of an async shutdown, so that path is covered synchronously instead: the app child is
2480
+ killed and the run's state file removed.
2481
+
2482
+ Every Prisma CLI spawn is asynchronous now (a `spawnSync` deadlocks the socket server the Dev
2483
+ database is served on), with stdin closed for `contract emit` and the terminal inherited for the
2484
+ boot `db update`, so a destructive plan stops at Prisma's own consent prompt and the app is never
2485
+ started.
2486
+
2487
+ - [#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.
2488
+
2489
+ - [#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.
2490
+
2491
+ - [#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.
2492
+
2493
+ - [#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 `[]`.
2494
+
2495
+ - [#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.
2496
+
2497
+ - [#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`).
2498
+
2499
+ - [#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.
2500
+
2501
+ - [#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`.
2502
+
2503
+ - [#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.
2504
+
2505
+ A `resolveInput` returning `undefined` for such a field now writes nothing; use `null` to clear it.
2506
+
2507
+ - [#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.
2508
+
2509
+ - [#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.
2510
+
2511
+ - [#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()`.
2512
+
2513
+ - [#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.
2514
+
2515
+ - [#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`.
2516
+
2517
+ - [#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.
2518
+
2519
+ - [#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.
2520
+
2521
+ - [#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.
2522
+
2523
+ - [#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.
2524
+
2525
+ - [#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.
2526
+
2527
+ - [#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.
2528
+
2529
+ - [#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`.
2530
+
2531
+ - [#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.
2532
+
2533
+ - [#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.
2534
+
2535
+ - [#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.
2536
+
2537
+ - [#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.
2538
+
2539
+ - [#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.
2540
+
2541
+ - [#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.
2542
+
2543
+ - [#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.
2544
+
2545
+ - [#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.
2546
+
2547
+ - [#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`.
2548
+
2549
+ - [#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.
2550
+
2551
+ - [#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.
2552
+
2553
+ - [#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.
2554
+
2555
+ - [#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.
2556
+
2557
+ - [#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.
2558
+
2559
+ - [#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.
2560
+
2561
+ - [#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.
2562
+
2563
+ - [#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.
2564
+
2565
+ - [#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`.
2566
+
2567
+ - [#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.
2568
+
2569
+ - [#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.
2570
+
2571
+ - [#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.
2572
+
2573
+ - [#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.
2574
+
2575
+ - [#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`.
2576
+
2577
+ - [#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).
2578
+
2579
+ - [#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.
2580
+
2581
+ - [#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`.
2582
+
2583
+ - [#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.
2584
+
2585
+ - [#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.
2586
+
2587
+ - [#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.
2588
+
2589
+ - [#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.
2590
+
2591
+ - [#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.
2592
+
2593
+ - [#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.
2594
+
2595
+ - [#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.
2596
+
2597
+ - [#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.
2598
+
2599
+ - [#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.
2600
+
2601
+ - [#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`.
2602
+
2603
+ - [#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`.
2604
+
2605
+ - [#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.
2606
+
2607
+ - [#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.
2608
+
2609
+ - [#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.
2610
+
2611
+ - [#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.
2612
+
2613
+ - [#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.
2614
+
2615
+ - [#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.
2616
+
2617
+ - [#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.
2618
+
2619
+ - [#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.
2620
+
2621
+ - [#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`.
2622
+
2623
+ - [#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.
2624
+
2625
+ - [#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.
2626
+
2627
+ - [#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.
2628
+
2629
+ - [#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.
2630
+
2631
+ 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):
2632
+
2633
+ ```typescript
2634
+ // Non-sudo create with metadata-shaped input is refused — upload a File instead.
2635
+ await context.db.Doc.create({ data: { attachment: someMetadata } }) // throws
2636
+
2637
+ // Sudo may still point a new row at an existing asset.
2638
+ await context.sudo().db.Doc.create({ data: { attachment: someMetadata } })
2639
+
2640
+ // Non-sudo update succeeds only when the value matches what's already stored.
2641
+ await context.db.Doc.update({ where: { id }, data: { attachment: row.attachment } }) // OK
2642
+ await context.db.Doc.update({ where: { id }, data: { attachment: otherRowsMetadata } }) // throws
2643
+ ```
2644
+
2645
+ 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.
2646
+
2647
+ `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`.
2648
+
2649
+ - [#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.
2650
+
2651
+ - [#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.
2652
+
2653
+ - [#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.
2654
+
2655
+ - [`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.
2656
+
2657
+ - [#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.
2658
+
2659
+ - [#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)).
2660
+
2661
+ - [#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.
2662
+
2663
+ - [#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.
2664
+
2665
+ - [#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.
2666
+
2667
+ - [#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.
2668
+
2669
+ - [#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.
2670
+
2671
+ - [#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.
2672
+
2673
+ - [#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.
2674
+
2675
+ - [#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)).
2676
+
2677
+ 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.
2678
+
2679
+ - [#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.
2680
+
2681
+ - [#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).
2682
+
2683
+ - [#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.
2684
+
2685
+ - [#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.
2686
+
2687
+ - [#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.
2688
+
2689
+ - [#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`.
2690
+
2691
+ - [#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.
2692
+
2693
+ - [#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`.
2694
+
2695
+ - [#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.
2696
+
2697
+ - [#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
2698
+
2699
+ `decimal()` had no registered UI component, so a field declared with it logged
2700
+ `No component registered for field type: decimal` and could not be edited at
2701
+ all. It now has a form component and reuses the existing integer list-table
2702
+ cell, registered under `decimal` in the usual registries — no wiring needed:
2703
+
2704
+ ```typescript
2705
+ // opensaas.config.ts
2706
+ fields: {
2707
+ price: decimal({ precision: 10, scale: 2 }),
2708
+ }
2709
+ ```
2710
+
2711
+ Prisma 8's numeric codec is a branded `string`, never a `decimal.js`
2712
+ `Decimal` — confirmed empirically by writing a value with more significant
2713
+ digits than a JS `number` can hold and reading it back. So the value read
2714
+ from and written to `context.db` is a plain numeric-text string
2715
+ (`'19.99'`) on both sides, full precision intact through the server/client
2716
+ boundary with no special encoding needed. `@opensaas/stack-core`'s
2717
+ `decimal()` doc comments, which described the pre-Prisma-8 `Decimal`
2718
+ assumption, are corrected to match.
2719
+
2720
+ `DecimalField` is exported for custom UIs:
2721
+
2722
+ ```typescript
2723
+ import { DecimalField } from '@opensaas/stack-ui/fields'
2724
+ ```
2725
+
2726
+ - [#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.
2727
+
2728
+ - [#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.
2729
+ 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`.
2730
+
2731
+ - [#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
2732
+
2733
+ - [#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.
2734
+
2735
+ - [#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).
2736
+
2737
+ - [#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.
2738
+
2739
+ - [#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`).
2740
+
2741
+ - [#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.
2742
+
2743
+ - [#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`.
2744
+
2745
+ - [#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`.
2746
+
2747
+ - [#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.
2748
+
2749
+ - [#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.
2750
+
3
2751
  ## 0.43.0
4
2752
 
5
2753
  ### Minor Changes
@@ -257,6 +3005,8 @@
257
3005
 
258
3006
  - [#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
3007
 
3008
+ > **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)`.
3009
+
260
3010
  - [#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
3011
 
262
3012
  ## 0.39.2
@@ -350,6 +3100,7 @@
350
3100
 
351
3101
  Three behavior changes to be aware of when upgrading:
352
3102
 
3103
+ > **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
3104
  - 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
3105
  - 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
3106
  - 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 +3968,8 @@
1217
3968
 
1218
3969
  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
3970
 
3971
+ > **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.
3972
+
1220
3973
  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
3974
 
1222
3975
  ```typescript