cvx-kit 0.2.0 → 2.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (372) hide show
  1. package/README.md +556 -99
  2. package/dist/agent-tools.d.mts +39 -26
  3. package/dist/agent-tools.mjs +1 -1
  4. package/dist/agent-tools.mjs.map +1 -1
  5. package/dist/auth.d.mts +120 -308
  6. package/dist/auth.mjs +1 -1
  7. package/dist/auth.mjs.map +1 -1
  8. package/dist/components/approvals/_generated/api.d.mts +7 -9
  9. package/dist/components/approvals/_generated/api.mjs.map +1 -1
  10. package/dist/components/approvals/_generated/component.d.mts +1 -4
  11. package/dist/components/approvals/_generated/dataModel.d.mts +5 -8
  12. package/dist/components/approvals/_generated/server.d.mts +12 -15
  13. package/dist/components/approvals/_generated/server.mjs.map +1 -1
  14. package/dist/components/approvals/audit.d.mts +8 -9
  15. package/dist/components/approvals/audit.mjs +1 -1
  16. package/dist/components/approvals/audit.mjs.map +1 -1
  17. package/dist/components/approvals/client.d.mts +11 -12
  18. package/dist/components/approvals/client.mjs +1 -1
  19. package/dist/components/approvals/client.mjs.map +1 -1
  20. package/dist/components/approvals/constants.d.mts +30 -31
  21. package/dist/components/approvals/constants.mjs.map +1 -1
  22. package/dist/components/approvals/convex.config.d.mts +0 -2
  23. package/dist/components/approvals/convex.config.mjs.map +1 -1
  24. package/dist/components/approvals/decisions.d.mts +13 -17
  25. package/dist/components/approvals/decisions.mjs +1 -1
  26. package/dist/components/approvals/decisions.mjs.map +1 -1
  27. package/dist/components/approvals/functions.d.mts +3 -4
  28. package/dist/components/approvals/functions.mjs +1 -1
  29. package/dist/components/approvals/functions.mjs.map +1 -1
  30. package/dist/components/approvals/health.d.mts +2 -3
  31. package/dist/components/approvals/health.mjs.map +1 -1
  32. package/dist/components/approvals/requests.d.mts +114 -131
  33. package/dist/components/approvals/requests.mjs +1 -1
  34. package/dist/components/approvals/requests.mjs.map +1 -1
  35. package/dist/components/approvals/schema.d.ts +106 -315
  36. package/dist/components/approvals/schema.js +1 -1
  37. package/dist/components/approvals/validators.d.mts +323 -395
  38. package/dist/components/approvals/validators.mjs +1 -1
  39. package/dist/components/approvals/validators.mjs.map +1 -1
  40. package/dist/components/approvals/workflow.d.mts +4 -5
  41. package/dist/components/approvals/workflow.mjs +1 -1
  42. package/dist/components/approvals/workflow.mjs.map +1 -1
  43. package/dist/components/approvals/workflow_steps.d.mts +16 -17
  44. package/dist/components/approvals/workflow_steps.mjs +1 -1
  45. package/dist/components/approvals/workflow_steps.mjs.map +1 -1
  46. package/dist/components/foundation/_generated/api.d.mts +6 -8
  47. package/dist/components/foundation/_generated/api.mjs.map +1 -1
  48. package/dist/components/foundation/_generated/component.d.mts +1 -4
  49. package/dist/components/foundation/_generated/dataModel.d.mts +5 -8
  50. package/dist/components/foundation/_generated/server.d.mts +12 -15
  51. package/dist/components/foundation/_generated/server.mjs.map +1 -1
  52. package/dist/components/foundation/client.d.mts +45 -38
  53. package/dist/components/foundation/client.mjs +1 -1
  54. package/dist/components/foundation/client.mjs.map +1 -1
  55. package/dist/components/foundation/convex.config.d.mts +0 -2
  56. package/dist/components/foundation/convex.config.mjs.map +1 -1
  57. package/dist/components/foundation/functions.d.mts +2 -3
  58. package/dist/components/foundation/functions.mjs.map +1 -1
  59. package/dist/components/foundation/modules/command/command.d.mts +65 -17
  60. package/dist/components/foundation/modules/command/command.mjs +1 -1
  61. package/dist/components/foundation/modules/command/command.mjs.map +1 -1
  62. package/dist/components/foundation/modules/command/lifecycle.d.mts +78 -0
  63. package/dist/components/foundation/modules/command/lifecycle.mjs +2 -0
  64. package/dist/components/foundation/modules/command/lifecycle.mjs.map +1 -0
  65. package/dist/components/foundation/modules/observability/observability.d.mts +13 -6
  66. package/dist/components/foundation/modules/observability/observability.mjs +1 -1
  67. package/dist/components/foundation/modules/observability/observability.mjs.map +1 -1
  68. package/dist/components/foundation/modules/query/query.d.mts +11 -12
  69. package/dist/components/foundation/modules/query/query.mjs +1 -1
  70. package/dist/components/foundation/modules/query/query.mjs.map +1 -1
  71. package/dist/components/foundation/operation.d.mts +72 -0
  72. package/dist/components/foundation/operation.mjs +2 -0
  73. package/dist/components/foundation/operation.mjs.map +1 -0
  74. package/dist/components/foundation/result.d.mts +7 -8
  75. package/dist/components/foundation/result.mjs.map +1 -1
  76. package/dist/components/foundation/schema.d.ts +0 -2
  77. package/dist/components/foundation/telemetry.d.mts +2 -3
  78. package/dist/components/foundation/telemetry.mjs +1 -1
  79. package/dist/components/foundation/telemetry.mjs.map +1 -1
  80. package/dist/contracts.d.mts +5 -0
  81. package/dist/contracts.mjs +1 -0
  82. package/dist/crud.d.mts +185 -27
  83. package/dist/crud.mjs +1 -1
  84. package/dist/crud.mjs.map +1 -1
  85. package/dist/effect.d.mts +16 -0
  86. package/dist/effect.mjs +1 -0
  87. package/dist/errors.d.mts +6 -6
  88. package/dist/errors.mjs +1 -1
  89. package/dist/errors.mjs.map +1 -1
  90. package/dist/filters.d.mts +4 -0
  91. package/dist/filters.mjs +1 -0
  92. package/dist/idempotency.d.mts +2 -0
  93. package/dist/idempotency.mjs +1 -0
  94. package/dist/index.d.mts +14 -7
  95. package/dist/index.mjs +1 -1
  96. package/dist/json-schema.d.mts +40 -0
  97. package/dist/json-schema.mjs +2 -0
  98. package/dist/json-schema.mjs.map +1 -0
  99. package/dist/k/compile.d.mts +17 -0
  100. package/dist/k/compile.mjs +2 -0
  101. package/dist/k/compile.mjs.map +1 -0
  102. package/dist/k/dates.d.mts +23 -0
  103. package/dist/k/dates.mjs +2 -0
  104. package/dist/k/dates.mjs.map +1 -0
  105. package/dist/k/formats.d.mts +24 -0
  106. package/dist/k/formats.mjs +2 -0
  107. package/dist/k/formats.mjs.map +1 -0
  108. package/dist/k/index.d.mts +32 -0
  109. package/dist/k/index.mjs +2 -0
  110. package/dist/k/index.mjs.map +1 -0
  111. package/dist/k/issues.d.mts +31 -0
  112. package/dist/k/issues.mjs +2 -0
  113. package/dist/k/issues.mjs.map +1 -0
  114. package/dist/k/kinds.d.mts +81 -0
  115. package/dist/k/kinds.mjs +2 -0
  116. package/dist/k/kinds.mjs.map +1 -0
  117. package/dist/k/object.d.mts +43 -0
  118. package/dist/k/object.mjs +2 -0
  119. package/dist/k/object.mjs.map +1 -0
  120. package/dist/k/parse.d.mts +29 -0
  121. package/dist/k/parse.mjs +2 -0
  122. package/dist/k/parse.mjs.map +1 -0
  123. package/dist/k/schema.d.mts +100 -0
  124. package/dist/k/schema.mjs +2 -0
  125. package/dist/k/schema.mjs.map +1 -0
  126. package/dist/k/standard.d.mts +8 -0
  127. package/dist/k/standard.mjs +2 -0
  128. package/dist/k/standard.mjs.map +1 -0
  129. package/dist/k/types.d.mts +64 -0
  130. package/dist/k/types.mjs +1 -0
  131. package/dist/k.d.mts +8 -0
  132. package/dist/k.mjs +1 -0
  133. package/dist/middleware.d.mts +8 -11
  134. package/dist/middleware.mjs +1 -1
  135. package/dist/middleware.mjs.map +1 -1
  136. package/dist/modules/contracts/binding.d.mts +23 -0
  137. package/dist/modules/contracts/binding.mjs +2 -0
  138. package/dist/modules/contracts/binding.mjs.map +1 -0
  139. package/dist/modules/contracts/contract.d.mts +67 -0
  140. package/dist/modules/contracts/contract.mjs +2 -0
  141. package/dist/modules/contracts/contract.mjs.map +1 -0
  142. package/dist/modules/contracts/convex.d.mts +18 -0
  143. package/dist/modules/contracts/convex.mjs +2 -0
  144. package/dist/modules/contracts/convex.mjs.map +1 -0
  145. package/dist/modules/contracts/domain.d.mts +62 -0
  146. package/dist/modules/contracts/domain.mjs +2 -0
  147. package/dist/modules/contracts/domain.mjs.map +1 -0
  148. package/dist/modules/contracts/errors.d.mts +737 -0
  149. package/dist/modules/contracts/errors.mjs +2 -0
  150. package/dist/modules/contracts/errors.mjs.map +1 -0
  151. package/dist/modules/contracts/exposure.d.mts +103 -0
  152. package/dist/modules/contracts/exposure.mjs +2 -0
  153. package/dist/modules/contracts/exposure.mjs.map +1 -0
  154. package/dist/modules/contracts/idempotency.d.mts +85 -0
  155. package/dist/modules/contracts/idempotency.mjs +2 -0
  156. package/dist/modules/contracts/idempotency.mjs.map +1 -0
  157. package/dist/modules/contracts/lazy.d.mts +6 -0
  158. package/dist/modules/contracts/lazy.mjs +2 -0
  159. package/dist/modules/contracts/lazy.mjs.map +1 -0
  160. package/dist/modules/contracts/standard.d.mts +17 -0
  161. package/dist/modules/contracts/standard.mjs +2 -0
  162. package/dist/modules/contracts/standard.mjs.map +1 -0
  163. package/dist/modules/contracts/workflow.d.mts +165 -0
  164. package/dist/modules/contracts/workflow.mjs +2 -0
  165. package/dist/modules/contracts/workflow.mjs.map +1 -0
  166. package/dist/modules/effect/action.d.mts +63 -0
  167. package/dist/modules/effect/action.mjs +2 -0
  168. package/dist/modules/effect/action.mjs.map +1 -0
  169. package/dist/modules/effect/agent-tools.d.mts +2 -0
  170. package/dist/modules/effect/agent-tools.mjs +1 -0
  171. package/dist/modules/effect/api-runtime.d.mts +36 -0
  172. package/dist/modules/effect/api-runtime.mjs +2 -0
  173. package/dist/modules/effect/api-runtime.mjs.map +1 -0
  174. package/dist/modules/effect/api.d.mts +46 -0
  175. package/dist/modules/effect/api.mjs +2 -0
  176. package/dist/modules/effect/api.mjs.map +1 -0
  177. package/dist/modules/effect/auth.d.mts +46 -0
  178. package/dist/modules/effect/auth.mjs +2 -0
  179. package/dist/modules/effect/auth.mjs.map +1 -0
  180. package/dist/modules/effect/client.d.mts +15 -0
  181. package/dist/modules/effect/client.mjs +1 -0
  182. package/dist/modules/effect/command.d.mts +108 -0
  183. package/dist/modules/effect/command.mjs +2 -0
  184. package/dist/modules/effect/command.mjs.map +1 -0
  185. package/dist/modules/effect/crud.d.mts +885 -0
  186. package/dist/modules/effect/crud.mjs +2 -0
  187. package/dist/modules/effect/crud.mjs.map +1 -0
  188. package/dist/modules/effect/domain.d.mts +82 -0
  189. package/dist/modules/effect/domain.mjs +2 -0
  190. package/dist/modules/effect/domain.mjs.map +1 -0
  191. package/dist/modules/effect/errors.d.mts +13 -0
  192. package/dist/modules/effect/errors.mjs +2 -0
  193. package/dist/modules/effect/errors.mjs.map +1 -0
  194. package/dist/modules/effect/failure-audit.d.mts +48 -0
  195. package/dist/modules/effect/failure-audit.mjs +2 -0
  196. package/dist/modules/effect/failure-audit.mjs.map +1 -0
  197. package/dist/modules/effect/failures.d.mts +21 -0
  198. package/dist/modules/effect/failures.mjs +2 -0
  199. package/dist/modules/effect/failures.mjs.map +1 -0
  200. package/dist/modules/effect/foundation.d.mts +23 -0
  201. package/dist/modules/effect/foundation.mjs +2 -0
  202. package/dist/modules/effect/foundation.mjs.map +1 -0
  203. package/dist/modules/effect/idempotency.d.mts +29 -0
  204. package/dist/modules/effect/idempotency.mjs +2 -0
  205. package/dist/modules/effect/idempotency.mjs.map +1 -0
  206. package/dist/modules/effect/input.d.mts +10 -0
  207. package/dist/modules/effect/input.mjs +2 -0
  208. package/dist/modules/effect/input.mjs.map +1 -0
  209. package/dist/modules/effect/normalize.d.mts +7 -0
  210. package/dist/modules/effect/normalize.mjs +2 -0
  211. package/dist/modules/effect/normalize.mjs.map +1 -0
  212. package/dist/modules/effect/operation.d.mts +148 -0
  213. package/dist/modules/effect/operation.mjs +2 -0
  214. package/dist/modules/effect/operation.mjs.map +1 -0
  215. package/dist/modules/effect/query.d.mts +90 -0
  216. package/dist/modules/effect/query.mjs +2 -0
  217. package/dist/modules/effect/query.mjs.map +1 -0
  218. package/dist/modules/effect/schema.d.mts +30 -0
  219. package/dist/modules/effect/schema.mjs +2 -0
  220. package/dist/modules/effect/schema.mjs.map +1 -0
  221. package/dist/modules/effect/scope.d.mts +25 -0
  222. package/dist/modules/effect/scope.mjs +2 -0
  223. package/dist/modules/effect/scope.mjs.map +1 -0
  224. package/dist/modules/effect/workflow.d.mts +75 -0
  225. package/dist/modules/effect/workflow.mjs +2 -0
  226. package/dist/modules/effect/workflow.mjs.map +1 -0
  227. package/dist/modules/foundation/foundation.d.mts +108 -0
  228. package/dist/modules/foundation/foundation.mjs +2 -0
  229. package/dist/modules/foundation/foundation.mjs.map +1 -0
  230. package/dist/modules/foundation/operation.d.mts +139 -0
  231. package/dist/modules/foundation/operation.mjs +2 -0
  232. package/dist/modules/foundation/operation.mjs.map +1 -0
  233. package/dist/namespace.d.mts +104 -0
  234. package/dist/namespace.mjs +2 -0
  235. package/dist/namespace.mjs.map +1 -0
  236. package/dist/oxlint/architecture.d.mts +23 -0
  237. package/dist/oxlint/architecture.mjs +2 -0
  238. package/dist/oxlint/architecture.mjs.map +1 -0
  239. package/dist/oxlint/ast.d.mts +51 -0
  240. package/dist/oxlint/ast.mjs +2 -0
  241. package/dist/oxlint/ast.mjs.map +1 -0
  242. package/dist/oxlint/components.d.mts +4 -0
  243. package/dist/oxlint/components.mjs +2 -0
  244. package/dist/oxlint/components.mjs.map +1 -0
  245. package/dist/oxlint/ownership.d.mts +59 -0
  246. package/dist/oxlint/ownership.mjs +2 -0
  247. package/dist/oxlint/ownership.mjs.map +1 -0
  248. package/dist/oxlint/reserved-files.d.mts +4 -0
  249. package/dist/oxlint/reserved-files.mjs +2 -0
  250. package/dist/oxlint/reserved-files.mjs.map +1 -0
  251. package/dist/oxlint.d.mts +9 -0
  252. package/dist/oxlint.mjs +2 -0
  253. package/dist/oxlint.mjs.map +1 -0
  254. package/dist/querying/cursors.d.mts +94 -0
  255. package/dist/querying/cursors.mjs +2 -0
  256. package/dist/querying/cursors.mjs.map +1 -0
  257. package/dist/querying/execution.d.mts +40 -0
  258. package/dist/querying/execution.mjs +2 -0
  259. package/dist/querying/execution.mjs.map +1 -0
  260. package/dist/querying/failures.d.mts +11 -0
  261. package/dist/querying/failures.mjs +2 -0
  262. package/dist/querying/failures.mjs.map +1 -0
  263. package/dist/querying/filter-boundary.d.mts +25 -0
  264. package/dist/querying/filter-boundary.mjs +2 -0
  265. package/dist/querying/filter-boundary.mjs.map +1 -0
  266. package/dist/querying/filters.d.mts +180 -0
  267. package/dist/querying/filters.mjs +2 -0
  268. package/dist/querying/filters.mjs.map +1 -0
  269. package/dist/querying/planner.d.mts +61 -0
  270. package/dist/querying/planner.mjs +2 -0
  271. package/dist/querying/planner.mjs.map +1 -0
  272. package/dist/querying/relationships.d.mts +58 -0
  273. package/dist/querying/relationships.mjs +2 -0
  274. package/dist/querying/relationships.mjs.map +1 -0
  275. package/dist/querying/search.d.mts +69 -0
  276. package/dist/querying/search.mjs +2 -0
  277. package/dist/querying/search.mjs.map +1 -0
  278. package/dist/querying/security.d.mts +123 -0
  279. package/dist/querying/security.mjs +2 -0
  280. package/dist/querying/security.mjs.map +1 -0
  281. package/dist/querying/shared/ast.d.mts +26 -0
  282. package/dist/querying/shared/ast.mjs +2 -0
  283. package/dist/querying/shared/ast.mjs.map +1 -0
  284. package/dist/querying/shared/contract.d.mts +98 -0
  285. package/dist/querying/shared/contract.mjs +2 -0
  286. package/dist/querying/shared/contract.mjs.map +1 -0
  287. package/dist/querying/shared/evaluate.d.mts +5 -0
  288. package/dist/querying/shared/evaluate.mjs +2 -0
  289. package/dist/querying/shared/evaluate.mjs.map +1 -0
  290. package/dist/querying/shared/filters.d.mts +65 -0
  291. package/dist/querying/shared/filters.mjs +2 -0
  292. package/dist/querying/shared/filters.mjs.map +1 -0
  293. package/dist/querying/shared/native-json.d.mts +7 -0
  294. package/dist/querying/shared/native-json.mjs +2 -0
  295. package/dist/querying/shared/native-json.mjs.map +1 -0
  296. package/dist/querying/shared/page.d.mts +20 -0
  297. package/dist/querying/shared/page.mjs +2 -0
  298. package/dist/querying/shared/page.mjs.map +1 -0
  299. package/dist/querying.d.mts +82 -0
  300. package/dist/querying.mjs +2 -0
  301. package/dist/querying.mjs.map +1 -0
  302. package/dist/react/failures.d.mts +24 -0
  303. package/dist/react/failures.mjs +2 -0
  304. package/dist/react/failures.mjs.map +1 -0
  305. package/dist/react/optimistic.d.mts +46 -0
  306. package/dist/react/optimistic.mjs +2 -0
  307. package/dist/react/optimistic.mjs.map +1 -0
  308. package/dist/react/pagination-state.d.mts +39 -0
  309. package/dist/react/pagination-state.mjs +2 -0
  310. package/dist/react/pagination-state.mjs.map +1 -0
  311. package/dist/react/use-command.d.mts +22 -0
  312. package/dist/react/use-command.mjs +2 -0
  313. package/dist/react/use-command.mjs.map +1 -0
  314. package/dist/react/use-paginated-list.d.mts +34 -0
  315. package/dist/react/use-paginated-list.mjs +2 -0
  316. package/dist/react/use-paginated-list.mjs.map +1 -0
  317. package/dist/react.d.mts +6 -0
  318. package/dist/react.mjs +1 -0
  319. package/dist/registration.d.mts +65 -0
  320. package/dist/registration.mjs +2 -0
  321. package/dist/registration.mjs.map +1 -0
  322. package/dist/relations-public.d.mts +2 -0
  323. package/dist/relations-public.mjs +1 -0
  324. package/dist/relations.d.mts +274 -0
  325. package/dist/relations.mjs +2 -0
  326. package/dist/relations.mjs.map +1 -0
  327. package/dist/state-machine.d.mts +1 -4
  328. package/dist/state-machine.mjs.map +1 -1
  329. package/dist/table.d.mts +222 -0
  330. package/dist/table.mjs +2 -0
  331. package/dist/table.mjs.map +1 -0
  332. package/dist/tenancy.d.mts +6 -8
  333. package/dist/tenancy.mjs +1 -1
  334. package/dist/tenancy.mjs.map +1 -1
  335. package/dist/triggers.d.mts +12 -10
  336. package/dist/triggers.mjs +1 -1
  337. package/dist/triggers.mjs.map +1 -1
  338. package/dist/webhooks.d.mts +22 -112
  339. package/dist/webhooks.mjs +1 -1
  340. package/dist/webhooks.mjs.map +1 -1
  341. package/dist/workflow.d.mts +2 -0
  342. package/dist/workflow.mjs +1 -0
  343. package/dist/zod.d.mts +30 -0
  344. package/dist/zod.mjs +2 -0
  345. package/dist/zod.mjs.map +1 -0
  346. package/package.json +145 -33
  347. package/src/test.ts +9 -17
  348. package/CHANGELOG.md +0 -145
  349. package/ROADMAP.md +0 -126
  350. package/dist/zod-table.d.mts +0 -175
  351. package/dist/zod-table.mjs +0 -2
  352. package/dist/zod-table.mjs.map +0 -1
  353. package/docs/agent-tools.md +0 -41
  354. package/docs/approvals.md +0 -200
  355. package/docs/architecture.md +0 -124
  356. package/docs/auth.md +0 -218
  357. package/docs/commands.md +0 -278
  358. package/docs/conventions.md +0 -291
  359. package/docs/crud.md +0 -62
  360. package/docs/llms.md +0 -220
  361. package/docs/maintainability.md +0 -124
  362. package/docs/migration.md +0 -351
  363. package/docs/plans/2026-08-14-001-feat-v0.1.0-feature-set-plan.md +0 -461
  364. package/docs/plans/2026-08-21-0930-feat-resolve-organization-hook-plan.md +0 -178
  365. package/docs/tenancy.md +0 -179
  366. package/docs/triggers.md +0 -75
  367. package/docs/upgrading.md +0 -175
  368. package/docs/webhooks.md +0 -58
  369. package/docs/zod-table.md +0 -173
  370. package/scripts/convex-config-bridge.mjs +0 -55
  371. package/scripts/extract-changelog.mjs +0 -29
  372. package/scripts/smoke-packed-components.mjs +0 -374
package/README.md CHANGED
@@ -3,18 +3,24 @@
3
3
  [![CI](https://github.com/ImRLopezAG/cvx-kit/actions/workflows/ci.yml/badge.svg)](https://github.com/ImRLopezAG/cvx-kit/actions/workflows/ci.yml)
4
4
  [![npm](https://img.shields.io/npm/v/cvx-kit)](https://www.npmjs.com/package/cvx-kit)
5
5
 
6
- Reusable Convex application kit: foundation kernels, a generic approvals
7
- component, zod table boundaries, auth-aware function constructors with
8
- per-app role vocabularies, an application trigger registry, and an audited
9
- command protocol.
6
+ Reusable Convex application kit: `k` validators built on native Convex
7
+ validators, table boundaries, foundation kernels, a generic approvals
8
+ component, auth-aware function constructors with per-app role vocabularies, an
9
+ application trigger registry, and an audited command protocol.
10
10
 
11
11
  ```sh
12
12
  bun add cvx-kit
13
13
  # or: npm install cvx-kit
14
14
  ```
15
15
 
16
- Supported versions: Convex `^1.43.0`, Zod `^4.0.0`, Bun `1.3+`, and Node.js
17
- `24+` with npm `11+`. The library runtime is ESM-only.
16
+ Supported versions: Convex `^1.46.0`, convex-helpers `>=0.1.130 <0.2.0`, Bun
17
+ `1.3+`, and Node.js `24+` with npm `11+`. The library runtime is ESM-only.
18
+ Zod is not required. Install `zod` (`^4.6.7`) only to use the optional
19
+ `cvx-kit/zod` interop entry; install `effect` (`>=4.0.1 <5`) for
20
+ `cvx-kit/effect`.
21
+
22
+ To upgrade from cvx-kit 0.1.x (Zod), follow the
23
+ [2.0 migration guide](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/migration-v2.md).
18
24
 
19
25
  ## Toolchain
20
26
 
@@ -28,58 +34,381 @@ Supported versions: Convex `^1.43.0`, Zod `^4.0.0`, Bun `1.3+`, and Node.js
28
34
 
29
35
  ## Documentation
30
36
 
31
- Full docs ship with the package — `node_modules/cvx-kit/docs/` when installed,
32
- authored in [`src/docs/`](./src/docs/):
33
-
34
- - [`architecture.md`](./src/docs/architecture.md) — the layered application shape the kit encodes
35
- - [`conventions.md`](./src/docs/conventions.md) — the doctrine: folder structure, file anatomy, naming grammar, import rules
36
- - [`zod-table.md`](./src/docs/zod-table.md) — one zod shape per entity, masked into every boundary
37
- - [`auth.md`](./src/docs/auth.md) — auth-aware function constructors from injected policy
38
- - [`commands.md`](./src/docs/commands.md) — Foundation, the audited command protocol, observability
39
- - [`triggers.md`](./src/docs/triggers.md) — trigger registry, timestamps/append-only/no-delete
40
- - [`approvals.md`](./src/docs/approvals.md) — declarative approval workflows
41
- - [`tenancy.md`](./src/docs/tenancy.md) — row-level security (roles) with opt-in multi-tenant isolation
42
- - [`crud.md`](./src/docs/crud.md) — the CRUD command factory
43
- - [`webhooks.md`](./src/docs/webhooks.md) — the sanctioned webhook boundary
44
- - [`agent-tools.md`](./src/docs/agent-tools.md) — agent tools that are audited commands
45
- - [`upgrading.md`](./src/docs/upgrading.md) — 0.0.x → 0.1.0, old way → new way
46
- - [`maintainability.md`](./src/docs/maintainability.md) — keeping a Convex app maintainable long-term
47
- - [`migration.md`](./src/docs/migration.md) — restructuring an existing raw Convex project into this architecture
48
- - [`llms.md`](./src/docs/llms.md) — condensed reference to paste into an LLM/agent context
37
+ Full docs live on [GitHub](https://github.com/ImRLopezAG/cvx-kit/tree/main/skills/cvx-kit/references)
38
+ and are bundled with the repository's [agent skill](https://github.com/ImRLopezAG/cvx-kit/tree/main/skills/cvx-kit).
39
+ The npm package includes this README; full docs and skills are installed separately.
40
+
41
+ If you use a coding agent, install the cvx-kit skill from your application directory:
42
+
43
+ ```sh
44
+ npx skills add ImRLopezAG/cvx-kit --skill cvx-kit
45
+ ```
46
+
47
+ The [skills CLI](https://www.skills.sh/docs) lets you choose your agent. Installation
48
+ is project-scoped by default; add `--global` only for a user-wide install. Public
49
+ GitHub installation needs no login. Preview available skills with
50
+ `npx skills add ImRLopezAG/cvx-kit --list`.
51
+ The skill reads the guides needed for each task instead of loading all docs.
52
+ Check your installed package version against the skill's source revision before
53
+ using newer APIs. For a release containing the skill, use its GitHub tag URL
54
+ (`https://github.com/ImRLopezAG/cvx-kit/tree/<tag>/skills/cvx-kit`) as the install source.
55
+
56
+ Maintainers edit `skills/cvx-kit/references/` directly. CI verifies that relative
57
+ links remain inside the installed skill with `bun run skills:check`.
58
+
59
+ Guides:
60
+
61
+ - [`native-id-relations.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/native-id-relations.md) — native-ID union links, authorized inverse pages, and migration
62
+
63
+ - [`architecture.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/architecture.md) — the layered application shape the kit encodes
64
+ - [`conventions.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/conventions.md) — the doctrine: folder structure, file anatomy, naming grammar, import rules
65
+ - [`k.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/k.md) — the `k` validators: factories, chains, parse and issues, dates, JSON Schema, Zod interop
66
+ - [`table.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/table.md) — one field object per entity, masked into every boundary
67
+ - [`migration-v2.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/migration-v2.md) — moving an app from cvx-kit 0.1.x (Zod) to 2.0
68
+ - [`auth.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/auth.md) — auth-aware function constructors from injected policy
69
+ - [`commands.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/commands.md) — Effect command declarations, lifecycle, and migration
70
+ - [`effect.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/effect.md) — opt-in Effect v4 registries, injected services, and shared API builders
71
+ - [`domain-operations.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/domain-operations.md) — server domain/API examples, contracts, errors, receipts, workflow steps, and selected tools
72
+ - [`triggers.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/triggers.md) — trigger registry, timestamps/append-only/no-delete
73
+ - [`approvals.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/approvals.md) — declarative approval workflows
74
+ - [`tenancy.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/tenancy.md) — row-level security (roles) with opt-in multi-tenant isolation
75
+ - [`crud.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/crud.md) — the CRUD command factory
76
+ - [`webhooks.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/webhooks.md) — the sanctioned webhook boundary
77
+ - [`agent-tools.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/agent-tools.md) — agent tools that are audited commands
78
+ - [`upgrading.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/upgrading.md) — upgrades within 0.1.x, old way → new way
79
+ - [`maintainability.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/maintainability.md) — keeping a Convex app maintainable long-term
80
+ - [`migration.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/migration.md) — restructuring an existing raw Convex project into this architecture
81
+ - [`llms.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/llms.md) — optional condensed reference for coding agents
82
+
83
+ ## Per-request import cost
84
+
85
+ Convex evaluates a function's whole static import graph on every request, and queries and mutations cannot use dynamic `import()`. Whatever a module builds at import is paid on every call. The kit builders do not convert validators at registration. Convex reads them when it exports function metadata at push, and the handler builds its parse state on first call. To keep a module from building schemas for functions it is not serving, declare them lazily:
86
+
87
+ ```ts
88
+ export const listPayments = authQuery({
89
+ get args() {
90
+ return financeContract.queries.listPayments.input
91
+ },
92
+ get returns() {
93
+ return financeContract.queries.listPayments.result
94
+ },
95
+ handler: (ctx, args) => ctx.queries.finance.exec('listPayments', args),
96
+ })
97
+ ```
98
+
99
+ With `args: contract.queries.x.input`, the property read builds the schema at import. A getter defers it, which makes the getter form the recommended one: on the benchmark app (about 30 tables, 14 functions) module load drops from 8.43 ms to 6.30 ms. The property form stays supported, and the v2 codemod writes getters unless given `--no-getters`. Declare contract operations as getters too (see the [domain contracts guide](./skills/cvx-kit/references/domain-contracts.md)), so that reading or executing one operation builds and binds only that operation. Keep the trigger registry out of query modules with `createAuthReaders` (see `cvx-kit/auth` below). Validation is identical in every form.
100
+
101
+ Two more things keep the deferral intact. First, a `paginationOpts(...)` or `pageDto(...)` call at module scope outside a contract still builds at import, so put it behind a getter or inside the operation that uses it. Second, pass Convex's generated builders (`query`, `mutation`, ...) to the kit constructors. A wrapper that spreads or copies the definition reads its getters at registration.
49
102
 
50
103
  ## Modules
51
104
 
52
- ### `cvx-kit/zod-table`
105
+ ### `cvx-kit/k`
106
+
107
+ Schemas are written with `k`. Each `k` schema carries a plain native Convex
108
+ validator, which is what Convex receives for args, returns and tables. The kit
109
+ runs checks, defaults, normalisers, refinements and transforms only where a
110
+ schema declares them; a function with none does no validation work of its own.
111
+
112
+ ```ts
113
+ import { k } from 'cvx-kit/k'
114
+
115
+ const renameArgs = k.object({
116
+ id: k.id('documents'),
117
+ title: k.string().trim().min(1).max(200),
118
+ })
119
+ type RenameArgs = k.input<typeof renameArgs>
120
+ ```
121
+
122
+ Failed declared checks throw a `ConvexError` with data
123
+ `{ code: 'VALIDATION', issues: [{ path, code, message }] }`. `k` schemas
124
+ implement Standard Schema v1; `toJsonSchema` (`cvx-kit/json-schema`) and
125
+ `toZod` (`cvx-kit/zod`) convert them for agent tools and Zod-only libraries.
126
+ See the [`k` guide](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/k.md).
53
127
 
54
- One zod shape per entity, masked into every boundary it crosses:
128
+ ### `cvx-kit/table`
129
+
130
+ One field object per entity, masked into every boundary it crosses:
55
131
 
56
132
  ```ts
57
- import { zodTable } from 'cvx-kit/zod-table'
58
-
59
- export const documents = zodTable(
60
- 'documents',
61
- (id) => ({
62
- title: z.string(),
63
- ownerId: id('users'),
64
- secretNote: z.string(),
65
- }),
66
- {
67
- commandFields: ['title'], // what a command may say
68
- publicFields: ['title', 'ownerId'], // the DTO allowlist
69
- },
133
+ import { k } from 'cvx-kit/k'
134
+ import { kTable } from 'cvx-kit/table'
135
+
136
+ export const documents = kTable(
137
+ 'documents',
138
+ {
139
+ title: k.string(),
140
+ ownerId: k.id('users'),
141
+ secretNote: k.string(),
142
+ },
143
+ {
144
+ commandFields: ['title'], // what a command may say
145
+ publicFields: ['title', 'ownerId'], // the DTO allowlist
146
+ },
70
147
  )
71
148
  // documents.table → defineTable(...) for schema.ts
72
- // documents.toPublicDto(row) → projects AND re-parses (runtime redaction)
149
+ // documents.toPublicDto(row) → projects AND re-checks (runtime redaction)
150
+ ```
151
+
152
+ For fields shared across tables, create a reusable declaration function:
153
+
154
+ ```ts
155
+ import { createTable } from 'cvx-kit/table'
156
+
157
+ const customTable = createTable({ ref: k.string(), nextActivity: k.string() })
158
+ const tasks = customTable('tasks', { title: k.string() })
159
+ const projects = customTable('projects', { name: k.string() })
73
160
  ```
74
161
 
162
+ It accepts the same arguments and returns the same boundary as `kTable`.
163
+ Table-specific fields cannot repeat shared field names. See the
164
+ [`table` guide](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/table.md)
165
+ for field masks and examples.
166
+
75
167
  Every table gets `createdAt`, `updatedAt`, and `archivedAt` baked in —
76
168
  opinionated, server-owned, always excluded from inserts and commands
77
169
  (expose them via `publicFields` when a DTO needs them). Register the
78
170
  `timestamps` trigger once and they maintain themselves; `archivedAt` stays
79
171
  under application control.
80
172
 
81
- `zodVariantTable` covers discriminated-union tables; `jsonSafeZid` keeps
82
- LLM-tool JSON schemas primitive while preserving the `Id<...>` type.
173
+ `kVariantTable` covers discriminated-union tables. Tool masks keep `k.id(...)`;
174
+ `toJsonSchema` renders ids as strings while the `Id<...>` type is preserved.
175
+
176
+ ### `cvx-kit/relations` and `cvx-kit/querying`
177
+
178
+ See the [querying guide](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/querying.md),
179
+ [DTO parameters](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/table.md#public-dto-parameters), and
180
+ [consumer rule reference](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/oxlint.md#dto-and-pagination-diagnostics).
181
+
182
+ Declare relationships once in `convex/relations.ts`, then configure the engine
183
+ once in `convex/querying.ts`. Both factories are also available from the package
184
+ root. The relations subpath exposes declarations and public types; executor
185
+ metadata and managed reader capabilities are internal.
186
+
187
+ ```ts
188
+ // convex/relations.ts
189
+ import { defineRelations } from 'cvx-kit/relations'
190
+ import './domain/tasks/table' // Establish native indexes before compiling the registry.
191
+ import { tasks, labels, edges } from './domain/tasks/schema'
192
+
193
+ export const relations = defineRelations({ tasks, labels, edges }, (r) => ({
194
+ tasks: {
195
+ referenceTask: r.one.tasks({ from: r.tasks.reference, to: r.tasks._id }),
196
+ labels: r.many.labels({
197
+ from: r.tasks._id.through(r.edges.task),
198
+ to: r.labels._id.through(r.edges.label),
199
+ }),
200
+ },
201
+ }))
202
+ ```
203
+
204
+ The tables can be `kTable`, `createTable`, `tenantTable`, or three-argument `kVariantTable` boundaries, with
205
+ indexes supporting each declared lookup. Names can distinguish multiple edges
206
+ to the same table; references can point to the same table. A one edge returns a
207
+ public DTO or `null`. A many edge returns a bounded native page. Junction output
208
+ preserves duplicate edge occurrences, even when target reads are memoized.
209
+ Missing and unreadable targets have the same public result.
210
+
211
+ `defineRelations` checks table names, native table ownership and the structure
212
+ of relation declarations. Variant tables also run their native table preflight
213
+ then, to expose common-field references. It captures each table's stored field semantics,
214
+ public DTO validation, variants and active indexes on that table's first use:
215
+ its schema helpers, an engine read, or a selected relation that reaches it. Each
216
+ edge's field types and indexes are checked when the edge is first read. Invalid
217
+ tables and edges throw on first use instead of at registration. Complete schema
218
+ and index configuration before calling `defineRelations`. Later changes to
219
+ source declarations do not affect a table after its first use. Create a new
220
+ registry to adopt changes. Caller-owned declarations remain mutable.
221
+
222
+ Call `verifyRelations(relations)` from a test to run every deferred check, so CI
223
+ fails on an invalid registry:
224
+
225
+ ```ts
226
+ import { verifyRelations } from 'cvx-kit/relations'
227
+ import { relations } from '../convex/relations'
228
+
229
+ test('relation registry is valid', () => verifyRelations(relations))
230
+ ```
231
+
232
+ Relation DTOs only validate; they never transform stored values. Refinement
233
+ closures still observe application state.
234
+
235
+ Variant tables keep their discriminated public unions. Use the relation callback's
236
+ second argument, `branch('payments', 'creditor_payment').creditorId`, for a
237
+ branch-specific reference; its tag is checked before lookup. See the
238
+ [variant querying guide](skills/cvx-kit/references/variant-querying.md) for the
239
+ complete authenticated flow and branch filter syntax.
240
+
241
+ ```ts
242
+ // convex/querying.ts
243
+ import { createQueryEngine } from 'cvx-kit/querying'
244
+ import schema from './schema'
245
+ import { relations } from './relations'
246
+
247
+ export const querying = createQueryEngine({ schema, relations })
248
+ ```
249
+
250
+ One engine serves every registered table. Cursor keys load internally on first
251
+ pagination from server environment variables `CVX_QUERY_CURSOR_KEYS_JSON`
252
+ (key IDs mapped to 128-character hex secrets) and `CVX_QUERY_CURSOR_CURRENT_KEY_ID`.
253
+ Keep key material out of arguments, client code, and logs. Optional overrides
254
+ belong in a separate second argument; see [querying](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/querying.md). The default codec
255
+ uses authenticated AES-SIV encryption without a plaintext fallback; identical
256
+ payloads under the same binding reveal equality. Tokens bind filters, selected
257
+ output, index, order, relation ancestry, principal/tenant/security scope, and
258
+ registry/policy/engine versions. Page-size changes alone remain valid. Retain
259
+ old keys during rotation when existing cursors should continue working.
260
+
261
+ Private DTO schemas are built on a table's first projection, and helper schemas
262
+ are memoised. See [registry capture](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/querying.md#registry-capture-and-private-dtos).
263
+
264
+ Use the registry's validators in domain contracts and an authenticated Query
265
+ registry handler:
266
+
267
+ ```ts
268
+ const options = relations.tables.tasks.paginationOpts({
269
+ department: true,
270
+ status: true,
271
+ labels: { name: true },
272
+ })
273
+ const result = relations.tables.tasks.pageDto({ labels: true })
274
+
275
+ // In the Query operation's handler, ctx comes from createAuthFunctions.authQuery.
276
+ const page = await querying(ctx)
277
+ .tasks.where({ tenant: ctx.tenant })
278
+ .with({ labels: true })
279
+ .paginate(args)
280
+
281
+ // A separate authenticated child endpoint validates parent with tasks.schema.shape._id.
282
+ const nextLabels = await querying(ctx)
283
+ .tasks.relation(parent, 'labels')
284
+ .paginate({ numItems: 25, cursor: page.page[0].labels.continueCursor })
285
+ ```
286
+
287
+ Select filterable stored fields explicitly, including server-owned fields when
288
+ needed. Public DTO fields do not determine filter eligibility. Scalar predicates
289
+ support equality, ranges, `and`, `or`, and `not`; many predicates use `some` or
290
+ `none`. Eligibility and composed read authorization run before parents fill a
291
+ page. Parent, junction, target, and continuation reads all recheck authorization.
292
+ `include` and `paginated(dto)` retain their existing behavior independently.
293
+
294
+ For large generated static APIs, opt into compact argument validators with
295
+ `paginationOpts(selection, { validator: 'compact' })` on a table or relation.
296
+ Use the resulting schema with cvx-kit's authenticated builders. Common filters
297
+ remain precisely typed; deeper generated filter branches become opaque where
298
+ native ID checks allow it. Full depth, node, membership, and value validation
299
+ still runs before customization or handler work. Use `PaginationFiltersInput`
300
+ from `cvx-kit/relations` to check deeper filter literals. See the
301
+ [compact filter guide](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/querying.md#compact-generated-filter-validators)
302
+ for registration requirements and ID-heavy size limits.
303
+
304
+ Chain `.when(value, 'index_name')` to choose the first present condition: `false`,
305
+ `0`, and `''` are present; `null` and `undefined` are absent. The gate does not
306
+ bind an index field; validated filters and server `.where(...)` constraints do.
307
+ An incompatible explicit choice fails. Automatic selection uses the longest
308
+ usable equality prefix, then stable index-name order, with creation-time fallback.
309
+ `order: 'desc'` reverses the chosen native index order. Native continuation,
310
+ split/end cursors, and page status are preserved, with external tokens protected.
311
+
312
+ Browse page sizes are positive integers up to 100; central `maxPageSize` may lower that
313
+ ceiling. Central budgets bound read operations, index ranges, raw candidates,
314
+ observed/reserved document bytes, fan-out, depth, and memo entries across a
315
+ request, including policy reads. Native request read limits may lower ceilings.
316
+ An incomplete eligibility proof throws `MANAGED_READ_BUDGET`; it is never an
317
+ empty exhausted page or a negative predicate. Output relationship depth is at
318
+ most four. Traversal executes in the caller's query transaction and may require
319
+ many reads. Application/helper accounting does not measure physical platform I/O.
320
+
321
+ Kit auth query contexts carry the engine's private read capability. Unknown
322
+ contexts fail closed unless a centrally configured trusted adapter attests their
323
+ query reader, effective policy, and security scope. Mutation/action contexts,
324
+ vector search, arbitrary predicates/projections,
325
+ and custom sorts are outside this API.
326
+
327
+ Root full-text search uses a declared native search index and keeps native relevance order:
328
+
329
+ ```ts
330
+ const page = await querying(ctx)
331
+ .tasks.search('search_text', input.text)
332
+ .where({ status: 'open' })
333
+ .include({ finance: 'if-permitted' })
334
+ .with({ labels: true })
335
+ .paginate({ numItems: 25, cursor: input.cursor, scanLimit: 250 })
336
+ ```
337
+
338
+ Declare `search_text` on the exact native table registered in `relations`.
339
+ Search supports the existing root filters, field groups and nested output;
340
+ direct `.relation(...).search(...)` is unsupported. Nested relationship pages
341
+ remain ordinary browse pages. Root search returns `paginationMode: 'native-search'`,
342
+ null split metadata, and no caller-pinned `endCursor`, custom order or refill.
343
+ A short or denied-empty page can still have `isDone: false`: continue manually
344
+ with its `continueCursor` (or `usePaginatedList().fetchNextPage()`).
345
+
346
+ Search `numItems` requests a positive integer initial native target, clamped by
347
+ central limits and the remaining branch threshold. Live windows can return more raw rows.
348
+ `scanLimit` is a cursor-branch admission threshold: all raw candidates, including
349
+ denied rows, count in authenticated `seen` state. A whole window can overshoot
350
+ (e.g. seen 6 + 5 rows with limit 9 returns all authorized rows, then stops with
351
+ `result-cap`). Replaying a cursor repeats that branch; this is no global quota.
352
+ Root search payload accounting is separate from shared policy/relationship read,
353
+ byte, depth and fan-out budgets. Any unfinished nested read, policy exception or
354
+ DTO failure aborts the whole page and mints no new continuation.
355
+
356
+ Project errors explicitly at registered endpoint boundaries: ordinary `authQuery`
357
+ handlers catch and throw `new ConvexError(queryFailureContract.project(error))`
358
+ from `cvx-kit/querying`. Effect constructors configure
359
+ `query: { errors: queryFailureContract }` and wrap the promise in
360
+ `Effect.tryPromise({ try: () => /* search page */, catch: error => error })`.
361
+ The declared contract sanitizes unknown failures; do not transport raw exceptions.
362
+ See the [search contract](skills/cvx-kit/references/querying.md#root-full-text-search)
363
+ and [React list protocol](skills/cvx-kit/references/client-list.md).
364
+
365
+ Argument and compact-filter validation failures throw `KValidationError`
366
+ (`ConvexError({ code: 'VALIDATION', issues })`) by default. Pass `argumentFailure: 'declared'`
367
+ to `createAuthFunctions` / `createAuthReaders` to throw the built-in
368
+ `argumentErrors` `INVALID_ARGUMENTS` envelope instead (bounded `{ path, code, message }`
369
+ issues, never the input), or a function returning the value to throw. Decode it
370
+ with `combineErrorContracts(appErrors, argumentErrors)` from `cvx-kit/errors`; see
371
+ [client failures](skills/cvx-kit/references/client-failures.md#argument-validation-failures).
372
+
373
+ Set `argumentFailure` on `createEffectFoundation` for Effect command and query
374
+ `input` validation, including direct `exec` calls. The default preserves the
375
+ decoder failure (`UnknownFailure` at endpoints with declared error projection).
376
+ Opt in to `'declared'` or supply a hook that receives
377
+ `{ source: 'arguments', issues }` and returns the value to throw.
378
+
379
+ For manual projection, `tasks.toPublicDto(row)` still omits IDs and unselected
380
+ storage fields. `tasks.toPublicDto(row, true)` or `{ _id: true }` adds the branded
381
+ ID only. Computed extensions use matching schemas:
382
+
383
+ ```ts
384
+ const extend = { url: k.string() }
385
+ const dto = tasks.toPublicDto(row, {
386
+ _id: true,
387
+ extend,
388
+ values: { url: `https://example.test/tasks/${row._id}` },
389
+ })
390
+ const returnSchema = tasks.dto({ _id: true, extend })
391
+ ```
392
+
393
+ To migrate, replace manual ID spreads with the shorthand and copied pagination
394
+ objects with `paginationOpts`. Move eligibility filters before bounded reads by
395
+ expressing them in the engine. Replace recognized unbounded relationship
396
+ collections with declared many pages and authenticated continuation endpoints.
397
+ Consumer diagnostics identify these patterns when kit/native provenance is known;
398
+ predicate movement has no automatic fix. Keep declarations in root
399
+ `relations.ts`/`querying.ts` and contracts and Query registries in their domain.
400
+
401
+ The [packed executable example](./test/fixture-packed-querying/convex/) includes
402
+ domain tables, contracts, authenticated API adapters, one/self/named/many/junction
403
+ edges, and child continuation. Its `.template` files become ordinary TypeScript
404
+ in isolated consumers; `bun run test:package:querying` installs the tarball on
405
+ installed and minimum peers, checks strict declarations and consumer rules, and
406
+ runs the full independent stress oracle and focused tie, output, replay, and
407
+ authorization-revocation probes. For a bounded anonymous local native proof,
408
+ run `node scripts/smoke-packed-querying.mjs <retained-packed-proof-directory>`
409
+ after the package check. It uses the same tarball and central default budgets.
410
+ Package publishing and application
411
+ migration remain separate work.
83
412
 
84
413
  ### `cvx-kit/auth`
85
414
 
@@ -90,20 +419,35 @@ policy — nothing in the kit imports your app's singletons:
90
419
  import { createAuthFunctions } from 'cvx-kit/auth'
91
420
  import { action, internalAction, internalMutation, mutation, query } from './_generated/server'
92
421
 
93
- export const { authQuery, authMutation, authAction, adminQuery, adminMutation,
94
- adminAction, systemMutation, systemAction, include } =
95
- createAuthFunctions<DataModel>({
96
- query, mutation, action, internalMutation, internalAction,
97
- getAuthUser: (ctx) => authKit.getAuthUser(ctx),
98
- verifyMembership: async ({ userId, organizationId }) => {
99
- const memberships = await authKit.workos.userManagement
100
- .listOrganizationMemberships({ organizationId, userId, statuses: ['active'] })
101
- const m = memberships.data.find((c) => c.userId === userId)
102
- return m ? { organizationId: m.organizationId, roleSlug: m.role.slug } : null
103
- },
104
- // resolveOrganization: async ({ ctx, user }) => { /* org+role from app tables */ },
105
- wrapDB: (ctx) => triggers.wrapDB(ctx),
106
- })
422
+ export const {
423
+ authQuery,
424
+ authMutation,
425
+ authAction,
426
+ adminQuery,
427
+ adminMutation,
428
+ adminAction,
429
+ systemMutation,
430
+ systemAction,
431
+ include,
432
+ } = createAuthFunctions<DataModel>({
433
+ query,
434
+ mutation,
435
+ action,
436
+ internalMutation,
437
+ internalAction,
438
+ getAuthUser: (ctx) => authKit.getAuthUser(ctx),
439
+ verifyMembership: async ({ userId, organizationId }) => {
440
+ const memberships = await authKit.workos.userManagement.listOrganizationMemberships({
441
+ organizationId,
442
+ userId,
443
+ statuses: ['active'],
444
+ })
445
+ const m = memberships.data.find((c) => c.userId === userId)
446
+ return m ? { organizationId: m.organizationId, roleSlug: m.role.slug } : null
447
+ },
448
+ // resolveOrganization: async ({ ctx, user }) => { /* org+role from app tables */ },
449
+ wrapDB: (ctx) => triggers.wrapDB(ctx),
450
+ })
107
451
  ```
108
452
 
109
453
  Actions re-verify membership live and fail closed; mutations get the trigger
@@ -111,50 +455,99 @@ registry structurally; `include()` bounds every read (default 100 rows).
111
455
  `resolveOrganization` derives org and role from your own tables, enabling
112
456
  identity providers whose tokens carry no org claims.
113
457
 
114
- ### `cvx-kit/components/foundation`
115
-
116
- Declared once; everything destructures from it. `Command` comes out of the
117
- Foundation already bound to observability and the audit writer — there is no
118
- separate command import.
458
+ Convex evaluates a function's whole static import graph on every request, and
459
+ queries and mutations cannot use dynamic `import()`. Passing `triggers` here
460
+ makes every module that imports these constructors, queries included, load
461
+ every domain the trigger registry imports. Split the constructors:
119
462
 
120
463
  ```ts
121
- // convex/convex.config.ts
122
- import foundation from 'cvx-kit/components/foundation/convex.config'
123
- app.use(foundation)
124
-
125
- // convex/foundation.ts — declared once, the single kernel source
126
- import { Foundation } from 'cvx-kit/components/foundation'
127
- export const { Command, Query, observability } = new Foundation(
128
- components.foundation,
129
- {
130
- observability: {
131
- enabled: () => env.OBS === 'true',
132
- classifyError,
133
- writeAudit: (ctx, entry) => writeAuditEntry(ctx, entry),
134
- },
135
- },
136
- )
464
+ // convex/functions/base.ts — no trigger import
465
+ export const base = {
466
+ query,
467
+ action,
468
+ internalQuery,
469
+ internalAction,
470
+ getAuthUser,
471
+ mapRole,
472
+ adminRoles,
473
+ }
474
+ // convex/functions/read.ts — never imports the trigger registry
475
+ export const { authQuery, adminQuery, authAction, include } = createAuthReaders<DataModel>(base)
476
+ // convex/functions/write.ts
477
+ export const { authMutation, systemMutation } = createAuthFunctions<DataModel>({
478
+ ...base,
479
+ mutation,
480
+ internalMutation,
481
+ triggers,
482
+ })
483
+ ```
484
+
485
+ Query and action modules import only from `read.ts`. `createAuthReaders`
486
+ shares the implementation, so identity, tenancy, rules, and role gates match;
487
+ it has no mutation constructors. `createEffectAuthFunctions` has no reader
488
+ variant yet.
137
489
 
138
- // convex/domain/<owner>/commands.ts
139
- import { Command } from '../foundation'
490
+ ### `cvx-kit/effect` — commands and queries
140
491
 
141
- const commands = new Command({
142
- 'documents.rename': Command.operation({
143
- command: renameInput,
144
- result: renameResult,
145
- classification: 'business',
146
- audit: ({ command }, ctx) => ({ ... }),
147
- }),
492
+ Use the Effect API for new commands. Install Effect `>=4.0.1 <5`, bind host
493
+ policies once with `createEffectFoundation`, and declare each handler inside
494
+ `command({...})` beside its schemas and audit policy.
495
+
496
+ <!-- packed-effect-example -->
497
+
498
+ ```ts
499
+ import { createEffectFoundation } from 'cvx-kit/effect'
500
+ import type { AuditEntryInput } from 'cvx-kit/components/foundation'
501
+ import { k } from 'cvx-kit/k'
502
+
503
+ type Host = {
504
+ actorId: string
505
+ rename: (id: string, title: string) => Promise<void>
506
+ appendAudit: (entry: AuditEntryInput) => Promise<void>
507
+ }
508
+ const { Command } = createEffectFoundation({
509
+ observability: {
510
+ enabled: false,
511
+ classifyError: () => ({ outcome: 'failed', errorCode: 'RENAME_FAILED' }),
512
+ },
513
+ writeAudit: (host: Host, entry) => host.appendAudit(entry),
148
514
  })
149
- export const executeRename = commands.exec({ operation: 'documents.rename', handler })
515
+ const renameInput = k.object({ id: k.string(), title: k.string() })
516
+ export const commands = Command({
517
+ context: (host: Host) => host,
518
+ operations: ({ command }) => ({
519
+ 'documents.rename': command({
520
+ input: renameInput,
521
+ result: k.object({ ok: k.literal(true) }),
522
+ classification: 'business',
523
+ handler: async (input, context) => {
524
+ await context.rename(input.id, input.title)
525
+ return { ok: true as const }
526
+ },
527
+ audit: ({ command }, context) => ({
528
+ operation: 'documents.rename',
529
+ actorId: context.actorId,
530
+ aggregate: { type: 'document', id: command.id },
531
+ }),
532
+ }),
533
+ }),
534
+ })
535
+ export const executeRename = (input: k.input<typeof renameInput>, host: Host) =>
536
+ commands.exec('documents.rename', input, host)
150
537
  ```
151
538
 
152
- Every command is validated (input and output zod-parsed), observed, and
153
- audited in-transaction. `classification` and `audit()` are mandatory per
154
- operation: auditing is type-enforced, not opt-in. The foundation component
155
- itself owns zero tables and ships `executeResultBoundary` (typed failures
156
- only while the transaction has no effects; otherwise rethrow so Convex
157
- rolls back).
539
+ `exec` returns a lazy Effect even for ordinary async handlers. Shared
540
+ `effectApiBuilder` constructors provide invocation-local
541
+ services and execute it; domain code can compose `Effect.gen` and `Effect.fn`
542
+ without starting another runner. Commands validate inputs and results, enforce
543
+ permissions and guards, and write audit entries in the mutation transaction.
544
+ See [commands](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/commands.md), [complete Effect wiring](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/effect.md),
545
+ and [authenticated builders](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/auth.md).
546
+
547
+ The old `Foundation.Command` Promise facade is **deprecated** and retained for
548
+ existing consumers. Its separate executor handler options are covered only in
549
+ the [compatibility reference](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/commands-legacy.md). The Foundation
550
+ component and its transaction result helpers remain available.
158
551
 
159
552
  ### `cvx-kit/components/approvals` (component)
160
553
 
@@ -170,6 +563,64 @@ import approvals from 'cvx-kit/components/approvals/convex.config'
170
563
  app.use(approvals)
171
564
  ```
172
565
 
566
+ ## Application lint rules
567
+
568
+ The TypeScript plugin `cvx-kit/oxlint` checks applications using the kit against
569
+ [`conventions.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/conventions.md). It targets `convex/`, including
570
+ public adapters, domain modules, root facades, and locally authored components.
571
+ Load it in your application's `.oxlintrc.json` and select rules:
572
+
573
+ ```json
574
+ {
575
+ "jsPlugins": [{ "name": "cvx", "specifier": "cvx-kit/oxlint" }],
576
+ "rules": {
577
+ "cvx/project-structure": "error",
578
+ "cvx/root-wiring-only": "error",
579
+ "cvx/application-orchestration": "error",
580
+ "cvx/internal-function-ownership": "error",
581
+ "cvx/domain-file-responsibilities": "error",
582
+ "cvx/reserved-domain-file-anatomy": "error",
583
+ "cvx/no-raw-builders": "error",
584
+ "cvx/no-handwritten-references": "error",
585
+ "cvx/domain-import-boundaries": "error",
586
+ "cvx/public-functions-in-api": "error",
587
+ "cvx/thin-api-adapters": "error",
588
+ "cvx/root-facade-ownership": "error",
589
+ "cvx/no-inline-enums": "error",
590
+ "cvx/no-unbounded-reads": "error",
591
+ "cvx/no-manual-timestamps": "error",
592
+ "cvx/component-boundaries": "error",
593
+ "cvx/no-component-env": "error",
594
+ "cvx/schema-file-boundaries": "error",
595
+ "cvx/no-internal-reexports": "error",
596
+ "cvx/public-api-first": "error",
597
+ "cvx/named-private-helpers": "error"
598
+ }
599
+ }
600
+ ```
601
+
602
+ With Vite+, put those fields under `lint` in `vite.config.ts`. Each rule accepts
603
+ `{ "convexDir": "path/to/convex" }` when your backend directory differs from
604
+ `convex/`. Generated files and tests are excluded from source-code rules. `project-structure`
605
+ inspects the whole backend for directory ownership, colocated runnable tests, and
606
+ module cycles. Run Oxlint on the whole backend, including `convex.config.ts`;
607
+ changed-file-only lint cannot guarantee a project scan. No application-owned
608
+ architecture test framework is required. The plugin also exports `checkArchitecture()`
609
+ for tools that need project diagnostics directly, named `rules`, and `RuleName`. Verified with
610
+ Oxlint 1.87.0 and Vite+ 1.1.0. See [rule coverage and limitations](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/oxlint.md)
611
+ and the [migration from the initial 0.1.4 plugin](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/upgrading.md).
612
+
613
+ Table-derived schemas are built on first access. Effect Query and Command registries
614
+ build on their first execution or `expose()` call; tests can force validation with
615
+ `checkArchitecture({ registries: [queries, commands] })`. For expensive contract
616
+ declarations, `defineDomainContract(() => ({ ... }))` builds once on first read,
617
+ preserving the same inferred types as the object form.
618
+
619
+ Repository checks and the enforced library rules are documented in
620
+ [`tools/oxlint/README.md`](https://github.com/ImRLopezAG/cvx-kit/blob/main/tools/oxlint/README.md). Run `bun run lint` for
621
+ anti-slop and architecture checks, `bun run test:lint` to test the custom
622
+ rules, and `bun run check` for the full Vite+ lint and formatting check.
623
+
173
624
  ## Component authoring conventions
174
625
 
175
626
  This package follows the official Convex component template
@@ -197,7 +648,7 @@ registerApprovals(t)
197
648
  ## Releasing
198
649
 
199
650
  Every release also creates a GitHub Release whose notes are the matching
200
- [CHANGELOG](./CHANGELOG.md) section (extracted by
651
+ [CHANGELOG](https://github.com/ImRLopezAG/cvx-kit/blob/main/CHANGELOG.md) section (extracted by
201
652
  `scripts/extract-changelog.mjs` in the release workflow).
202
653
 
203
654
  ### OIDC setup
@@ -206,10 +657,10 @@ Publishing uses [npm Trusted Publishing](https://docs.npmjs.com/trusted-publishe
206
657
  (OIDC) — no tokens stored anywhere. The release workflow authenticates via
207
658
  GitHub's OIDC and npm generates provenance attestations automatically.
208
659
 
209
- - `bun run release` — patch version bump, tag, and push; the `v*` tag
210
- triggers `.github/workflows/release.yml`, which verifies (typecheck, test,
211
- build + publint) and publishes.
212
- - `bun run release:minor` — same, minor bump.
660
+ Merge the version bump and changelog into `main`, then wait for successful CI
661
+ on that exact commit before pushing its `v<version>` tag. The tag triggers
662
+ `.github/workflows/release.yml`, which checks the main CI result, builds and
663
+ validates the package and skill documentation, and publishes to npm.
213
664
 
214
665
  One-time setup (already-published package required first):
215
666
 
@@ -221,4 +672,10 @@ One-time setup (already-published package required first):
221
672
 
222
673
  ## Roadmap
223
674
 
224
- See [ROADMAP.md](./ROADMAP.md) — milestones from 0.1.0 through 1.0.0.
675
+ See [ROADMAP.md](https://github.com/ImRLopezAG/cvx-kit/blob/main/ROADMAP.md) for milestones.
676
+
677
+ Optional request context can be added through the existing Effect API adapter's
678
+ `context` callback. Bind selected registries with `commands.withContext(value)`
679
+ and consume `ctx.commands.exec(name, input)` through the application's existing
680
+ function helper names. Keep dependencies local to each feature; explicit execution
681
+ and input-only command handlers remain supported. See [optional context injection](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/command-context.md).