@aotter/mantle 0.1.5-alpha.1 → 0.2.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 (870) hide show
  1. package/README.md +39 -306
  2. package/dist/admin/consent.d.ts +17 -0
  3. package/dist/admin/consent.d.ts.map +1 -0
  4. package/dist/admin/consent.js +17 -0
  5. package/dist/admin/consent.js.map +1 -0
  6. package/dist/admin/createAdminSurface.d.ts +22 -0
  7. package/dist/admin/createAdminSurface.d.ts.map +1 -0
  8. package/dist/admin/createAdminSurface.js +592 -0
  9. package/dist/admin/createAdminSurface.js.map +1 -0
  10. package/dist/admin/developerConsole.d.ts +266 -0
  11. package/dist/admin/developerConsole.d.ts.map +1 -0
  12. package/dist/admin/developerConsole.js +136 -0
  13. package/dist/admin/developerConsole.js.map +1 -0
  14. package/dist/admin/identity.d.ts +62 -0
  15. package/dist/admin/identity.d.ts.map +1 -0
  16. package/dist/admin/identity.js +7 -0
  17. package/dist/admin/identity.js.map +1 -0
  18. package/dist/admin/index.d.ts +4 -0
  19. package/dist/admin/index.d.ts.map +1 -0
  20. package/dist/admin/index.js +4 -0
  21. package/dist/admin/index.js.map +1 -0
  22. package/dist/admin/procedureFlow.d.ts +38 -0
  23. package/dist/admin/procedureFlow.d.ts.map +1 -0
  24. package/dist/admin/procedureFlow.js +188 -0
  25. package/dist/admin/procedureFlow.js.map +1 -0
  26. package/dist/auth/ConsoleEmailSender.d.ts +15 -0
  27. package/dist/auth/ConsoleEmailSender.d.ts.map +1 -0
  28. package/dist/auth/ConsoleEmailSender.js +19 -0
  29. package/dist/auth/ConsoleEmailSender.js.map +1 -0
  30. package/dist/auth/appleClientSecret.d.ts +75 -0
  31. package/dist/auth/appleClientSecret.d.ts.map +1 -0
  32. package/dist/auth/appleClientSecret.js +116 -0
  33. package/dist/auth/appleClientSecret.js.map +1 -0
  34. package/dist/auth/buildAuth.d.ts +4565 -0
  35. package/dist/auth/buildAuth.d.ts.map +1 -0
  36. package/dist/auth/buildAuth.js +307 -0
  37. package/dist/auth/buildAuth.js.map +1 -0
  38. package/dist/auth/callerResolver.d.ts +48 -0
  39. package/dist/auth/callerResolver.d.ts.map +1 -0
  40. package/dist/auth/callerResolver.js +49 -0
  41. package/dist/auth/callerResolver.js.map +1 -0
  42. package/dist/auth/createAuthRoutes.d.ts +22 -0
  43. package/dist/auth/createAuthRoutes.d.ts.map +1 -0
  44. package/dist/auth/createAuthRoutes.js +129 -0
  45. package/dist/auth/createAuthRoutes.js.map +1 -0
  46. package/dist/auth/createMantleAuth.d.ts +3 -0
  47. package/dist/auth/createMantleAuth.d.ts.map +1 -0
  48. package/dist/auth/createMantleAuth.js +508 -0
  49. package/dist/auth/createMantleAuth.js.map +1 -0
  50. package/dist/auth/db.d.ts +17 -0
  51. package/dist/auth/db.d.ts.map +1 -0
  52. package/dist/auth/db.js +24 -0
  53. package/dist/auth/db.js.map +1 -0
  54. package/dist/auth/emailTemplates.d.ts +7 -0
  55. package/dist/auth/emailTemplates.d.ts.map +1 -0
  56. package/dist/auth/emailTemplates.js +27 -0
  57. package/dist/auth/emailTemplates.js.map +1 -0
  58. package/dist/auth/index.d.ts +9 -0
  59. package/dist/auth/index.d.ts.map +1 -0
  60. package/dist/auth/index.js +7 -0
  61. package/dist/auth/index.js.map +1 -0
  62. package/dist/auth/methods.d.ts +717 -0
  63. package/dist/auth/methods.d.ts.map +1 -0
  64. package/dist/auth/methods.js +321 -0
  65. package/dist/auth/methods.js.map +1 -0
  66. package/dist/auth/oauthTokens.d.ts +24 -0
  67. package/dist/auth/oauthTokens.d.ts.map +1 -0
  68. package/dist/auth/oauthTokens.js +146 -0
  69. package/dist/auth/oauthTokens.js.map +1 -0
  70. package/dist/auth/setupIncomplete.d.ts +16 -0
  71. package/dist/auth/setupIncomplete.d.ts.map +1 -0
  72. package/dist/auth/setupIncomplete.js +50 -0
  73. package/dist/auth/setupIncomplete.js.map +1 -0
  74. package/dist/auth/types.d.ts +440 -0
  75. package/dist/auth/types.d.ts.map +1 -0
  76. package/dist/auth/types.js +10 -0
  77. package/dist/auth/types.js.map +1 -0
  78. package/dist/bun/index.d.ts +65 -0
  79. package/dist/bun/index.d.ts.map +1 -0
  80. package/dist/bun/index.js +130 -0
  81. package/dist/bun/index.js.map +1 -0
  82. package/dist/cli/emitModule.d.ts +7 -0
  83. package/dist/cli/emitModule.d.ts.map +1 -0
  84. package/dist/cli/emitModule.js +127 -0
  85. package/dist/cli/emitModule.js.map +1 -0
  86. package/dist/cli/generate.d.ts +4 -16
  87. package/dist/cli/generate.d.ts.map +1 -1
  88. package/dist/cli/generate.js +318 -262
  89. package/dist/cli/generate.js.map +1 -1
  90. package/dist/cli/main.d.ts +1 -1
  91. package/dist/cli/main.d.ts.map +1 -1
  92. package/dist/cli/main.js +15 -71
  93. package/dist/cli/main.js.map +1 -1
  94. package/dist/cli/preset.d.ts +18 -0
  95. package/dist/cli/preset.d.ts.map +1 -0
  96. package/dist/cli/preset.js +353 -0
  97. package/dist/cli/preset.js.map +1 -0
  98. package/dist/cloudflare/index.d.ts +21 -0
  99. package/dist/cloudflare/index.d.ts.map +1 -0
  100. package/dist/cloudflare/index.js +14 -0
  101. package/dist/cloudflare/index.js.map +1 -0
  102. package/dist/cloudflare/r2Media.d.ts +43 -0
  103. package/dist/cloudflare/r2Media.d.ts.map +1 -0
  104. package/dist/cloudflare/r2Media.js +69 -0
  105. package/dist/cloudflare/r2Media.js.map +1 -0
  106. package/dist/core/caller.d.ts +35 -0
  107. package/dist/core/caller.d.ts.map +1 -0
  108. package/dist/core/caller.js +3 -0
  109. package/dist/core/caller.js.map +1 -0
  110. package/dist/core/createMantle.d.ts +22 -0
  111. package/dist/core/createMantle.d.ts.map +1 -0
  112. package/dist/core/createMantle.js +117 -0
  113. package/dist/core/createMantle.js.map +1 -0
  114. package/dist/core/dialect.d.ts +41 -0
  115. package/dist/core/dialect.d.ts.map +1 -0
  116. package/dist/core/dialect.js +7 -0
  117. package/dist/core/dialect.js.map +1 -0
  118. package/dist/core/driver.d.ts +17 -0
  119. package/dist/core/driver.d.ts.map +1 -0
  120. package/dist/core/driver.js +2 -0
  121. package/dist/core/driver.js.map +1 -0
  122. package/dist/core/email.d.ts +17 -0
  123. package/dist/core/email.d.ts.map +1 -0
  124. package/dist/core/email.js +2 -0
  125. package/dist/core/email.js.map +1 -0
  126. package/dist/core/index.d.ts +16 -0
  127. package/dist/core/index.d.ts.map +1 -0
  128. package/dist/core/index.js +16 -0
  129. package/dist/core/index.js.map +1 -0
  130. package/dist/core/invocation.d.ts +66 -0
  131. package/dist/core/invocation.d.ts.map +1 -0
  132. package/dist/core/invocation.js +3 -0
  133. package/dist/core/invocation.js.map +1 -0
  134. package/dist/core/runtime/auth.d.ts +9 -0
  135. package/dist/core/runtime/auth.d.ts.map +1 -0
  136. package/dist/core/runtime/auth.js +39 -0
  137. package/dist/core/runtime/auth.js.map +1 -0
  138. package/dist/core/runtime/createRuntime.d.ts +23 -0
  139. package/dist/core/runtime/createRuntime.d.ts.map +1 -0
  140. package/dist/core/runtime/createRuntime.js +214 -0
  141. package/dist/core/runtime/createRuntime.js.map +1 -0
  142. package/dist/core/runtime/verifyPlan.d.ts +34 -0
  143. package/dist/core/runtime/verifyPlan.d.ts.map +1 -0
  144. package/dist/core/runtime/verifyPlan.js +301 -0
  145. package/dist/core/runtime/verifyPlan.js.map +1 -0
  146. package/dist/core/service.d.ts +45 -0
  147. package/dist/core/service.d.ts.map +1 -0
  148. package/dist/core/service.js +2 -0
  149. package/dist/core/service.js.map +1 -0
  150. package/dist/core/site.d.ts +117 -0
  151. package/dist/core/site.d.ts.map +1 -0
  152. package/dist/core/site.js +2 -0
  153. package/dist/core/site.js.map +1 -0
  154. package/dist/core/siteConfig.d.ts +5 -0
  155. package/dist/core/siteConfig.d.ts.map +1 -0
  156. package/dist/core/siteConfig.js +24 -0
  157. package/dist/core/siteConfig.js.map +1 -0
  158. package/dist/core/sql/allowlist.d.ts +65 -0
  159. package/dist/core/sql/allowlist.d.ts.map +1 -0
  160. package/dist/core/sql/allowlist.js +705 -0
  161. package/dist/core/sql/allowlist.js.map +1 -0
  162. package/dist/core/sql/ast.d.ts +24 -0
  163. package/dist/core/sql/ast.d.ts.map +1 -0
  164. package/dist/core/sql/ast.js +32 -0
  165. package/dist/core/sql/ast.js.map +1 -0
  166. package/dist/core/sql/compile.d.ts +50 -0
  167. package/dist/core/sql/compile.d.ts.map +1 -0
  168. package/dist/core/sql/compile.js +48 -0
  169. package/dist/core/sql/compile.js.map +1 -0
  170. package/dist/core/sql/policy.d.ts +121 -0
  171. package/dist/core/sql/policy.d.ts.map +1 -0
  172. package/dist/core/sql/policy.js +379 -0
  173. package/dist/core/sql/policy.js.map +1 -0
  174. package/dist/core/sql/positions.d.ts +30 -0
  175. package/dist/core/sql/positions.d.ts.map +1 -0
  176. package/dist/core/sql/positions.js +22 -0
  177. package/dist/core/sql/positions.js.map +1 -0
  178. package/dist/core/sql/run.d.ts +76 -0
  179. package/dist/core/sql/run.d.ts.map +1 -0
  180. package/dist/core/sql/run.js +267 -0
  181. package/dist/core/sql/run.js.map +1 -0
  182. package/dist/core/store/createStore.d.ts +49 -0
  183. package/dist/core/store/createStore.d.ts.map +1 -0
  184. package/dist/core/store/createStore.js +227 -0
  185. package/dist/core/store/createStore.js.map +1 -0
  186. package/dist/core/store/cursor.d.ts +4 -0
  187. package/dist/core/store/cursor.d.ts.map +1 -0
  188. package/dist/core/store/cursor.js +22 -0
  189. package/dist/core/store/cursor.js.map +1 -0
  190. package/dist/core/store/json.d.ts +80 -0
  191. package/dist/core/store/json.d.ts.map +1 -0
  192. package/dist/core/store/json.js +342 -0
  193. package/dist/core/store/json.js.map +1 -0
  194. package/dist/core/store.d.ts +160 -0
  195. package/dist/core/store.d.ts.map +1 -0
  196. package/dist/core/store.js +2 -0
  197. package/dist/core/store.js.map +1 -0
  198. package/dist/core/wire.d.ts +20 -0
  199. package/dist/core/wire.d.ts.map +1 -0
  200. package/dist/core/wire.js +84 -0
  201. package/dist/core/wire.js.map +1 -0
  202. package/dist/core/withCaller.d.ts +16 -0
  203. package/dist/core/withCaller.d.ts.map +1 -0
  204. package/dist/core/withCaller.js +29 -0
  205. package/dist/core/withCaller.js.map +1 -0
  206. package/dist/d1/adapter.d.ts +12 -0
  207. package/dist/d1/adapter.d.ts.map +1 -0
  208. package/dist/d1/adapter.js +23 -0
  209. package/dist/d1/adapter.js.map +1 -0
  210. package/dist/d1/codec.d.ts +14 -0
  211. package/dist/d1/codec.d.ts.map +1 -0
  212. package/dist/d1/codec.js +136 -0
  213. package/dist/d1/codec.js.map +1 -0
  214. package/dist/d1/compile/index.d.ts +9 -0
  215. package/dist/d1/compile/index.d.ts.map +1 -0
  216. package/dist/d1/compile/index.js +9 -0
  217. package/dist/d1/compile/index.js.map +1 -0
  218. package/dist/d1/dialect.d.ts +4 -0
  219. package/dist/d1/dialect.d.ts.map +1 -0
  220. package/dist/d1/dialect.js +13 -0
  221. package/dist/d1/dialect.js.map +1 -0
  222. package/dist/d1/executor.d.ts +13 -0
  223. package/dist/d1/executor.d.ts.map +1 -0
  224. package/dist/d1/executor.js +91 -0
  225. package/dist/d1/executor.js.map +1 -0
  226. package/dist/d1/index.d.ts +6 -0
  227. package/dist/d1/index.d.ts.map +1 -0
  228. package/dist/d1/index.js +6 -0
  229. package/dist/d1/index.js.map +1 -0
  230. package/dist/d1/lower.d.ts +8 -0
  231. package/dist/d1/lower.d.ts.map +1 -0
  232. package/dist/d1/lower.js +167 -0
  233. package/dist/d1/lower.js.map +1 -0
  234. package/dist/d1/media.d.ts +5 -0
  235. package/dist/d1/media.d.ts.map +1 -0
  236. package/dist/d1/media.js +157 -0
  237. package/dist/d1/media.js.map +1 -0
  238. package/dist/d1/migrations.d.ts +12 -0
  239. package/dist/d1/migrations.d.ts.map +1 -0
  240. package/dist/d1/migrations.js +111 -0
  241. package/dist/d1/migrations.js.map +1 -0
  242. package/dist/d1/print.d.ts +28 -0
  243. package/dist/d1/print.d.ts.map +1 -0
  244. package/dist/d1/print.js +54 -0
  245. package/dist/d1/print.js.map +1 -0
  246. package/dist/d1/site.d.ts +17 -0
  247. package/dist/d1/site.d.ts.map +1 -0
  248. package/dist/d1/site.js +63 -0
  249. package/dist/d1/site.js.map +1 -0
  250. package/dist/d1/storage.d.ts +34 -0
  251. package/dist/d1/storage.d.ts.map +1 -0
  252. package/dist/d1/storage.js +288 -0
  253. package/dist/d1/storage.js.map +1 -0
  254. package/dist/d1/tz.d.ts +21 -0
  255. package/dist/d1/tz.d.ts.map +1 -0
  256. package/dist/d1/tz.js +54 -0
  257. package/dist/d1/tz.js.map +1 -0
  258. package/dist/d1/validator.d.ts +10 -0
  259. package/dist/d1/validator.d.ts.map +1 -0
  260. package/dist/d1/validator.js +33 -0
  261. package/dist/d1/validator.js.map +1 -0
  262. package/dist/mcp/apps.d.ts +43 -0
  263. package/dist/mcp/apps.d.ts.map +1 -0
  264. package/dist/mcp/apps.js +57 -0
  265. package/dist/mcp/apps.js.map +1 -0
  266. package/dist/mcp/catalog.d.ts +55 -0
  267. package/dist/mcp/catalog.d.ts.map +1 -0
  268. package/dist/mcp/catalog.js +81 -0
  269. package/dist/mcp/catalog.js.map +1 -0
  270. package/dist/mcp/createMcpSurface.d.ts +34 -0
  271. package/dist/mcp/createMcpSurface.d.ts.map +1 -0
  272. package/dist/mcp/createMcpSurface.js +150 -0
  273. package/dist/mcp/createMcpSurface.js.map +1 -0
  274. package/dist/mcp/index.d.ts +4 -0
  275. package/dist/mcp/index.d.ts.map +1 -0
  276. package/dist/mcp/index.js +4 -0
  277. package/dist/mcp/index.js.map +1 -0
  278. package/dist/postgres/adapter.d.ts +20 -0
  279. package/dist/postgres/adapter.d.ts.map +1 -0
  280. package/dist/postgres/adapter.js +44 -0
  281. package/dist/postgres/adapter.js.map +1 -0
  282. package/dist/postgres/codec.d.ts +13 -0
  283. package/dist/postgres/codec.d.ts.map +1 -0
  284. package/dist/postgres/codec.js +110 -0
  285. package/dist/postgres/codec.js.map +1 -0
  286. package/dist/postgres/compile/index.d.ts +9 -0
  287. package/dist/postgres/compile/index.d.ts.map +1 -0
  288. package/dist/postgres/compile/index.js +9 -0
  289. package/dist/postgres/compile/index.js.map +1 -0
  290. package/dist/postgres/driver.d.ts +92 -0
  291. package/dist/postgres/driver.d.ts.map +1 -0
  292. package/dist/postgres/driver.js +110 -0
  293. package/dist/postgres/driver.js.map +1 -0
  294. package/dist/postgres/executor.d.ts +20 -0
  295. package/dist/postgres/executor.d.ts.map +1 -0
  296. package/dist/postgres/executor.js +69 -0
  297. package/dist/postgres/executor.js.map +1 -0
  298. package/dist/postgres/index.d.ts +7 -0
  299. package/dist/postgres/index.d.ts.map +1 -0
  300. package/dist/postgres/index.js +7 -0
  301. package/dist/postgres/index.js.map +1 -0
  302. package/dist/postgres/lower.d.ts +6 -0
  303. package/dist/postgres/lower.d.ts.map +1 -0
  304. package/dist/postgres/lower.js +157 -0
  305. package/dist/postgres/lower.js.map +1 -0
  306. package/dist/postgres/print.d.ts +11 -0
  307. package/dist/postgres/print.d.ts.map +1 -0
  308. package/dist/postgres/print.js +121 -0
  309. package/dist/postgres/print.js.map +1 -0
  310. package/dist/postgres/storage.d.ts +19 -0
  311. package/dist/postgres/storage.d.ts.map +1 -0
  312. package/dist/postgres/storage.js +201 -0
  313. package/dist/postgres/storage.js.map +1 -0
  314. package/dist/postgres/textRows.d.ts +10 -0
  315. package/dist/postgres/textRows.d.ts.map +1 -0
  316. package/dist/postgres/textRows.js +44 -0
  317. package/dist/postgres/textRows.js.map +1 -0
  318. package/dist/postgres/validator.d.ts +12 -0
  319. package/dist/postgres/validator.d.ts.map +1 -0
  320. package/dist/postgres/validator.js +46 -0
  321. package/dist/postgres/validator.js.map +1 -0
  322. package/dist/spec/domain/index.d.ts +3 -0
  323. package/dist/spec/domain/index.d.ts.map +1 -0
  324. package/dist/spec/domain/index.js +3 -0
  325. package/dist/spec/domain/index.js.map +1 -0
  326. package/dist/spec/domain/model/ContentState.d.ts +8 -0
  327. package/dist/spec/domain/model/ContentState.d.ts.map +1 -0
  328. package/dist/spec/domain/model/ContentState.js +7 -0
  329. package/dist/spec/domain/model/ContentState.js.map +1 -0
  330. package/dist/spec/domain/model/Entry.d.ts +29 -0
  331. package/dist/spec/domain/model/Entry.d.ts.map +1 -0
  332. package/dist/spec/domain/model/Entry.js +16 -0
  333. package/dist/spec/domain/model/Entry.js.map +1 -0
  334. package/dist/spec/domain/model/Locale.d.ts +30 -0
  335. package/dist/spec/domain/model/Locale.d.ts.map +1 -0
  336. package/dist/spec/domain/model/Locale.js +33 -0
  337. package/dist/spec/domain/model/Locale.js.map +1 -0
  338. package/dist/spec/domain/model/ManifestGrammar.d.ts +452 -0
  339. package/dist/spec/domain/model/ManifestGrammar.d.ts.map +1 -0
  340. package/dist/spec/domain/model/ManifestGrammar.js +149 -0
  341. package/dist/spec/domain/model/ManifestGrammar.js.map +1 -0
  342. package/dist/spec/domain/model/MediaMimeAccept.d.ts +55 -0
  343. package/dist/spec/domain/model/MediaMimeAccept.d.ts.map +1 -0
  344. package/dist/spec/domain/model/MediaMimeAccept.js +90 -0
  345. package/dist/spec/domain/model/MediaMimeAccept.js.map +1 -0
  346. package/dist/spec/domain/model/RuntimePlan.d.ts +94 -0
  347. package/dist/spec/domain/model/RuntimePlan.d.ts.map +1 -0
  348. package/dist/spec/domain/model/RuntimePlan.js +4 -0
  349. package/dist/spec/domain/model/RuntimePlan.js.map +1 -0
  350. package/dist/spec/domain/model/SiteConfig.d.ts +173 -0
  351. package/dist/spec/domain/model/SiteConfig.d.ts.map +1 -0
  352. package/dist/spec/domain/model/SiteConfig.js +13 -0
  353. package/dist/spec/domain/model/SiteConfig.js.map +1 -0
  354. package/dist/spec/domain/model/SqlIr.d.ts +96 -0
  355. package/dist/spec/domain/model/SqlIr.d.ts.map +1 -0
  356. package/dist/spec/domain/model/SqlIr.js +95 -0
  357. package/dist/spec/domain/model/SqlIr.js.map +1 -0
  358. package/dist/spec/domain/model/index.d.ts +14 -0
  359. package/dist/spec/domain/model/index.d.ts.map +1 -0
  360. package/dist/spec/domain/model/index.js +14 -0
  361. package/dist/spec/domain/model/index.js.map +1 -0
  362. package/dist/spec/domain/service/CloudflareCron.d.ts +2 -0
  363. package/dist/spec/domain/service/CloudflareCron.d.ts.map +1 -0
  364. package/dist/spec/domain/service/CloudflareCron.js +63 -0
  365. package/dist/spec/domain/service/CloudflareCron.js.map +1 -0
  366. package/dist/spec/domain/service/CrossSchemaChecker.d.ts +34 -0
  367. package/dist/spec/domain/service/CrossSchemaChecker.d.ts.map +1 -0
  368. package/dist/spec/domain/service/CrossSchemaChecker.js +114 -0
  369. package/dist/spec/domain/service/CrossSchemaChecker.js.map +1 -0
  370. package/dist/spec/domain/service/EntryDataValidator.d.ts +56 -0
  371. package/dist/spec/domain/service/EntryDataValidator.d.ts.map +1 -0
  372. package/dist/spec/domain/service/EntryDataValidator.js +88 -0
  373. package/dist/spec/domain/service/EntryDataValidator.js.map +1 -0
  374. package/dist/spec/domain/service/JsonSchemaToZod.d.ts +29 -0
  375. package/dist/spec/domain/service/JsonSchemaToZod.d.ts.map +1 -0
  376. package/dist/spec/domain/service/JsonSchemaToZod.js +156 -0
  377. package/dist/spec/domain/service/JsonSchemaToZod.js.map +1 -0
  378. package/dist/spec/domain/service/LifecycleStateMachine.d.ts +75 -0
  379. package/dist/spec/domain/service/LifecycleStateMachine.d.ts.map +1 -0
  380. package/dist/spec/domain/service/LifecycleStateMachine.js +76 -0
  381. package/dist/spec/domain/service/LifecycleStateMachine.js.map +1 -0
  382. package/dist/spec/domain/service/LocaleCanonicalizer.d.ts +29 -0
  383. package/dist/spec/domain/service/LocaleCanonicalizer.d.ts.map +1 -0
  384. package/dist/spec/domain/service/LocaleCanonicalizer.js +96 -0
  385. package/dist/spec/domain/service/LocaleCanonicalizer.js.map +1 -0
  386. package/dist/spec/domain/service/ManifestFieldChecks.d.ts +60 -0
  387. package/dist/spec/domain/service/ManifestFieldChecks.d.ts.map +1 -0
  388. package/dist/spec/domain/service/ManifestFieldChecks.js +116 -0
  389. package/dist/spec/domain/service/ManifestFieldChecks.js.map +1 -0
  390. package/dist/spec/domain/service/ManifestGraphValidator.d.ts +15 -0
  391. package/dist/spec/domain/service/ManifestGraphValidator.d.ts.map +1 -0
  392. package/dist/spec/domain/service/ManifestGraphValidator.js +225 -0
  393. package/dist/spec/domain/service/ManifestGraphValidator.js.map +1 -0
  394. package/dist/spec/domain/service/ManifestLinker.d.ts +45 -0
  395. package/dist/spec/domain/service/ManifestLinker.d.ts.map +1 -0
  396. package/dist/spec/domain/service/ManifestLinker.js +92 -0
  397. package/dist/spec/domain/service/ManifestLinker.js.map +1 -0
  398. package/dist/spec/domain/service/ManifestLocaleTrimmer.d.ts +16 -0
  399. package/dist/spec/domain/service/ManifestLocaleTrimmer.d.ts.map +1 -0
  400. package/dist/spec/domain/service/ManifestLocaleTrimmer.js +76 -0
  401. package/dist/spec/domain/service/ManifestLocaleTrimmer.js.map +1 -0
  402. package/dist/spec/domain/service/ManifestParser.d.ts +49 -0
  403. package/dist/spec/domain/service/ManifestParser.d.ts.map +1 -0
  404. package/dist/spec/domain/service/ManifestParser.js +203 -0
  405. package/dist/spec/domain/service/ManifestParser.js.map +1 -0
  406. package/dist/spec/domain/service/ManifestPartition.d.ts +9 -0
  407. package/dist/spec/domain/service/ManifestPartition.d.ts.map +1 -0
  408. package/dist/spec/domain/service/ManifestPartition.js +19 -0
  409. package/dist/spec/domain/service/ManifestPartition.js.map +1 -0
  410. package/dist/spec/domain/service/ManifestPathDiagnoser.d.ts +33 -0
  411. package/dist/spec/domain/service/ManifestPathDiagnoser.d.ts.map +1 -0
  412. package/dist/spec/domain/service/ManifestPathDiagnoser.js +43 -0
  413. package/dist/spec/domain/service/ManifestPathDiagnoser.js.map +1 -0
  414. package/dist/spec/domain/service/ManifestSourceSpans.d.ts +10 -0
  415. package/dist/spec/domain/service/ManifestSourceSpans.d.ts.map +1 -0
  416. package/dist/spec/domain/service/ManifestSourceSpans.js +76 -0
  417. package/dist/spec/domain/service/ManifestSourceSpans.js.map +1 -0
  418. package/dist/spec/domain/service/McpToolNaming.d.ts +25 -0
  419. package/dist/spec/domain/service/McpToolNaming.d.ts.map +1 -0
  420. package/dist/spec/domain/service/McpToolNaming.js +50 -0
  421. package/dist/spec/domain/service/McpToolNaming.js.map +1 -0
  422. package/dist/spec/domain/service/PlanFingerprint.d.ts +4 -0
  423. package/dist/spec/domain/service/PlanFingerprint.d.ts.map +1 -0
  424. package/dist/spec/domain/service/PlanFingerprint.js +14 -0
  425. package/dist/spec/domain/service/PlanFingerprint.js.map +1 -0
  426. package/dist/spec/domain/service/ProcedureViewSpecChecks.d.ts +4 -0
  427. package/dist/spec/domain/service/ProcedureViewSpecChecks.d.ts.map +1 -0
  428. package/dist/spec/domain/service/ProcedureViewSpecChecks.js +211 -0
  429. package/dist/spec/domain/service/ProcedureViewSpecChecks.js.map +1 -0
  430. package/dist/spec/domain/service/SchemaAdminUiChecker.d.ts +42 -0
  431. package/dist/spec/domain/service/SchemaAdminUiChecker.d.ts.map +1 -0
  432. package/dist/spec/domain/service/SchemaAdminUiChecker.js +289 -0
  433. package/dist/spec/domain/service/SchemaAdminUiChecker.js.map +1 -0
  434. package/dist/spec/domain/service/SchemaIndexChecker.d.ts +33 -0
  435. package/dist/spec/domain/service/SchemaIndexChecker.d.ts.map +1 -0
  436. package/dist/spec/domain/service/SchemaIndexChecker.js +256 -0
  437. package/dist/spec/domain/service/SchemaIndexChecker.js.map +1 -0
  438. package/dist/spec/domain/service/SchemaSearchChecker.d.ts +11 -0
  439. package/dist/spec/domain/service/SchemaSearchChecker.d.ts.map +1 -0
  440. package/dist/spec/domain/service/SchemaSearchChecker.js +78 -0
  441. package/dist/spec/domain/service/SchemaSearchChecker.js.map +1 -0
  442. package/dist/spec/domain/service/SchemaSpecChecks.d.ts +31 -0
  443. package/dist/spec/domain/service/SchemaSpecChecks.d.ts.map +1 -0
  444. package/dist/spec/domain/service/SchemaSpecChecks.js +445 -0
  445. package/dist/spec/domain/service/SchemaSpecChecks.js.map +1 -0
  446. package/dist/spec/domain/service/SiteDefaultsValidator.d.ts +39 -0
  447. package/dist/spec/domain/service/SiteDefaultsValidator.d.ts.map +1 -0
  448. package/dist/spec/domain/service/SiteDefaultsValidator.js +194 -0
  449. package/dist/spec/domain/service/SiteDefaultsValidator.js.map +1 -0
  450. package/dist/spec/domain/service/SqlClassify.d.ts +19 -0
  451. package/dist/spec/domain/service/SqlClassify.d.ts.map +1 -0
  452. package/dist/spec/domain/service/SqlClassify.js +42 -0
  453. package/dist/spec/domain/service/SqlClassify.js.map +1 -0
  454. package/dist/spec/domain/service/SqlRefusal.d.ts +16 -0
  455. package/dist/spec/domain/service/SqlRefusal.d.ts.map +1 -0
  456. package/dist/spec/domain/service/SqlRefusal.js +20 -0
  457. package/dist/spec/domain/service/SqlRefusal.js.map +1 -0
  458. package/dist/spec/domain/service/SqlTypes.d.ts +40 -0
  459. package/dist/spec/domain/service/SqlTypes.d.ts.map +1 -0
  460. package/dist/spec/domain/service/SqlTypes.js +110 -0
  461. package/dist/spec/domain/service/SqlTypes.js.map +1 -0
  462. package/dist/spec/domain/service/StaffRoleHierarchy.d.ts +3 -0
  463. package/dist/spec/domain/service/StaffRoleHierarchy.d.ts.map +1 -0
  464. package/dist/spec/domain/service/StaffRoleHierarchy.js +19 -0
  465. package/dist/spec/domain/service/StaffRoleHierarchy.js.map +1 -0
  466. package/dist/spec/domain/service/TriggerGraphChecks.d.ts +16 -0
  467. package/dist/spec/domain/service/TriggerGraphChecks.d.ts.map +1 -0
  468. package/dist/spec/domain/service/TriggerGraphChecks.js +337 -0
  469. package/dist/spec/domain/service/TriggerGraphChecks.js.map +1 -0
  470. package/dist/spec/domain/service/TriggerSpecChecks.d.ts +4 -0
  471. package/dist/spec/domain/service/TriggerSpecChecks.d.ts.map +1 -0
  472. package/dist/spec/domain/service/TriggerSpecChecks.js +89 -0
  473. package/dist/spec/domain/service/TriggerSpecChecks.js.map +1 -0
  474. package/dist/spec/domain/service/ValidatedAdminUiProjection.d.ts +11 -0
  475. package/dist/spec/domain/service/ValidatedAdminUiProjection.d.ts.map +1 -0
  476. package/dist/spec/domain/service/ValidatedAdminUiProjection.js +26 -0
  477. package/dist/spec/domain/service/ValidatedAdminUiProjection.js.map +1 -0
  478. package/dist/spec/domain/service/ViewAdminUiChecker.d.ts +14 -0
  479. package/dist/spec/domain/service/ViewAdminUiChecker.d.ts.map +1 -0
  480. package/dist/spec/domain/service/ViewAdminUiChecker.js +53 -0
  481. package/dist/spec/domain/service/ViewAdminUiChecker.js.map +1 -0
  482. package/dist/spec/domain/service/index.d.ts +24 -0
  483. package/dist/spec/domain/service/index.d.ts.map +1 -0
  484. package/dist/spec/domain/service/index.js +24 -0
  485. package/dist/spec/domain/service/index.js.map +1 -0
  486. package/dist/spec/index.d.ts +10 -0
  487. package/dist/spec/index.d.ts.map +1 -0
  488. package/dist/spec/index.js +12 -0
  489. package/dist/spec/index.js.map +1 -0
  490. package/dist/spec/infrastructure/cli/parseArgsError.d.ts +16 -0
  491. package/dist/spec/infrastructure/cli/parseArgsError.d.ts.map +1 -0
  492. package/dist/spec/infrastructure/cli/parseArgsError.js +34 -0
  493. package/dist/spec/infrastructure/cli/parseArgsError.js.map +1 -0
  494. package/dist/spec/infrastructure/index.d.ts +2 -0
  495. package/dist/spec/infrastructure/index.d.ts.map +1 -0
  496. package/dist/spec/infrastructure/index.js +2 -0
  497. package/dist/spec/infrastructure/index.js.map +1 -0
  498. package/dist/spec/infrastructure/sql/PgQueryParser.d.ts +18 -0
  499. package/dist/spec/infrastructure/sql/PgQueryParser.d.ts.map +1 -0
  500. package/dist/spec/infrastructure/sql/PgQueryParser.js +17 -0
  501. package/dist/spec/infrastructure/sql/PgQueryParser.js.map +1 -0
  502. package/dist/spec/infrastructure/sql/compilePlan.d.ts +37 -0
  503. package/dist/spec/infrastructure/sql/compilePlan.d.ts.map +1 -0
  504. package/dist/spec/infrastructure/sql/compilePlan.js +282 -0
  505. package/dist/spec/infrastructure/sql/compilePlan.js.map +1 -0
  506. package/dist/spec/infrastructure/sql/compileSql.d.ts +35 -0
  507. package/dist/spec/infrastructure/sql/compileSql.d.ts.map +1 -0
  508. package/dist/spec/infrastructure/sql/compileSql.js +92 -0
  509. package/dist/spec/infrastructure/sql/compileSql.js.map +1 -0
  510. package/dist/spec/infrastructure/sql/frontEnd.d.ts +8 -0
  511. package/dist/spec/infrastructure/sql/frontEnd.d.ts.map +1 -0
  512. package/dist/spec/infrastructure/sql/frontEnd.js +100 -0
  513. package/dist/spec/infrastructure/sql/frontEnd.js.map +1 -0
  514. package/dist/spec/infrastructure/sql/index.d.ts +4 -0
  515. package/dist/spec/infrastructure/sql/index.d.ts.map +1 -0
  516. package/dist/spec/infrastructure/sql/index.js +4 -0
  517. package/dist/spec/infrastructure/sql/index.js.map +1 -0
  518. package/dist/spec/kernel/diagnostic.d.ts +137 -0
  519. package/dist/spec/kernel/diagnostic.d.ts.map +1 -0
  520. package/dist/spec/kernel/diagnostic.js +296 -0
  521. package/dist/spec/kernel/diagnostic.js.map +1 -0
  522. package/dist/spec/kernel/index.d.ts +8 -0
  523. package/dist/spec/kernel/index.d.ts.map +1 -0
  524. package/dist/spec/kernel/index.js +8 -0
  525. package/dist/spec/kernel/index.js.map +1 -0
  526. package/dist/spec/usecase/EmitTypes.d.ts +22 -0
  527. package/dist/spec/usecase/EmitTypes.d.ts.map +1 -0
  528. package/dist/spec/usecase/EmitTypes.js +182 -0
  529. package/dist/spec/usecase/EmitTypes.js.map +1 -0
  530. package/dist/spec/usecase/ValidateManifestsUseCase.d.ts +8 -0
  531. package/dist/spec/usecase/ValidateManifestsUseCase.d.ts.map +1 -0
  532. package/dist/spec/usecase/ValidateManifestsUseCase.js +101 -0
  533. package/dist/spec/usecase/ValidateManifestsUseCase.js.map +1 -0
  534. package/dist/spec/usecase/dto/ValidateManifestsRequest.d.ts +27 -0
  535. package/dist/spec/usecase/dto/ValidateManifestsRequest.d.ts.map +1 -0
  536. package/dist/spec/usecase/dto/ValidateManifestsRequest.js +2 -0
  537. package/dist/spec/usecase/dto/ValidateManifestsRequest.js.map +1 -0
  538. package/dist/spec/usecase/dto/ValidateManifestsResponse.d.ts +14 -0
  539. package/dist/spec/usecase/dto/ValidateManifestsResponse.d.ts.map +1 -0
  540. package/dist/spec/usecase/dto/ValidateManifestsResponse.js +2 -0
  541. package/dist/spec/usecase/dto/ValidateManifestsResponse.js.map +1 -0
  542. package/dist/spec/usecase/dto/index.d.ts +3 -0
  543. package/dist/spec/usecase/dto/index.d.ts.map +1 -0
  544. package/dist/spec/usecase/dto/index.js +3 -0
  545. package/dist/spec/usecase/dto/index.js.map +1 -0
  546. package/dist/spec/usecase/index.d.ts +10 -0
  547. package/dist/spec/usecase/index.d.ts.map +1 -0
  548. package/dist/spec/usecase/index.js +10 -0
  549. package/dist/spec/usecase/index.js.map +1 -0
  550. package/dist/testing/cases/before-hook.d.ts +4 -0
  551. package/dist/testing/cases/before-hook.d.ts.map +1 -0
  552. package/dist/testing/cases/before-hook.js +71 -0
  553. package/dist/testing/cases/before-hook.js.map +1 -0
  554. package/dist/testing/cases/corpus.d.ts +12 -0
  555. package/dist/testing/cases/corpus.d.ts.map +1 -0
  556. package/dist/testing/cases/corpus.js +91 -0
  557. package/dist/testing/cases/corpus.js.map +1 -0
  558. package/dist/testing/cases/policy.d.ts +74 -0
  559. package/dist/testing/cases/policy.d.ts.map +1 -0
  560. package/dist/testing/cases/policy.js +142 -0
  561. package/dist/testing/cases/policy.js.map +1 -0
  562. package/dist/testing/cases/printer.d.ts +4 -0
  563. package/dist/testing/cases/printer.d.ts.map +1 -0
  564. package/dist/testing/cases/printer.js +32 -0
  565. package/dist/testing/cases/printer.js.map +1 -0
  566. package/dist/testing/cases/report-view.d.ts +5 -0
  567. package/dist/testing/cases/report-view.d.ts.map +1 -0
  568. package/dist/testing/cases/report-view.js +33 -0
  569. package/dist/testing/cases/report-view.js.map +1 -0
  570. package/dist/testing/cases/requisition.d.ts +4 -0
  571. package/dist/testing/cases/requisition.d.ts.map +1 -0
  572. package/dist/testing/cases/requisition.js +38 -0
  573. package/dist/testing/cases/requisition.js.map +1 -0
  574. package/dist/testing/cases/search-places.d.ts +4 -0
  575. package/dist/testing/cases/search-places.d.ts.map +1 -0
  576. package/dist/testing/cases/search-places.js +60 -0
  577. package/dist/testing/cases/search-places.js.map +1 -0
  578. package/dist/testing/cases/stock.d.ts +4 -0
  579. package/dist/testing/cases/stock.d.ts.map +1 -0
  580. package/dist/testing/cases/stock.js +35 -0
  581. package/dist/testing/cases/stock.js.map +1 -0
  582. package/dist/testing/cases/store.d.ts +4 -0
  583. package/dist/testing/cases/store.d.ts.map +1 -0
  584. package/dist/testing/cases/store.js +100 -0
  585. package/dist/testing/cases/store.js.map +1 -0
  586. package/dist/testing/harness.d.ts +94 -0
  587. package/dist/testing/harness.d.ts.map +1 -0
  588. package/dist/testing/harness.js +168 -0
  589. package/dist/testing/harness.js.map +1 -0
  590. package/dist/testing/index.d.ts +37 -0
  591. package/dist/testing/index.d.ts.map +1 -0
  592. package/dist/testing/index.js +43 -0
  593. package/dist/testing/index.js.map +1 -0
  594. package/dist/testing/report.d.ts +15 -0
  595. package/dist/testing/report.d.ts.map +1 -0
  596. package/dist/testing/report.js +22 -0
  597. package/dist/testing/report.js.map +1 -0
  598. package/dist/web/createRestSurface.d.ts +7 -0
  599. package/dist/web/createRestSurface.d.ts.map +1 -0
  600. package/dist/web/createRestSurface.js +39 -0
  601. package/dist/web/createRestSurface.js.map +1 -0
  602. package/dist/web/index.d.ts +2 -0
  603. package/dist/web/index.d.ts.map +1 -0
  604. package/dist/web/index.js +2 -0
  605. package/dist/web/index.js.map +1 -0
  606. package/docs/adr/0008-structured-diagnostic-shape.md +2 -2
  607. package/docs/adr/0011-adapter-port-spec.md +2 -2
  608. package/docs/adr/0014-auth-better-auth-and-multi-tenant-mcp.md +21 -2
  609. package/docs/adr/0019-sealed-manifest-runtime-pipeline.md +5 -1
  610. package/docs/adr/0022-caller-observed-version-occ.md +1 -1
  611. package/docs/adr/0024-manifest-native-schema-tables.md +2 -2
  612. package/docs/adr/0027-scheduled-procedure-triggers.md +1 -1
  613. package/docs/adr/0028-schema-ttl-expiry.md +3 -3
  614. package/docs/adr/0029-mcp-apps-interaction-contracts.md +324 -0
  615. package/docs/adr/0030-store.md +40 -0
  616. package/docs/adr/0031-host-cloud-core-contract.md +25 -0
  617. package/docs/adr/0032-store-centric-core-and-service-contract.md +361 -0
  618. package/docs/adr/0033-storage-converges-to-the-plan.md +92 -0
  619. package/docs/adr/0034-store-is-authored-as-sql.md +192 -0
  620. package/docs/adr/0035-sql-dialects.md +154 -0
  621. package/docs/adr/0036-host-and-dialect.md +65 -0
  622. package/docs/adr/0037-postgresql-is-the-reference-dialect.md +124 -0
  623. package/docs/adr/0038-bun-native-host.md +63 -0
  624. package/docs/adr/README.md +23 -8
  625. package/docs/adr/adr-lite-861-admin-webmcp.md +6 -0
  626. package/docs/adr/adr-lite-909-admin-ui-kit.md +1 -1
  627. package/docs/examples/README.md +16 -18
  628. package/docs/examples/commerce-inventory.md +481 -0
  629. package/docs/examples/commerce.md +254 -0
  630. package/docs/examples/guarded-api.md +238 -0
  631. package/docs/examples/intake-hooks.md +237 -0
  632. package/docs/examples/intake.md +127 -0
  633. package/docs/examples/legal-documents.md +218 -0
  634. package/docs/examples/procurement.md +215 -0
  635. package/docs/examples/publication.md +211 -0
  636. package/docs/examples/reference-service/.dev.vars.example +4 -0
  637. package/docs/examples/reference-service/.mantle/generated/mantle.ts +174 -0
  638. package/docs/examples/reference-service/.mantle/generated/plan.json +1936 -0
  639. package/docs/examples/reference-service/README.md +33 -0
  640. package/docs/examples/reference-service/manifests/catalog.yaml +103 -0
  641. package/docs/examples/reference-service/manifests/orders.yaml +120 -0
  642. package/docs/examples/reference-service/mantle.config.json +1 -0
  643. package/docs/examples/reference-service/package.json +27 -0
  644. package/docs/examples/reference-service/smoke.mjs +156 -0
  645. package/docs/examples/reference-service/src/handlers.ts +36 -0
  646. package/docs/examples/reference-service/src/index.ts +33 -0
  647. package/docs/examples/reference-service/src/service.ts +78 -0
  648. package/docs/examples/{host-minimal-worker → reference-service}/tsconfig.json +7 -2
  649. package/docs/examples/reference-service/wrangler.jsonc +26 -0
  650. package/docs/examples/reservation.md +142 -0
  651. package/docs/handbook/cloudflare/authentication.md +119 -311
  652. package/docs/handbook/cloudflare/chatgpt-sites.md +104 -15
  653. package/docs/handbook/cloudflare/deploy-and-operate.md +77 -71
  654. package/docs/handbook/cloudflare/media-r2.md +64 -187
  655. package/docs/handbook/cloudflare/service-entry.md +138 -0
  656. package/docs/handbook/concepts/authorization.md +104 -94
  657. package/docs/handbook/concepts/four-atoms.md +68 -144
  658. package/docs/handbook/concepts/lifecycle-and-locales.md +62 -114
  659. package/docs/handbook/concepts/mcp-and-agents.md +112 -117
  660. package/docs/handbook/concepts/procedures-and-triggers.md +126 -181
  661. package/docs/handbook/concepts/runtime-and-adapters.md +177 -163
  662. package/docs/handbook/concepts/views.md +97 -173
  663. package/docs/handbook/examples/hub.md +17 -6
  664. package/docs/handbook/guides/admin-ui.md +101 -96
  665. package/docs/handbook/guides/agent-setup.md +56 -71
  666. package/docs/handbook/guides/typed-queries.md +105 -111
  667. package/docs/handbook/navigation.json +8 -33
  668. package/docs/handbook/reference/authorization.md +52 -271
  669. package/docs/handbook/reference/diagnostics.md +69 -178
  670. package/docs/handbook/reference/features.md +48 -50
  671. package/docs/handbook/reference/manifest.md +56 -116
  672. package/docs/handbook/reference/procedure.md +91 -279
  673. package/docs/handbook/reference/schema.md +154 -239
  674. package/docs/handbook/reference/site-config.md +58 -211
  675. package/docs/handbook/reference/surface.md +69 -181
  676. package/docs/handbook/reference/trigger.md +72 -181
  677. package/docs/handbook/reference/view.md +140 -241
  678. package/docs/handbook/releases/index.md +58 -77
  679. package/docs/handbook/start/overview.md +59 -51
  680. package/docs/handbook/start/project-and-cli.md +132 -105
  681. package/docs/handbook/start/quickstart-worker.md +102 -160
  682. package/docs/skills/develop/SKILL.md +114 -240
  683. package/docs/skills/develop/mcp-app.md +79 -0
  684. package/docs/skills/integrate/SKILL.md +83 -47
  685. package/docs/skills/media-gc/SKILL.md +21 -10
  686. package/docs/skills/provision/SKILL.md +68 -162
  687. package/docs/skills/update/SKILL.md +33 -34
  688. package/docs/upgrade-0.1-to-0.2.md +211 -0
  689. package/package.json +87 -106
  690. package/dist/admin-ui.d.ts +0 -2
  691. package/dist/admin-ui.d.ts.map +0 -1
  692. package/dist/admin-ui.js +0 -2
  693. package/dist/admin-ui.js.map +0 -1
  694. package/dist/admin.d.ts +0 -2
  695. package/dist/admin.d.ts.map +0 -1
  696. package/dist/admin.js +0 -2
  697. package/dist/admin.js.map +0 -1
  698. package/dist/auth.d.ts +0 -2
  699. package/dist/auth.d.ts.map +0 -1
  700. package/dist/auth.js +0 -2
  701. package/dist/auth.js.map +0 -1
  702. package/dist/bun.d.ts +0 -2
  703. package/dist/bun.d.ts.map +0 -1
  704. package/dist/bun.js +0 -2
  705. package/dist/bun.js.map +0 -1
  706. package/dist/cli/generate-cloudflare.d.ts +0 -7
  707. package/dist/cli/generate-cloudflare.d.ts.map +0 -1
  708. package/dist/cli/generate-cloudflare.js +0 -123
  709. package/dist/cli/generate-cloudflare.js.map +0 -1
  710. package/dist/cli/generate-project.d.ts +0 -25
  711. package/dist/cli/generate-project.d.ts.map +0 -1
  712. package/dist/cli/generate-project.js +0 -282
  713. package/dist/cli/generate-project.js.map +0 -1
  714. package/dist/cli/generate-sites.d.ts +0 -8
  715. package/dist/cli/generate-sites.d.ts.map +0 -1
  716. package/dist/cli/generate-sites.js +0 -273
  717. package/dist/cli/generate-sites.js.map +0 -1
  718. package/dist/cli/harness.d.ts +0 -3
  719. package/dist/cli/harness.d.ts.map +0 -1
  720. package/dist/cli/harness.js +0 -214
  721. package/dist/cli/harness.js.map +0 -1
  722. package/dist/cli/skills.d.ts +0 -3
  723. package/dist/cli/skills.d.ts.map +0 -1
  724. package/dist/cli/skills.js +0 -128
  725. package/dist/cli/skills.js.map +0 -1
  726. package/dist/cloudflare.d.ts +0 -2
  727. package/dist/cloudflare.d.ts.map +0 -1
  728. package/dist/cloudflare.js +0 -2
  729. package/dist/cloudflare.js.map +0 -1
  730. package/dist/codegen/emitMantleModule.d.ts +0 -22
  731. package/dist/codegen/emitMantleModule.d.ts.map +0 -1
  732. package/dist/codegen/emitMantleModule.js +0 -291
  733. package/dist/codegen/emitMantleModule.js.map +0 -1
  734. package/dist/codegen.d.ts +0 -2
  735. package/dist/codegen.d.ts.map +0 -1
  736. package/dist/codegen.js +0 -2
  737. package/dist/codegen.js.map +0 -1
  738. package/dist/runtime-testing.d.ts +0 -2
  739. package/dist/runtime-testing.d.ts.map +0 -1
  740. package/dist/runtime-testing.js +0 -2
  741. package/dist/runtime-testing.js.map +0 -1
  742. package/dist/runtime.d.ts +0 -2
  743. package/dist/runtime.d.ts.map +0 -1
  744. package/dist/runtime.js +0 -2
  745. package/dist/runtime.js.map +0 -1
  746. package/dist/spec.d.ts +0 -2
  747. package/dist/spec.d.ts.map +0 -1
  748. package/dist/spec.js +0 -2
  749. package/dist/spec.js.map +0 -1
  750. package/dist/vercel-libsql.d.ts +0 -2
  751. package/dist/vercel-libsql.d.ts.map +0 -1
  752. package/dist/vercel-libsql.js +0 -2
  753. package/dist/vercel-libsql.js.map +0 -1
  754. package/dist/vercel.d.ts +0 -2
  755. package/dist/vercel.d.ts.map +0 -1
  756. package/dist/vercel.js +0 -2
  757. package/dist/vercel.js.map +0 -1
  758. package/dist/web.d.ts +0 -2
  759. package/dist/web.d.ts.map +0 -1
  760. package/dist/web.js +0 -2
  761. package/dist/web.js.map +0 -1
  762. package/docs/adapter-guide.md +0 -222
  763. package/docs/agent-prompts.md +0 -64
  764. package/docs/api-mcp-authorization.md +0 -5
  765. package/docs/assets/mantle-admin-developer.png +0 -0
  766. package/docs/assets/mantle-admin-operations.png +0 -0
  767. package/docs/assets/mantle-hero.jpg +0 -0
  768. package/docs/auth-hosting-model.md +0 -166
  769. package/docs/cloudflare-low-level-composition.md +0 -5
  770. package/docs/consumer-onboarding-audit.md +0 -65
  771. package/docs/deferred-lifecycle-queues.md +0 -5
  772. package/docs/design-atoms.md +0 -16
  773. package/docs/design-references/editorial-blog-2026-05-05.md +0 -218
  774. package/docs/direct-authoring.md +0 -5
  775. package/docs/examples/builtin-commerce.md +0 -269
  776. package/docs/examples/builtin-intake.md +0 -143
  777. package/docs/examples/builtin-legal-documents.md +0 -189
  778. package/docs/examples/builtin-procurement.md +0 -241
  779. package/docs/examples/builtin-publication.md +0 -241
  780. package/docs/examples/builtin-reservation.md +0 -149
  781. package/docs/examples/cf-primitives-commerce-inventory.md +0 -809
  782. package/docs/examples/cf-primitives-guarded-api.md +0 -429
  783. package/docs/examples/cf-primitives-intake-hooks.md +0 -319
  784. package/docs/examples/host-chatgpt-sites/.openai/hosting.json +0 -1
  785. package/docs/examples/host-chatgpt-sites/README.md +0 -70
  786. package/docs/examples/host-chatgpt-sites/drizzle/0000_sites_users.sql +0 -8
  787. package/docs/examples/host-chatgpt-sites/drizzle/0001_mantle.sql +0 -294
  788. package/docs/examples/host-chatgpt-sites/drizzle/0002_article_cover.sql +0 -5
  789. package/docs/examples/host-chatgpt-sites/drizzle/0003_store_instance_id.sql +0 -1
  790. package/docs/examples/host-chatgpt-sites/drizzle/0004_mantle.sql +0 -10
  791. package/docs/examples/host-chatgpt-sites/drizzle/0005_mantle.sql +0 -24
  792. package/docs/examples/host-chatgpt-sites/drizzle/meta/_journal.json +0 -1
  793. package/docs/examples/host-chatgpt-sites/drizzle/meta/mantle-state.json +0 -60
  794. package/docs/examples/host-chatgpt-sites/manifests/site.yaml +0 -27
  795. package/docs/examples/host-chatgpt-sites/package.json +0 -1
  796. package/docs/examples/host-chatgpt-sites/public/site.css +0 -1
  797. package/docs/examples/host-chatgpt-sites/scripts/build.mjs +0 -13
  798. package/docs/examples/host-chatgpt-sites/scripts/check.mjs +0 -101
  799. package/docs/examples/host-chatgpt-sites/scripts/migration.mjs +0 -43
  800. package/docs/examples/host-chatgpt-sites/src/chatgpt-auth.ts +0 -66
  801. package/docs/examples/host-chatgpt-sites/src/index.ts +0 -46
  802. package/docs/examples/host-chatgpt-sites/src/mcp.ts +0 -49
  803. package/docs/examples/host-chatgpt-sites/src/media.ts +0 -109
  804. package/docs/examples/host-chatgpt-sites/src/r2-lab.ts +0 -38
  805. package/docs/examples/host-chatgpt-sites/src/storage-fingerprint.json +0 -1
  806. package/docs/examples/host-chatgpt-sites/src/web.ts +0 -35
  807. package/docs/examples/host-chatgpt-sites/tsconfig.json +0 -1
  808. package/docs/examples/host-chatgpt-sites/wrangler.jsonc +0 -10
  809. package/docs/examples/host-local-admin-otp/.dev.vars.example +0 -3
  810. package/docs/examples/host-local-admin-otp/README.md +0 -80
  811. package/docs/examples/host-local-admin-otp/ensure-dev-vars.mjs +0 -5
  812. package/docs/examples/host-local-admin-otp/manifests/site.yaml +0 -25
  813. package/docs/examples/host-local-admin-otp/package.json +0 -29
  814. package/docs/examples/host-local-admin-otp/public/.gitkeep +0 -1
  815. package/docs/examples/host-local-admin-otp/smoke.mjs +0 -141
  816. package/docs/examples/host-local-admin-otp/src/index.ts +0 -54
  817. package/docs/examples/host-local-admin-otp/tsconfig.json +0 -17
  818. package/docs/examples/host-local-admin-otp/wrangler.jsonc +0 -23
  819. package/docs/examples/host-minimal-worker/README.md +0 -41
  820. package/docs/examples/host-minimal-worker/manifests/site.yaml +0 -25
  821. package/docs/examples/host-minimal-worker/package.json +0 -26
  822. package/docs/examples/host-minimal-worker/smoke.mjs +0 -23
  823. package/docs/examples/host-minimal-worker/src/index.ts +0 -4
  824. package/docs/examples/host-minimal-worker/wrangler.jsonc +0 -22
  825. package/docs/handbook/chatgpt-sites/equipment-checkout.md +0 -231
  826. package/docs/handbook/chatgpt-sites/generated-app.md +0 -84
  827. package/docs/handbook/chatgpt-sites/host-reference.md +0 -113
  828. package/docs/handbook/chatgpt-sites/index.md +0 -133
  829. package/docs/handbook/cloudflare/bindings.md +0 -291
  830. package/docs/handbook/cloudflare/conventional-worker.md +0 -166
  831. package/docs/handbook/cloudflare/deferred-hooks-queues.md +0 -170
  832. package/docs/handbook/cloudflare/low-level-composition.md +0 -169
  833. package/docs/handbook/cloudflare/public-web.md +0 -144
  834. package/docs/handbook/cloudflare/site-chrome.md +0 -75
  835. package/docs/handbook/examples/commerce-transaction.md +0 -11
  836. package/docs/handbook/examples/commerce.md +0 -11
  837. package/docs/handbook/examples/guarded-api.md +0 -10
  838. package/docs/handbook/examples/intake-form.md +0 -12
  839. package/docs/handbook/examples/intake-hooks.md +0 -11
  840. package/docs/handbook/examples/legal-documents.md +0 -10
  841. package/docs/handbook/examples/procurement-approvals.md +0 -10
  842. package/docs/handbook/examples/publication.md +0 -10
  843. package/docs/handbook/examples/reservation.md +0 -10
  844. package/docs/handbook/start/quickstart-admin.md +0 -52
  845. package/docs/labels.md +0 -71
  846. package/docs/media-uploads.md +0 -5
  847. package/docs/migration-0.1.2.md +0 -13
  848. package/docs/performance-harness.md +0 -228
  849. package/docs/release-process.md +0 -244
  850. package/docs/schema-indexes.md +0 -5
  851. package/docs/sealed-pipeline-ownership.md +0 -101
  852. package/docs/skills/plugin/SKILL.md +0 -132
  853. package/docs/skills/theme/SKILL.md +0 -77
  854. package/docs/spec-only-host-adoption.md +0 -157
  855. package/docs/transaction-patterns.md +0 -5
  856. package/skills/README.md +0 -127
  857. package/skills/develop/SKILL.md +0 -258
  858. package/skills/install/SKILL.md +0 -112
  859. package/skills/integrate/SKILL.md +0 -60
  860. package/skills/media-gc/SKILL.md +0 -85
  861. package/skills/plugin/SKILL.md +0 -132
  862. package/skills/provision/SKILL.md +0 -194
  863. package/skills/theme/SKILL.md +0 -77
  864. package/skills/update/SKILL.md +0 -51
  865. package/templates/chatgpt-sites/auth.ts +0 -66
  866. package/templates/chatgpt-sites/build.mjs +0 -14
  867. package/templates/chatgpt-sites/env.ts +0 -1
  868. package/templates/chatgpt-sites/mcp.ts +0 -48
  869. package/templates/chatgpt-sites/public-mcp.ts +0 -29
  870. package/templates/chatgpt-sites/smoke-local.mjs +0 -20
@@ -0,0 +1,138 @@
1
+ ---
2
+ description: The generated src/service.ts and src/index.ts of a Mantle 0.2.0 Cloudflare service — how the surfaces are mounted, and how to add your own routes, bindings and scheduled work.
3
+ ---
4
+ # The service and its entry
5
+
6
+ On host `cloudflare`, `mantle generate` writes two files once, then they are
7
+ yours (host `bun` writes a `Bun.serve` entry instead, ADR-0038):
8
+
9
+ - `src/service.ts` composes the service: storage, identity, surfaces, and the
10
+ `mantle` object from `createMantle`;
11
+ - `src/index.ts` is the Cloudflare entry: `fetch` and `scheduled`.
12
+
13
+ Mantle owns no route of its own. What is mounted, and where, is this code.
14
+
15
+ ## `src/service.ts`
16
+
17
+ With identity `mantle` and every feature (the
18
+ [reference service](../../examples/reference-service/src/service.ts) is this
19
+ file, unchanged):
20
+
21
+ ```ts
22
+ function mount(runtime: MantleRuntime, env: Env) {
23
+ const auth = createAuth(env, origin); // createMantleAuth, or a setup-incomplete stub
24
+ const resolver = createCallerResolver(auth, { jwtBearer: { audience: `${origin}/mcp`, scopes: ["mcp"] } });
25
+ const authRoutes = createAuthRoutes(auth, { resolver });
26
+ const guard = (surface, options?) => withCaller(resolver, surface, options);
27
+ const admin = guard(createAdminSurface(runtime, { basePath: "/admin", assets: (path) => adminAsset(env.ASSETS, path), identity: { … }, site: { mcpEndpoints: { public: "/mcp", staff: "/mcp/staff" } } }));
28
+ const mcp = guard(createMcpSurface(runtime, { basePath: "/mcp", surface: "public", resourceMetadata }), { resourceMetadata });
29
+ // MCP Apps hosts render each staff View's rows, and the operations on one row, in the chat
30
+ const staffMcp = guard(createMcpSurface(runtime, { basePath: "/mcp/staff", surface: "staff", apps: { resources: [planApp(runtime.plan, { surface: "staff", html: mantleAppHtml })] }, resourceMetadata }), { resourceMetadata });
31
+ const rest = guard(createRestSurface(runtime, { basePath: "/api" }));
32
+ return async (request, waitUntil) => {
33
+ const owned = await authRoutes(request, { waitUntil });
34
+ if (owned) return owned;
35
+ if (under("/admin")) return admin(request);
36
+ if (under("/mcp/staff")) return staffMcp(request);
37
+ if (under("/mcp")) return mcp(request);
38
+ return rest(request);
39
+ };
40
+ }
41
+
42
+ const service: MantleService<Env> = {
43
+ handlers,
44
+ fetch: (request, env, { runtime, waitUntil }) => (routes ??= mount(runtime, env))(request, waitUntil),
45
+ };
46
+
47
+ export const mantle = createMantle(service, { plan, storage: (env) => d1Storage(env.DB), schedules: true });
48
+ ```
49
+
50
+ - `Env` lists the bindings and vars the service reads. Add yours there.
51
+ - The surfaces are built once per isolate, on the first request.
52
+ - With identity `custom` the resolver is your `src/identity.ts`; with `none`
53
+ every surface gets `{ kind: "anonymous" }` and no auth routes are mounted.
54
+
55
+ ## Add your own routes
56
+
57
+ Put them in the function `mount` returns, where they belong in the order:
58
+
59
+ ```ts
60
+ return async (request, waitUntil) => {
61
+ const { pathname } = new URL(request.url);
62
+ await auth.ready?.catch((error) => { routes = undefined; throw error; }); // first, before any route answers
63
+ if (pathname === "/healthz") return new Response("ok"); // no caller
64
+ if (pathname === "/payments/callback") return handleCallback(request, runtime, env);
65
+ const owned = await authRoutes(request, { waitUntil });
66
+ if (owned) return owned;
67
+ …
68
+ };
69
+ ```
70
+
71
+ - With identity `mantle`, keep `await auth.ready` above every route. `mount`
72
+ starts Better Auth inside an isolate's first request, and Workers cancels I/O
73
+ that a finished request started: a route that answers that first request
74
+ before `auth.ready` settles leaves the context pending for ever, and every
75
+ later request waits on it (under `wrangler dev` too). The wait costs only the
76
+ isolate's first request.
77
+
78
+ - A route that acts for a caller resolves it the same way:
79
+ `withCaller(resolver, (request, caller) => …)` gives you the caller, the 401
80
+ for a bad credential, and the cross-origin check.
81
+ - Reach data through `runtime.store.as(caller)` or
82
+ `runtime.invokeProcedure({ procedure, input, caller, cause: { kind: "internal", id } })`;
83
+ `runtime.store` alone is unscoped, for trusted code only.
84
+ - Server-rendered pages, a SPA's assets, a signed webhook: all are routes
85
+ here. Mantle renders no public pages in 0.2.0.
86
+
87
+ ## `src/index.ts`
88
+
89
+ ```ts
90
+ export default {
91
+ fetch: (request, env) => mantle.fetch(request, env, ctx),
92
+ async scheduled(controller, env) { … mantle.invokeSchedule(cron, controller.scheduledTime, env, ctx) … },
93
+ } satisfies ExportedHandler<Env>;
94
+ ```
95
+
96
+ - `ctx` is `{ waitUntil }` from `cloudflare:workers`, which is not bound to one
97
+ request, so a handler's `ctx.waitUntil` never lands on a finished request.
98
+ - Manifest crons are POSIX; Cloudflare names a cron as `wrangler.jsonc` spells
99
+ it. The entry maps each Cloudflare cron back to every POSIX expression that
100
+ shares it, runs them all, and reports every failure together. A cron no
101
+ Trigger maps to throws.
102
+ - There is no `queue` handler: no Mantle path produces queue messages. Add
103
+ your own `queue` beside `fetch` if your service uses one.
104
+
105
+ ## Bindings
106
+
107
+ `wrangler.jsonc` starts with `DB` (D1), or with dialect `postgres` a
108
+ `HYPERDRIVE` binding whose `id` is a placeholder until
109
+ `wrangler hyperdrive create <name> --caching-disabled --connection-string=…`
110
+ gives one, `triggers.crons`, and with feature `admin` the console's files:
111
+
112
+ ```jsonc
113
+ "assets": { "directory": "node_modules/@aotter/mantle-ui/dist/admin", "binding": "ASSETS", "run_worker_first": true, "html_handling": "none" }
114
+ ```
115
+
116
+ `run_worker_first` sends every request through the Worker, so Admin answers
117
+ every `/admin` path and nothing is served at the files' bare paths; keep it
118
+ when you add assets of your own (serve those through the same binding or a
119
+ route). `mantle generate` warns when `admin` is selected and no `ASSETS` is
120
+ bound. Add the rest:
121
+
122
+ | Need | `wrangler.jsonc` | Code |
123
+ |---|---|---|
124
+ | Media | `r2_buckets: [{ binding: "MEDIA", bucket_name: … }]` | [Media uploads with R2](./media-r2.md) |
125
+ | A secret | `wrangler secret put NAME` (`.dev.vars` locally) | `env.NAME` |
126
+ | A plain var | `vars: { NAME: "…" }` | `env.NAME` |
127
+ | Email | `send_email: [{ name: "EMAIL" }]` | your `EmailSender` for sign-in, or a handler's `ctx.env.EMAIL` |
128
+ | KV, Queues, Durable Objects | their usual keys | your own code; Mantle reads none of them |
129
+
130
+ Handlers receive the same `env` as `ctx.env`. Mantle-owned rows are reached
131
+ only through Store; never write a Schema's table with `env.DB` directly. Your
132
+ own tables in the same database are yours.
133
+
134
+ ## When the preset changes
135
+
136
+ The preset is never rewritten. After an SDK upgrade, compare your files with
137
+ a fresh preset: generate into an empty directory with the same manifests and
138
+ `mantle.config.json`, and diff `src/service.ts` and `src/index.ts`.
@@ -1,116 +1,126 @@
1
1
  ---
2
- description: One authorization pipeline for REST, MCP and Admin — identity kinds, static predicates, the dynamic guard, staff roles and 401/403/402.
2
+ description: The Caller, the one CallerResolver at the service entry, requires predicates, guards, Schema scope and auth.uid(), and how staff roles fit.
3
3
  ---
4
4
  # Authorization
5
5
 
6
- Mantle has one authorization pipeline. A manifest HTTP Trigger, a View over REST, an MCP `tools/call` and an Admin operation all reach the same evaluator, so a rule written once holds on every surface. This page explains the model; the exact `requires` grammar is in the [authorization reference](../reference/authorization.md), and a worked ladder of four access levels is in [Guarded API access](../../examples/cf-primitives-guarded-api.md).
6
+ Mantle never owns your users. The service resolves who is calling once per
7
+ request, and Mantle enforces the manifests against that answer.
7
8
 
8
- ## The fixed order
9
-
10
- Every protected invocation runs the same five steps:
11
-
12
- 1. Verify and normalize the transport credential.
13
- 2. Evaluate the static predicates in `requires.auth.all`, before any input-schema detail is exposed.
14
- 3. Validate and coerce the target input, or the View params.
15
- 4. Invoke the guard Procedure with that validated value and the same context.
16
- 5. Invoke the target only after the guard succeeds.
17
-
18
- Static predicates run before validation so an unauthorized caller cannot probe a schema by reading its error messages. The guard runs after validation so it can decide on the actual arguments. Every stage fails closed.
19
-
20
- ## Identity kinds
21
-
22
- The adapter verifies the transport, then hands the runtime normalized, non-secret metadata. Handlers see this and nothing else:
9
+ ## The Caller
23
10
 
24
11
  ```ts
25
- interface HandlerContext {
26
- readonly user: { readonly id: string } | null;
27
- readonly staff: { readonly id: string; readonly role: StaffRole } | null;
28
- readonly auth?: {
29
- readonly credential: "session" | "oauth" | "api-key" | "personal-token";
30
- readonly credentialId: string | null;
31
- readonly clientId: string | null;
32
- readonly scopes: readonly string[];
33
- };
34
- }
12
+ type Caller =
13
+ | { kind: "anonymous" }
14
+ | { kind: "user"; subject: string; issuer?: string; role: "owner" | "editor" | "contributor" | null;
15
+ scopes: readonly string[]; credential: "session" | "oauth" | "api-key" | "personal-token";
16
+ credentialId: string | null; clientId: string | null }
17
+ | { kind: "system"; reason: string };
35
18
  ```
36
19
 
37
- Three things are distinct:
38
-
39
- - **`ctx.user`** is the end-user identity: a row in the site's own Better Auth user table. A service API key may have no user at all.
40
- - **`ctx.staff`** is a role overlay on top of a user, not a separate account. A user with no overlay is `null` here.
41
- - **`ctx.auth`** is the verified credential itself, of kind `session`, `oauth`, `api-key` or `personal-token`. Raw keys, refresh tokens and cookies never enter the runtime; `credentialId` is an opaque record id.
20
+ - `subject` is the application's subject key: opaque, stable, unique across
21
+ every issuer, never an email. `auth.uid()`, a scope field and `author_id`
22
+ store it. A resolver over several identity providers namespaces it
23
+ (`chatgpt:<sub>`, `account:<id>`).
24
+ - `role` is a staff role or `null`. Admin's vocabulary is `owner`, `editor`,
25
+ `contributor`; a resolver maps its own roles onto it, or leaves `null` and
26
+ uses scopes and guards.
27
+ - The `system` caller comes only from host code (`systemCaller(reason)`):
28
+ schedules, maintenance, a verified webhook. No request can produce one.
42
29
 
43
- The predicate vocabulary is closed and maps onto those three: `ctx.user`, `ctx.auth`, `{ "ctx.auth.scope": "<scope>" }` (repeat it to require several), and `{ "ctx.staff": [roles] }`. There is no credential-kind predicate — a target that must reject browser sessions does so by requiring a scope no session grant carries.
44
-
45
- ## Predicates versus the guard
46
-
47
- | | Static predicates | Guard Procedure |
48
- |---|---|---|
49
- | Declared as | `requires.auth.all` | `requires.guard.procedure` |
50
- | Answers | Is this caller of the right kind, with the right role and scopes? | Is this verified caller allowed to do this business action right now? |
51
- | Evaluated | Before input validation | After input validation, on every call, never cached |
52
- | Reads | The compiled plan only | Your tables, your provider state, `ctx.env` |
53
- | Typical failure | `401` or `403` | `402` |
54
-
55
- Anything that changes independently of the credential belongs in the guard: payment state, subscription or membership status, seat counts, per-tenant entitlement. A key stays valid while a subscription lapses, so the fact that a caller paid is not something a token can carry. The guard is an ordinary unguarded `handler.kind: ref` Procedure — not a fifth atom — and it throws a structured diagnostic to deny:
30
+ ## One boundary: `CallerResolver` and `withCaller`
56
31
 
57
32
  ```ts
58
- throw new DiagnosticError(
59
- runtimeDiagnostic({
60
- code: "ENTITLEMENT_REQUIRED",
61
- severity: "error",
62
- path: `site:membership/${ctx.user!.id}`,
63
- message: "Active membership is required.",
64
- }),
65
- );
33
+ type CallerResolver = (request: Request) =>
34
+ Promise<{ caller: Caller } | { invalid: true; challenge?: string; status?: 401 | 403 }>;
66
35
  ```
67
36
 
68
- ## 401, 403 and 402
69
-
70
- | Status | Diagnostic | Meaning |
71
- |---|---|---|
72
- | `401` | `UNAUTHENTICATED` | No credential, or a recognized credential that is bad, revoked or expired. |
73
- | `403` | `AUTH_DENIED` | Verified caller, but a required predicate failed — a missing scope, a missing user subject, an insufficient staff role. |
74
- | `402` | `ENTITLEMENT_REQUIRED` | Verified and permitted caller whose current business state does not allow the action. |
75
-
76
- The split is the point: `401` says *who are you*, `403` says *you may not*, `402` says *not until you settle something*. Only the guard produces `402`, and on `402` the target handler is never invoked. See [Diagnostic codes](../reference/diagnostics.md) for the full mapping.
77
-
78
- ## Staff roles
79
-
80
- Staff roles are `owner`, `editor` and `contributor`. Owners manage staff and site settings; editors publish, approve and manage entries; contributors work on drafts.
81
-
82
- A manifest predicate tests **exact membership**, not rank: `{ "ctx.staff": [editor] }` admits editors and nobody else, an owner included. List every role you mean, as in `{ "ctx.staff": [owner, editor] }`. Rank ordering does exist, but only Admin's own route table uses it, which is why an owner passes an Admin route gated at editor. See [Authorization requirements](../reference/authorization.md).
83
-
84
- The role is re-read from the database on every protected REST and MCP call. A token snapshot or a consent-time role is not an authorization boundary, so demoting or revoking a user in Admin locks them out on their very next request — no token revocation, no cache flush, no waiting for expiry.
85
-
86
- ## The credential resolver seam
87
-
88
- Sites that issue their own API keys or personal tokens supply one `ConsumerCredentialResolver` through the Worker's `extend` seam. It returns exactly one of three outcomes:
37
+ The generated `src/service.ts` wraps every surface in
38
+ `withCaller(resolver, surface)`:
39
+
40
+ - A credential that was presented but fails is answered 401 before any
41
+ surface runs. It is never treated as anonymous; only "no credential" is.
42
+ - A cookie session may not mutate across origins: a non-GET request with a
43
+ session needs a same-origin `Origin` or `Sec-Fetch-Site`, or it is 403.
44
+ - Identity `mantle` resolves Better Auth sessions and OAuth bearer tokens;
45
+ identity `custom` is your `src/identity.ts`; identity `none` passes
46
+ `{ kind: "anonymous" }`. See [Authentication](../cloudflare/authentication.md).
47
+
48
+ ## `requires`
49
+
50
+ Views and Procedures take the same block:
51
+
52
+ ```yaml
53
+ requires:
54
+ auth:
55
+ all:
56
+ - ctx.user
57
+ - { ctx.staff: [owner, editor] }
58
+ - { ctx.auth.scope: "exports:read" }
59
+ guard: { procedure: require-active-plan }
60
+ ```
89
61
 
90
- | Outcome | Meaning |
62
+ | Predicate | Holds when |
91
63
  |---|---|
92
- | `not-handled` | The request carries none of the site's credential formats. Resolution moves on. |
93
- | `invalid` | The request carries a recognized format that is bad, revoked or malformed. |
94
- | `verified` | The site's authoritative record was checked; normalized metadata is returned. |
95
-
96
- Resolution precedence is site resolver, then configured OAuth bearer, then cookie session. A recognized-but-invalid credential never falls back to a valid cookie: presenting a revoked key is a failure, not an invitation to be treated as an anonymous browser. Return `not-handled`, never `invalid`, for a request your resolver simply does not recognize.
64
+ | `ctx.user` | the caller is a `user` |
65
+ | `ctx.auth` | the caller is a `user` (any verified credential) |
66
+ | `{ ctx.staff: [roles] }` | the caller's `role` is one of them |
67
+ | `{ ctx.auth.scope: "<scope>" }` | the caller's `scopes` include it; repeat for several |
68
+
69
+ Every predicate in `all` must hold. A system or anonymous caller satisfies
70
+ none. A failure is 401 `UNAUTHENTICATED` for an anonymous caller and 403
71
+ `AUTH_DENIED` for a signed-in one. The optional guard is a `ref` Procedure
72
+ that runs next and may reject with any code, for example
73
+ `ENTITLEMENT_REQUIRED` (402).
74
+
75
+ `requires` is checked on every path: REST, MCP, Admin operations,
76
+ `ctx.invoke` and `runtime.invokeProcedure`. Listing a tool is not permission
77
+ to call it.
78
+
79
+ ## Rows: scope and `auth.uid()`
80
+
81
+ `requires` decides whether a caller may run a View or Procedure. Which
82
+ **rows** it reaches is decided in the data:
83
+
84
+ **Scope** hides rows from everyone but their owner:
85
+
86
+ ```yaml
87
+ kind: Schema
88
+ metadata: { name: orders }
89
+ spec:
90
+ scope: { owner: auth.uid() }
91
+ indexes: [[owner]]
92
+ schema:
93
+ required: [owner, …]
94
+ ```
97
95
 
98
- Scopes are opaque strings the site defines and grants. Mantle compares them; it does not interpret `catalog:read`, publish a scope catalog, or infer a hierarchy. Correspondingly, Mantle issues and stores no API keys or personal tokens, and holds no payment or subscription state. Those tables, their issuance, hashing, rotation and revocation, and whatever fills them from a billing provider, are application code. Mantle owns verification, normalization and enforcement.
96
+ - The scope field is a required string, the first column of an index, and the
97
+ first column of every `uniqueIndexes` entry.
98
+ - Every read and write of a user caller is limited to rows whose `owner` is its
99
+ subject key; an anonymous caller reaches none. Store fills `owner` on insert,
100
+ and no write may set it, so a row can never move to another owner.
101
+ - Staff are user callers too: scope hides other users' rows from them as
102
+ well. Use scope only for rows that no one but the owner may ever see.
103
+ - `runtime.store` and the system caller are not scoped.
104
+
105
+ **`auth.uid()` in SQL** covers the rest. When staff must see every row but a
106
+ member sees only their own, store the writer and filter on it:
107
+
108
+ ```sql
109
+ INSERT INTO requisitions (requestedBy, item) VALUES (auth.uid(), input.item);
110
+ SELECT … FROM requisitions WHERE requestedBy = auth.uid();
111
+ ```
99
112
 
100
- ## MCP is the same pipeline
113
+ The writer comes from the caller, never from an input. See
114
+ [Procurement approvals](../../examples/procurement.md).
101
115
 
102
- An MCP `tools/call` runs the identical evaluator, in the identical order, with the identical diagnostics — surfaced as JSON-RPC errors carrying `error.data.code` instead of an HTTP status. A Trigger's `source.surface` selects which catalog lists a tool, and `tools/list` hides what the caller cannot see. That filtering is discovery UX, not enforcement: a client that guesses a tool name still meets every predicate and the guard. Discovery is never the authorization boundary. See [MCP and agents](./mcp-and-agents.md).
116
+ ## Admin
103
117
 
104
- ## Related
118
+ Admin's gate admits any staff role, and each Admin route names the least role
119
+ it needs. Admin reads and writes through `runtime.store.as(caller)`, so scope
120
+ and `requires` apply to staff exactly as to anyone. See
121
+ [Customize Admin](../guides/admin-ui.md).
105
122
 
106
- - [Authorization requirements](../reference/authorization.md) — the `requires` shape, predicate forms, guard rules, OpenAPI projection.
107
- - [Guarded API access](../../examples/cf-primitives-guarded-api.md) — a full resolver, guards and the REST/MCP outcome tables.
108
- - [Reads: Views, REST and MCP](./views.md) — the `$ctx.user` identity-View sentinel.
109
- - [Authentication](../cloudflare/authentication.md) — sessions, first owner, role management routes.
123
+ ## Further reading
110
124
 
111
- ## Source
112
- - [`docs/adapter-guide.md`](../../../docs/adapter-guide.md)
113
- - [`packages/mantle-runtime/src/domain/model/HandlerContext.ts`](../../../packages/mantle-runtime/src/domain/model/HandlerContext.ts)
114
- - [`packages/mantle-runtime/src/usecase/procedure/InvokeProcedureUseCase.ts`](../../../packages/mantle-runtime/src/usecase/procedure/InvokeProcedureUseCase.ts)
115
- - [`packages/adapters/cloudflare/src/mount/resolveCaller.ts`](../../../packages/adapters/cloudflare/src/mount/resolveCaller.ts)
116
- - [`packages/mantle-spec/src/domain/service/StaffRoleHierarchy.ts`](../../../packages/mantle-spec/src/domain/service/StaffRoleHierarchy.ts)
125
+ - [Authorization reference](../reference/authorization.md)
126
+ - [Guarded API access](../../examples/guarded-api.md)
@@ -1,173 +1,97 @@
1
1
  ---
2
- description: Schema, View, Procedure and Trigger — what each atom owns, why reads and writes are asymmetric, and how to compose everything else from four kinds.
2
+ description: The four manifest atoms of Mantle 0.2.0 (Schema, View, Procedure, Trigger), what each compiles to, and how they reference each other.
3
3
  ---
4
4
  # The four atoms
5
5
 
6
- A Mantle Manifest declares exactly four resource kinds under the `cms.mantle.aotter.net/v1` API group. This page explains what each atom owns, how they compose, and how to decide where a new feature belongs. Field-level rules live in the [Reference](../reference/manifest.md) section.
7
-
8
- ## The four kinds
9
-
10
- They map one-to-one onto the primitives Postgres has shipped for thirty years.
11
-
12
- | Atom | Postgres equivalent | Externally exposed by itself? | Has user code? |
13
- |---|---|---|---|
14
- | `Schema` | `CREATE TABLE` | No. Reached only through a View or a Procedure. | No |
15
- | `View` | `CREATE VIEW` | Yes. Auto-mounted on its declared `public` or `staff` REST and MCP surface. | No |
16
- | `Procedure` | `CREATE FUNCTION` | No. Transport-agnostic; needs a Trigger to gain a surface. | Yes — a handler in your project's registry. |
17
- | `Trigger` | `CREATE TRIGGER` plus route and tool binding | Yes. It is the binding atom. | No |
18
-
19
- A four-word gloss covers most questions: Schema is state, View is the read API, Procedure is the write API, Trigger is the binding.
20
-
21
- ## Reads and writes are asymmetric on purpose
22
-
23
- Views mount themselves; Procedures do not. That asymmetry matches HTTP safe-versus-unsafe semantics. A View is a named, read-only query: idempotent, cacheable, and safe to expose the moment its `surface` is declared. A Procedure changes state, so its path, method, tool name and authorization are decisions an author must make explicitly, one Trigger at a time. There is no `Schema.spec.expose.rest` switch and no `/api/<collection>` shortcut; exposing collections directly was considered and rejected, because a Schema stores drafts, server-stamped fields and rows the author never meant to publish.
24
-
25
- The consequence for authors: a Procedure that has no Trigger is unreachable from outside the runtime, and calling its name as a URL returns `404`.
26
-
27
- ## The composition rule
28
-
29
- Anything more domain-shaped than these four is not an atom. A Form, Membership, Email, Webhook, Workflow or ScheduledJob is a composition of Schemas, Views, Procedures and Triggers plus your own TypeScript. A fifth kind would recreate the same overlap: authors would have to decide whether a contact form was a Form, a Workflow or an Email.
30
-
31
- If you find yourself wanting another kind, sketch the same thing as a composition of the four first. Almost always it works.
32
-
33
- ## The Manifest envelope
34
-
35
- Every document carries the same four top-level keys. Unknown keys at any known level are rejected with `INVALID_MANIFEST_ENVELOPE`.
6
+ Every manifest document is one atom:
36
7
 
37
8
  ```yaml
38
- apiVersion: cms.mantle.aotter.net/v1
9
+ apiVersion: cms.mantle.aotter.net/v2
39
10
  kind: Schema | View | Procedure | Trigger
40
- metadata:
41
- name: posts
42
- spec: {}
43
- ```
44
-
45
- There is no `namespace` field. Names are unique within a kind, so a Schema and a View may share a name; two Schemas may not. Multi-tenancy belongs in your application layer, not in manifest metadata.
46
-
47
- One feature usually needs several atoms, so YAML's `---` separator keeps the file count down. Core reads every immediate `.yaml` and `.yml` file in the manifest directory and parses each document independently:
48
-
49
- ```yaml
50
- # manifests/contact.yaml
51
- apiVersion: cms.mantle.aotter.net/v1
52
- kind: Procedure
53
- metadata:
54
- name: send-contact-message
55
- spec:
56
- input:
57
- type: object
58
- additionalProperties: false
59
- required: [name, message]
60
- properties:
61
- name: { type: string, minLength: 1, maxLength: 80 }
62
- message: { type: string, minLength: 1, maxLength: 4000 }
63
- output: { type: object }
64
- handler: { kind: ref, ref: send-contact-message }
65
- ---
66
- apiVersion: cms.mantle.aotter.net/v1
67
- kind: Trigger
68
- metadata:
69
- name: contact-http
70
- spec:
71
- source: { kind: http, method: POST, path: /api/contact }
72
- target: { procedure: send-contact-message }
11
+ metadata: { name: <name> }
12
+ spec: { … }
73
13
  ```
74
14
 
75
- Parsing is all-or-nothing: one error in one document means no `ParsedManifestSet` at all.
15
+ | Atom | Declares | Compiles to | Code |
16
+ |---|---|---|---|
17
+ | **Schema** | rows: a JSON Schema of fields, indexes, `checks`, scope, TTL, lifecycle | one table (`STRICT` on SQLite) with native columns and one column per scalar field | none |
18
+ | **View** | a read: one SQL `SELECT`, its `input`, `surface` and `requires` | validated SQL IR in the plan | none |
19
+ | **Procedure** | a write: `input`, `output`, `requires` and a handler, either SQL statements or a `ref` | IR for `sql`, a name for `ref` | only `ref` |
20
+ | **Trigger** | when a Procedure runs: an HTTP route, an MCP tool, a lifecycle hook or a schedule | a binding in the plan | none |
76
21
 
77
- ## Schema — the entity
22
+ Views read and Procedures write; a View never writes and a Procedure's SQL
23
+ holds write statements only. Custom code exists only behind a Procedure's
24
+ `ref`.
78
25
 
79
- A Schema declares one collection: the JSON Schema for each entry's `data`, its indexes, its Admin presentation and its [lifecycle mode](./lifecycle-and-locales.md). Entries also carry six [native columns](../reference/schema.md#reserved-entry-columns) outside `data`.
26
+ ## How they reference each other
80
27
 
81
- ```yaml
82
- apiVersion: cms.mantle.aotter.net/v1
83
- kind: Schema
84
- metadata:
85
- name: notes
86
- spec:
87
- title: Notes
88
- lifecycle: publishing
89
- schema:
90
- type: object
91
- additionalProperties: false
92
- required: [title, body]
93
- properties:
94
- title: { type: string, minLength: 1, maxLength: 200 }
95
- body: { type: string, x-mcp-hint: markdown }
96
- searchableFields: [title]
97
28
  ```
98
-
99
- Full field rules, the JSON Schema subset and the `x-mantle-bind` / `x-mantle-ref` / `x-mcp-hint` keywords are in the [Schema reference](../reference/schema.md).
100
-
101
- ## View — the read surface
102
-
103
- A View is a named read-only query over Schemas, mounted on exactly one surface. No Trigger is involved.
104
-
105
- ```yaml
106
- apiVersion: cms.mantle.aotter.net/v1
107
- kind: View
108
- metadata:
109
- name: published-notes
110
- spec:
111
- title: Published notes
112
- surface: public
113
- from: notes
114
- fields: [id, title, updatedAt]
115
- filter:
116
- eq: { field: status, value: published }
117
- orderBy:
118
- - { field: updatedAt, direction: desc }
119
- limit: 20
29
+ Trigger ──target──▶ Procedure ──SQL writes / ctx.store──▶ Schema
30
+ ▲ │ ▲
31
+ requires.guard│ └─ctx.invoke──▶ Procedure │
32
+ │ │
33
+ View ────────────SQL SELECT (joins, subqueries)──────────────┘
34
+ Trigger(lifecycle) ◀── a write to its Schema
120
35
  ```
121
36
 
122
- `surface: public` serves `GET /api/views/published-notes` and the `query_view_published_notes` MCP tool on `/mcp`; `surface: staff` moves both behind the staff gate. See [Reads: Views, REST and MCP](./views.md) and the [View reference](../reference/view.md).
123
-
124
- ## Procedure — the typed callable
125
-
126
- A Procedure declares typed `input`, typed `output`, optional `requires`, and one `handler`. It is the only atom with a code seam. The handler is either `kind: builtin` — a CRUD shortcut over one Schema — or `kind: ref`, an opaque key into the `handlers` map your project registers.
37
+ - A View's or Procedure's SQL names Schemas by `metadata.name`; a name that is
38
+ not a plain identifier is quoted (`"support-tickets"`).
39
+ - A Trigger targets one Procedure. A lifecycle Trigger also names the Schema
40
+ it watches.
41
+ - `requires.guard` names a `ref` Procedure that runs before the target.
42
+ - `x-mantle-ref` on a field points at another Schema's `id` or unique field;
43
+ Admin uses it to relate rows and bind operations.
127
44
 
128
- ```yaml
129
- spec:
130
- handler: { kind: builtin, op: create, schema: notes }
131
- ```
45
+ `mantle generate` links every reference and refuses a dangling one, a
46
+ duplicate name, or two names that differ only in case.
132
47
 
133
- Builtin ops are `create`, `update`, `upsert`, `delete` and `archive`. `request_publish` and `publish` are deliberately absent: they are lifecycle operations, not CRUD primitives. See [Writes: Procedures, Triggers and lifecycle hooks](./procedures-and-triggers.md) and the [Procedure reference](../reference/procedure.md).
48
+ ## Native columns
134
49
 
135
- ## Trigger — the binding
50
+ Every Schema table carries native columns that Store fills and no write may
51
+ set:
136
52
 
137
- A Trigger says "when X happens, run Procedure Y". Its `source` is one of three kinds, and its `target.procedure` names a declared Procedure.
53
+ | SQL name | Store JSON name | Meaning |
54
+ |---|---|---|
55
+ | `id` | `id` | text id, generated unless a `ref` handler passes `ctx.store.id()` |
56
+ | `status` | `status` | `draft`, `published` or `archived`; on a `publishing` Schema only (an `operational` one has no `status` column) |
57
+ | `version` | `version` | starts at 1, bumps on every write; the optimistic lock |
58
+ | `created_at`, `updated_at` | `createdAt`, `updatedAt` | timestamps |
59
+ | `author_id` | `authorId` | the subject key of the caller that created the row |
138
60
 
139
- ```yaml
140
- spec:
141
- source: { kind: http, method: POST, path: /api/contact }
142
- # or: { kind: mcp, surface: public }
143
- # or: { kind: lifecycle, schema: notes, on: [before_create] }
144
- target: { procedure: send-contact-message }
145
- ```
61
+ SQL spells them snake_case; the JSON of `ctx.store` keeps camelCase. A Schema
62
+ field may not reuse these names.
146
63
 
147
- Several Triggers may target one Procedure, which is how the same handler becomes an HTTP endpoint, an MCP tool and a lifecycle hook without duplicated logic. Adding a transport is additive; the Procedure never changes. See the [Trigger reference](../reference/trigger.md).
64
+ ## Values in SQL
148
65
 
149
- ## How to think when extending
66
+ | Reference | Is |
67
+ |---|---|
68
+ | `input.<name>` | a declared `input` property |
69
+ | `auth.uid()` | the caller's subject key (`NULL` for an anonymous caller) |
70
+ | `auth.role()` | the caller's staff role, or `NULL` |
71
+ | `now()` | the invocation time |
72
+ | `mantle.search(t, q)`, `mantle.search_rank(t)`, `mantle.near(...)`, `mantle.distance(...)` | full-text search and geo functions |
150
73
 
151
- 1. **What entities does the feature need?** One `Schema` each.
152
- 2. **What named queries?** One `View` each. Ad-hoc reads stay inside handler code; only sanctioned queries become Views, because a View is an external read endpoint.
153
- 3. **What operations?** One `Procedure` each. One Procedure equals one typed function call. Compose in handler code, not in YAML.
154
- 4. **What invokes them?** One `Trigger` per declared HTTP, MCP or lifecycle source.
155
- 5. **Who is allowed?** `requires.auth` for static identity and scope, plus one optional `requires.guard.procedure` for a live business check. See [Authorization](./authorization.md).
74
+ A SQL literal is a literal. There are no `$`-prefixed references and no
75
+ positional `$1`.
156
76
 
157
- ## The Postgres heuristic
77
+ ## What the runtime adds
158
78
 
159
- When you are unsure whether something deserves to be an atom, ask what it would be in Postgres.
79
+ Every Schema reference in every statement, joins and subqueries included, is
80
+ rewritten before it runs:
160
81
 
161
- - If it is a `CREATE X` an **application developer** writes — `TABLE`, `VIEW`, `FUNCTION`, `TRIGGER` — it maps to one of the four.
162
- - If it is a `CREATE X` Postgres only needs because it is a database engine — `INDEX`, `MATERIALIZED VIEW`, `TABLESPACE`, `STATISTICS`, `EVENT TRIGGER`, `EXTENSION`, `LANGUAGE`, `PUBLICATION`, `FOREIGN TABLE`, `RULE` — it does not map, and it belongs behind the storage adapter.
163
- - If it is a type-system extension — `TYPE`, `DOMAIN`, `SEQUENCE`, `COLLATION`, `CAST`, `AGGREGATE`, `OPERATOR` — it folds into the JSON Schema inside a `Schema`.
82
+ - **Scope**: on a Schema with `scope`, a user caller sees and writes only the
83
+ rows whose scope field is its own subject key.
84
+ - **TTL**: expired rows are invisible.
85
+ - **Published-only**: a public View reading a `publishing` Schema sees
86
+ published rows only.
87
+ - **Locks**: `WHERE id = … AND version = input.…` pins one row; writing none is
88
+ `CONFLICT`.
164
89
 
165
- Postgres exposes roughly twenty-five object kinds; an application developer writes four to six of them. That is the same ratio Mantle ships.
90
+ Authors write the business query; they never repeat these rules. See
91
+ [Authorization](./authorization.md) and [Lifecycle and locales](./lifecycle-and-locales.md).
166
92
 
167
- ## Source
93
+ ## Further reading
168
94
 
169
- - [`docs/adr/0001-four-atom-manifest-model.md`](../../../docs/adr/0001-four-atom-manifest-model.md)
170
- - [`docs/adr/0012-views-as-public-rest.md`](../../../docs/adr/0012-views-as-public-rest.md)
171
- - [`packages/mantle-spec/src/domain/model/ManifestGrammar.ts`](../../../packages/mantle-spec/src/domain/model/ManifestGrammar.ts)
172
- - [`packages/mantle-spec/src/domain/service/ManifestParser.ts`](../../../packages/mantle-spec/src/domain/service/ManifestParser.ts)
173
- - [`docs/skills/develop/SKILL.md`](../../skills/develop/SKILL.md)
95
+ - [Reads: Views, REST and MCP](./views.md)
96
+ - [Writes: Procedures, Triggers and hooks](./procedures-and-triggers.md)
97
+ - [Feature table](../reference/features.md)