primitive-admin 1.2.0-alpha.8 → 1.3.0-alpha.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 (563) hide show
  1. package/README.md +258 -186
  2. package/assets/skill/skills/primitive-platform/SKILL.md +103 -29
  3. package/dist/bin/primitive.js +15 -89
  4. package/dist/bin/primitive.js.map +1 -1
  5. package/dist/src/commands/admins.js +80 -17
  6. package/dist/src/commands/admins.js.map +1 -1
  7. package/dist/src/commands/agent-sessions.d.ts +129 -0
  8. package/dist/src/commands/agent-sessions.js +532 -20
  9. package/dist/src/commands/agent-sessions.js.map +1 -1
  10. package/dist/src/commands/analytics.js +207 -155
  11. package/dist/src/commands/analytics.js.map +1 -1
  12. package/dist/src/commands/apps-children.d.ts +1 -1
  13. package/dist/src/commands/apps-children.js +56 -145
  14. package/dist/src/commands/apps-children.js.map +1 -1
  15. package/dist/src/commands/apps-transitions.d.ts +39 -0
  16. package/dist/src/commands/apps-transitions.js +198 -0
  17. package/dist/src/commands/apps-transitions.js.map +1 -0
  18. package/dist/src/commands/apps.d.ts +17 -0
  19. package/dist/src/commands/apps.js +108 -3
  20. package/dist/src/commands/apps.js.map +1 -1
  21. package/dist/src/commands/auth-sessions.js +2 -0
  22. package/dist/src/commands/auth-sessions.js.map +1 -1
  23. package/dist/src/commands/auth.js +138 -44
  24. package/dist/src/commands/auth.js.map +1 -1
  25. package/dist/src/commands/blob-buckets.js +2 -0
  26. package/dist/src/commands/blob-buckets.js.map +1 -1
  27. package/dist/src/commands/collections.js +318 -256
  28. package/dist/src/commands/collections.js.map +1 -1
  29. package/dist/src/commands/comparisons.js +2 -0
  30. package/dist/src/commands/comparisons.js.map +1 -1
  31. package/dist/src/commands/config.d.ts +2 -2
  32. package/dist/src/commands/config.js +59 -33
  33. package/dist/src/commands/config.js.map +1 -1
  34. package/dist/src/commands/connections.js +2 -0
  35. package/dist/src/commands/connections.js.map +1 -1
  36. package/dist/src/commands/database-type-configs.js +5 -3
  37. package/dist/src/commands/database-type-configs.js.map +1 -1
  38. package/dist/src/commands/database-types.js +13 -313
  39. package/dist/src/commands/database-types.js.map +1 -1
  40. package/dist/src/commands/databases.js +6 -4
  41. package/dist/src/commands/databases.js.map +1 -1
  42. package/dist/src/commands/db3-types.d.ts +15 -0
  43. package/dist/src/commands/db3-types.js +159 -0
  44. package/dist/src/commands/db3-types.js.map +1 -0
  45. package/dist/src/commands/db3.d.ts +24 -0
  46. package/dist/src/commands/db3.js +1444 -0
  47. package/dist/src/commands/db3.js.map +1 -0
  48. package/dist/src/commands/documents.d.ts +110 -10
  49. package/dist/src/commands/documents.js +1012 -748
  50. package/dist/src/commands/documents.js.map +1 -1
  51. package/dist/src/commands/email-templates.js +74 -0
  52. package/dist/src/commands/email-templates.js.map +1 -1
  53. package/dist/src/commands/env.js +8 -4
  54. package/dist/src/commands/env.js.map +1 -1
  55. package/dist/src/commands/function-trigger-commands.d.ts +28 -0
  56. package/dist/src/commands/function-trigger-commands.js +341 -0
  57. package/dist/src/commands/function-trigger-commands.js.map +1 -0
  58. package/dist/src/commands/functions.js +376 -30
  59. package/dist/src/commands/functions.js.map +1 -1
  60. package/dist/src/commands/groups.js +168 -50
  61. package/dist/src/commands/groups.js.map +1 -1
  62. package/dist/src/commands/guides.js +7 -5
  63. package/dist/src/commands/guides.js.map +1 -1
  64. package/dist/src/commands/hosting.d.ts +8 -0
  65. package/dist/src/commands/hosting.js +346 -0
  66. package/dist/src/commands/hosting.js.map +1 -0
  67. package/dist/src/commands/init.js +129 -38
  68. package/dist/src/commands/init.js.map +1 -1
  69. package/dist/src/commands/integrations.js +82 -53
  70. package/dist/src/commands/integrations.js.map +1 -1
  71. package/dist/src/commands/llm.js +9 -6
  72. package/dist/src/commands/llm.js.map +1 -1
  73. package/dist/src/commands/locks.d.ts +5 -3
  74. package/dist/src/commands/locks.js +19 -61
  75. package/dist/src/commands/locks.js.map +1 -1
  76. package/dist/src/commands/metadata-category-configs.d.ts +2 -2
  77. package/dist/src/commands/metadata-category-configs.js +4 -2
  78. package/dist/src/commands/metadata-category-configs.js.map +1 -1
  79. package/dist/src/commands/metadata.js +41 -0
  80. package/dist/src/commands/metadata.js.map +1 -1
  81. package/dist/src/commands/prompts.js +75 -52
  82. package/dist/src/commands/prompts.js.map +1 -1
  83. package/dist/src/commands/rate-counters.d.ts +19 -0
  84. package/dist/src/commands/rate-counters.js +104 -0
  85. package/dist/src/commands/rate-counters.js.map +1 -0
  86. package/dist/src/commands/rule-sets.d.ts +1 -1
  87. package/dist/src/commands/rule-sets.js +2 -1
  88. package/dist/src/commands/rule-sets.js.map +1 -1
  89. package/dist/src/commands/schemas.d.ts +15 -0
  90. package/dist/src/commands/schemas.js +122 -0
  91. package/dist/src/commands/schemas.js.map +1 -0
  92. package/dist/src/commands/scripts.d.ts +9 -17
  93. package/dist/src/commands/scripts.js +24 -479
  94. package/dist/src/commands/scripts.js.map +1 -1
  95. package/dist/src/commands/secrets.js +47 -3
  96. package/dist/src/commands/secrets.js.map +1 -1
  97. package/dist/src/commands/sessions.js +2 -0
  98. package/dist/src/commands/sessions.js.map +1 -1
  99. package/dist/src/commands/settings.d.ts +12 -9
  100. package/dist/src/commands/settings.js +31 -79
  101. package/dist/src/commands/settings.js.map +1 -1
  102. package/dist/src/commands/skill.js +2 -0
  103. package/dist/src/commands/skill.js.map +1 -1
  104. package/dist/src/commands/sync-schemas.d.ts +202 -0
  105. package/dist/src/commands/sync-schemas.js +629 -0
  106. package/dist/src/commands/sync-schemas.js.map +1 -0
  107. package/dist/src/commands/sync-user-properties.d.ts +118 -0
  108. package/dist/src/commands/sync-user-properties.js +276 -0
  109. package/dist/src/commands/sync-user-properties.js.map +1 -0
  110. package/dist/src/commands/sync.d.ts +519 -554
  111. package/dist/src/commands/sync.js +3010 -4909
  112. package/dist/src/commands/sync.js.map +1 -1
  113. package/dist/src/commands/tokens.js +5 -3
  114. package/dist/src/commands/tokens.js.map +1 -1
  115. package/dist/src/commands/transitions.d.ts +54 -0
  116. package/dist/src/commands/transitions.js +418 -0
  117. package/dist/src/commands/transitions.js.map +1 -0
  118. package/dist/src/commands/usage.d.ts +18 -0
  119. package/dist/src/commands/usage.js +343 -0
  120. package/dist/src/commands/usage.js.map +1 -0
  121. package/dist/src/commands/user-properties.d.ts +14 -0
  122. package/dist/src/commands/user-properties.js +79 -0
  123. package/dist/src/commands/user-properties.js.map +1 -0
  124. package/dist/src/commands/users.js +911 -18
  125. package/dist/src/commands/users.js.map +1 -1
  126. package/dist/src/commands/vars.js +2 -0
  127. package/dist/src/commands/vars.js.map +1 -1
  128. package/dist/src/commands/waitlist.js +39 -4
  129. package/dist/src/commands/waitlist.js.map +1 -1
  130. package/dist/src/commands/workflows.d.ts +5 -83
  131. package/dist/src/commands/workflows.js +57 -2282
  132. package/dist/src/commands/workflows.js.map +1 -1
  133. package/dist/src/lib/analytics-query.d.ts +58 -0
  134. package/dist/src/lib/analytics-query.js +134 -0
  135. package/dist/src/lib/analytics-query.js.map +1 -0
  136. package/dist/src/lib/api-client.d.ts +1830 -429
  137. package/dist/src/lib/api-client.js +1025 -546
  138. package/dist/src/lib/api-client.js.map +1 -1
  139. package/dist/src/lib/app-settings-descriptor.d.ts +1 -1
  140. package/dist/src/lib/app-settings-descriptor.js +6 -0
  141. package/dist/src/lib/app-settings-descriptor.js.map +1 -1
  142. package/dist/src/lib/auth-fixtures.d.ts +44 -0
  143. package/dist/src/lib/auth-fixtures.js +61 -0
  144. package/dist/src/lib/auth-fixtures.js.map +1 -0
  145. package/dist/src/lib/auth-flow.d.ts +34 -1
  146. package/dist/src/lib/auth-flow.js +429 -13
  147. package/dist/src/lib/auth-flow.js.map +1 -1
  148. package/dist/src/lib/block-layout.d.ts +12 -23
  149. package/dist/src/lib/block-layout.js +26 -92
  150. package/dist/src/lib/block-layout.js.map +1 -1
  151. package/dist/src/lib/block-selector.d.ts +8 -14
  152. package/dist/src/lib/block-selector.js +8 -19
  153. package/dist/src/lib/block-selector.js.map +1 -1
  154. package/dist/src/lib/child-apps-local.d.ts +3 -47
  155. package/dist/src/lib/child-apps-local.js +11 -73
  156. package/dist/src/lib/child-apps-local.js.map +1 -1
  157. package/dist/src/lib/cli-manifest.d.ts +9 -0
  158. package/dist/src/lib/cli-manifest.js +10 -1
  159. package/dist/src/lib/cli-manifest.js.map +1 -1
  160. package/dist/src/lib/cli-version.d.ts +14 -0
  161. package/dist/src/lib/cli-version.js +38 -0
  162. package/dist/src/lib/cli-version.js.map +1 -0
  163. package/dist/src/lib/codegen-shared/prettierStable.d.ts +41 -0
  164. package/dist/src/lib/codegen-shared/prettierStable.js +146 -24
  165. package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -1
  166. package/dist/src/lib/collection-export.d.ts +76 -15
  167. package/dist/src/lib/collection-export.js +116 -23
  168. package/dist/src/lib/collection-export.js.map +1 -1
  169. package/dist/src/lib/collection-principal.d.ts +22 -0
  170. package/dist/src/lib/collection-principal.js +35 -0
  171. package/dist/src/lib/collection-principal.js.map +1 -0
  172. package/dist/src/lib/command-groups.d.ts +30 -0
  173. package/dist/src/lib/command-groups.js +109 -0
  174. package/dist/src/lib/command-groups.js.map +1 -0
  175. package/dist/src/lib/command-status.d.ts +147 -0
  176. package/dist/src/lib/command-status.js +266 -0
  177. package/dist/src/lib/command-status.js.map +1 -0
  178. package/dist/src/lib/config-object-descriptor.d.ts +9 -22
  179. package/dist/src/lib/config-object-descriptor.js +107 -276
  180. package/dist/src/lib/config-object-descriptor.js.map +1 -1
  181. package/dist/src/lib/config-surface.d.ts +3 -7
  182. package/dist/src/lib/config-surface.js +9 -13
  183. package/dist/src/lib/config-surface.js.map +1 -1
  184. package/dist/src/lib/config-toml.d.ts +11 -2
  185. package/dist/src/lib/config-toml.js +25 -2
  186. package/dist/src/lib/config-toml.js.map +1 -1
  187. package/dist/src/lib/credentials-home.d.ts +7 -0
  188. package/dist/src/lib/credentials-home.js +45 -10
  189. package/dist/src/lib/credentials-home.js.map +1 -1
  190. package/dist/src/lib/credentials-lock.d.ts +14 -6
  191. package/dist/src/lib/credentials-lock.js +90 -10
  192. package/dist/src/lib/credentials-lock.js.map +1 -1
  193. package/dist/src/lib/credentials-store.d.ts +123 -70
  194. package/dist/src/lib/credentials-store.js +358 -113
  195. package/dist/src/lib/credentials-store.js.map +1 -1
  196. package/dist/src/lib/custodian.d.ts +8 -0
  197. package/dist/src/lib/custodian.js +18 -0
  198. package/dist/src/lib/custodian.js.map +1 -0
  199. package/dist/src/lib/data-input.d.ts +1 -1
  200. package/dist/src/lib/data-input.js +1 -1
  201. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +1 -1
  202. package/dist/src/lib/db-codegen/dbTsTypes.js +3 -0
  203. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
  204. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +38 -1
  205. package/dist/src/lib/db-codegen/dbTypeIR.js +29 -7
  206. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -1
  207. package/dist/src/lib/db-type-records.d.ts +106 -0
  208. package/dist/src/lib/db-type-records.js +224 -0
  209. package/dist/src/lib/db-type-records.js.map +1 -0
  210. package/dist/src/lib/db3-export.d.ts +287 -0
  211. package/dist/src/lib/db3-export.js +647 -0
  212. package/dist/src/lib/db3-export.js.map +1 -0
  213. package/dist/src/lib/db3-index-output.d.ts +116 -0
  214. package/dist/src/lib/db3-index-output.js +223 -0
  215. package/dist/src/lib/db3-index-output.js.map +1 -0
  216. package/dist/src/lib/db3-type-models.d.ts +134 -0
  217. package/dist/src/lib/db3-type-models.js +452 -0
  218. package/dist/src/lib/db3-type-models.js.map +1 -0
  219. package/dist/src/lib/deprecation.d.ts +2 -2
  220. package/dist/src/lib/deprecation.js +2 -2
  221. package/dist/src/lib/document-ingest-artifact.d.ts +13 -0
  222. package/dist/src/lib/document-ingest-artifact.js +36 -6
  223. package/dist/src/lib/document-ingest-artifact.js.map +1 -1
  224. package/dist/src/lib/document-ingest-format2.d.ts +36 -0
  225. package/dist/src/lib/document-ingest-format2.js +78 -0
  226. package/dist/src/lib/document-ingest-format2.js.map +1 -0
  227. package/dist/src/lib/document-ingest-input.d.ts +9 -0
  228. package/dist/src/lib/document-ingest-input.js +28 -1
  229. package/dist/src/lib/document-ingest-input.js.map +1 -1
  230. package/dist/src/lib/document-ingest.d.ts +11 -1
  231. package/dist/src/lib/document-ingest.js +16 -0
  232. package/dist/src/lib/document-ingest.js.map +1 -1
  233. package/dist/src/lib/document-schema-rows.d.ts +42 -0
  234. package/dist/src/lib/document-schema-rows.js +53 -0
  235. package/dist/src/lib/document-schema-rows.js.map +1 -0
  236. package/dist/src/lib/experimental-apis.d.ts +36 -0
  237. package/dist/src/lib/experimental-apis.js +46 -0
  238. package/dist/src/lib/experimental-apis.js.map +1 -0
  239. package/dist/src/lib/file-attachment.d.ts +24 -0
  240. package/dist/src/lib/file-attachment.js +31 -0
  241. package/dist/src/lib/file-attachment.js.map +1 -0
  242. package/dist/src/lib/function-authorize-check.d.ts +142 -0
  243. package/dist/src/lib/function-authorize-check.js +311 -0
  244. package/dist/src/lib/function-authorize-check.js.map +1 -0
  245. package/dist/src/lib/function-authorize-view.d.ts +27 -0
  246. package/dist/src/lib/function-authorize-view.js +88 -0
  247. package/dist/src/lib/function-authorize-view.js.map +1 -0
  248. package/dist/src/lib/function-bundle.d.ts +27 -5
  249. package/dist/src/lib/function-bundle.js +142 -7
  250. package/dist/src/lib/function-bundle.js.map +1 -1
  251. package/dist/src/lib/function-collect.d.ts +90 -12
  252. package/dist/src/lib/function-collect.js +482 -12
  253. package/dist/src/lib/function-collect.js.map +1 -1
  254. package/dist/src/lib/function-db-types.d.ts +65 -11
  255. package/dist/src/lib/function-db-types.js +297 -157
  256. package/dist/src/lib/function-db-types.js.map +1 -1
  257. package/dist/src/lib/function-document-types.d.ts +19 -7
  258. package/dist/src/lib/function-document-types.js +24 -12
  259. package/dist/src/lib/function-document-types.js.map +1 -1
  260. package/dist/src/lib/function-lint.d.ts +57 -0
  261. package/dist/src/lib/function-lint.js +234 -0
  262. package/dist/src/lib/function-lint.js.map +1 -0
  263. package/dist/src/lib/function-log-row.js +21 -2
  264. package/dist/src/lib/function-log-row.js.map +1 -1
  265. package/dist/src/lib/function-run.d.ts +13 -21
  266. package/dist/src/lib/function-run.js +14 -27
  267. package/dist/src/lib/function-run.js.map +1 -1
  268. package/dist/src/lib/function-schema-codegen.d.ts +86 -22
  269. package/dist/src/lib/function-schema-codegen.js +194 -88
  270. package/dist/src/lib/function-schema-codegen.js.map +1 -1
  271. package/dist/src/lib/function-schema-refs.d.ts +98 -0
  272. package/dist/src/lib/function-schema-refs.js +177 -0
  273. package/dist/src/lib/function-schema-refs.js.map +1 -0
  274. package/dist/src/lib/function-sync.d.ts +109 -6
  275. package/dist/src/lib/function-sync.js +179 -26
  276. package/dist/src/lib/function-sync.js.map +1 -1
  277. package/dist/src/lib/function-trigger-listing.d.ts +11 -6
  278. package/dist/src/lib/function-trigger-listing.js +32 -11
  279. package/dist/src/lib/function-trigger-listing.js.map +1 -1
  280. package/dist/src/lib/function-triggers.d.ts +15 -3
  281. package/dist/src/lib/function-triggers.js +72 -10
  282. package/dist/src/lib/function-triggers.js.map +1 -1
  283. package/dist/src/lib/function-typecheck.d.ts +52 -0
  284. package/dist/src/lib/function-typecheck.js +174 -54
  285. package/dist/src/lib/function-typecheck.js.map +1 -1
  286. package/dist/src/lib/function-versions.d.ts +2 -0
  287. package/dist/src/lib/function-versions.js +1 -0
  288. package/dist/src/lib/function-versions.js.map +1 -1
  289. package/dist/src/lib/generated-build-flags.d.ts +13 -0
  290. package/dist/src/lib/generated-build-flags.js +14 -0
  291. package/dist/src/lib/generated-build-flags.js.map +1 -0
  292. package/dist/src/lib/generated-command-status.d.ts +6 -0
  293. package/dist/src/lib/generated-command-status.js +469 -0
  294. package/dist/src/lib/generated-command-status.js.map +1 -0
  295. package/dist/src/lib/generated-config-surfaces.d.ts +586 -152
  296. package/dist/src/lib/generated-config-surfaces.js +1919 -1883
  297. package/dist/src/lib/generated-config-surfaces.js.map +1 -1
  298. package/dist/src/lib/generated-sdk-types.d.ts +1 -1
  299. package/dist/src/lib/generated-sdk-types.js +1 -1
  300. package/dist/src/lib/generated-sdk-types.js.map +1 -1
  301. package/dist/src/lib/generated-workflow-model-fields.d.ts +20 -0
  302. package/dist/src/lib/generated-workflow-model-fields.js +53 -0
  303. package/dist/src/lib/generated-workflow-model-fields.js.map +1 -0
  304. package/dist/src/lib/hosting-build.d.ts +97 -0
  305. package/dist/src/lib/hosting-build.js +204 -0
  306. package/dist/src/lib/hosting-build.js.map +1 -0
  307. package/dist/src/lib/hosting-client.d.ts +167 -0
  308. package/dist/src/lib/hosting-client.js +340 -0
  309. package/dist/src/lib/hosting-client.js.map +1 -0
  310. package/dist/src/lib/hosting-environments.d.ts +32 -0
  311. package/dist/src/lib/hosting-environments.js +74 -0
  312. package/dist/src/lib/hosting-environments.js.map +1 -0
  313. package/dist/src/lib/hosting-errors.d.ts +30 -0
  314. package/dist/src/lib/hosting-errors.js +43 -0
  315. package/dist/src/lib/hosting-errors.js.map +1 -0
  316. package/dist/src/lib/hosting-token.d.ts +46 -0
  317. package/dist/src/lib/hosting-token.js +60 -0
  318. package/dist/src/lib/hosting-token.js.map +1 -0
  319. package/dist/src/lib/hosting-wait.d.ts +42 -0
  320. package/dist/src/lib/hosting-wait.js +84 -0
  321. package/dist/src/lib/hosting-wait.js.map +1 -0
  322. package/dist/src/lib/hosting-wfp-upload.d.ts +86 -0
  323. package/dist/src/lib/hosting-wfp-upload.js +149 -0
  324. package/dist/src/lib/hosting-wfp-upload.js.map +1 -0
  325. package/dist/src/lib/init-assets.d.ts +2 -6
  326. package/dist/src/lib/init-assets.js +11 -27
  327. package/dist/src/lib/init-assets.js.map +1 -1
  328. package/dist/src/lib/init-ios-links.d.ts +11 -7
  329. package/dist/src/lib/init-ios-links.js +28 -22
  330. package/dist/src/lib/init-ios-links.js.map +1 -1
  331. package/dist/src/lib/init-login-note.d.ts +13 -0
  332. package/dist/src/lib/init-login-note.js +22 -0
  333. package/dist/src/lib/init-login-note.js.map +1 -0
  334. package/dist/src/lib/init-schema.d.ts +15 -0
  335. package/dist/src/lib/init-schema.js +54 -0
  336. package/dist/src/lib/init-schema.js.map +1 -1
  337. package/dist/src/lib/integration-test-request.d.ts +54 -0
  338. package/dist/src/lib/integration-test-request.js +207 -0
  339. package/dist/src/lib/integration-test-request.js.map +1 -0
  340. package/dist/src/lib/invoker-shared-enums.d.ts +35 -0
  341. package/dist/src/lib/invoker-shared-enums.js +98 -0
  342. package/dist/src/lib/invoker-shared-enums.js.map +1 -0
  343. package/dist/src/lib/json-value.d.ts +6 -0
  344. package/dist/src/lib/json-value.js +13 -0
  345. package/dist/src/lib/json-value.js.map +1 -0
  346. package/dist/src/lib/load-routes.d.ts +33 -0
  347. package/dist/src/lib/load-routes.js +35 -0
  348. package/dist/src/lib/load-routes.js.map +1 -0
  349. package/dist/src/lib/log-inspection.d.ts +23 -4
  350. package/dist/src/lib/log-inspection.js +14 -5
  351. package/dist/src/lib/log-inspection.js.map +1 -1
  352. package/dist/src/lib/login-exchange-check.d.ts +18 -0
  353. package/dist/src/lib/login-exchange-check.js +27 -0
  354. package/dist/src/lib/login-exchange-check.js.map +1 -0
  355. package/dist/src/lib/login-scope-lines.d.ts +17 -7
  356. package/dist/src/lib/login-scope-lines.js +33 -10
  357. package/dist/src/lib/login-scope-lines.js.map +1 -1
  358. package/dist/src/lib/metadata-report.d.ts +85 -0
  359. package/dist/src/lib/metadata-report.js +81 -0
  360. package/dist/src/lib/metadata-report.js.map +1 -0
  361. package/dist/src/lib/object-status-filter.d.ts +9 -1
  362. package/dist/src/lib/object-status-filter.js +9 -1
  363. package/dist/src/lib/object-status-filter.js.map +1 -1
  364. package/dist/src/lib/output.d.ts +1 -1
  365. package/dist/src/lib/output.js +3 -1
  366. package/dist/src/lib/output.js.map +1 -1
  367. package/dist/src/lib/pin-refusal-hint.d.ts +12 -0
  368. package/dist/src/lib/pin-refusal-hint.js +35 -0
  369. package/dist/src/lib/pin-refusal-hint.js.map +1 -0
  370. package/dist/src/lib/platform-owned.js +5 -0
  371. package/dist/src/lib/platform-owned.js.map +1 -1
  372. package/dist/src/lib/primitive-declaration-names.d.ts +21 -0
  373. package/dist/src/lib/primitive-declaration-names.js +22 -0
  374. package/dist/src/lib/primitive-declaration-names.js.map +1 -0
  375. package/dist/src/lib/primitive-declaration.d.ts +174 -0
  376. package/dist/src/lib/primitive-declaration.js +792 -0
  377. package/dist/src/lib/primitive-declaration.js.map +1 -0
  378. package/dist/src/lib/primitive-env-plugin.d.ts +99 -0
  379. package/dist/src/lib/primitive-env-plugin.js +408 -0
  380. package/dist/src/lib/primitive-env-plugin.js.map +1 -0
  381. package/dist/src/lib/project-login-apps.d.ts +8 -0
  382. package/dist/src/lib/project-login-apps.js +27 -0
  383. package/dist/src/lib/project-login-apps.js.map +1 -0
  384. package/dist/src/lib/prompt-schema-codegen.d.ts +46 -15
  385. package/dist/src/lib/prompt-schema-codegen.js +142 -108
  386. package/dist/src/lib/prompt-schema-codegen.js.map +1 -1
  387. package/dist/src/lib/prompt-schema-document.d.ts +35 -0
  388. package/dist/src/lib/prompt-schema-document.js +92 -0
  389. package/dist/src/lib/prompt-schema-document.js.map +1 -0
  390. package/dist/src/lib/prompt-schema-refs.d.ts +173 -0
  391. package/dist/src/lib/prompt-schema-refs.js +478 -0
  392. package/dist/src/lib/prompt-schema-refs.js.map +1 -0
  393. package/dist/src/lib/records-verbs.d.ts +79 -0
  394. package/dist/src/lib/records-verbs.js +45 -0
  395. package/dist/src/lib/records-verbs.js.map +1 -0
  396. package/dist/src/lib/register-commands.d.ts +36 -0
  397. package/dist/src/lib/register-commands.js +37 -0
  398. package/dist/src/lib/register-commands.js.map +1 -0
  399. package/dist/src/lib/retired-imports.d.ts +53 -0
  400. package/dist/src/lib/retired-imports.js +120 -0
  401. package/dist/src/lib/retired-imports.js.map +1 -0
  402. package/dist/src/lib/run-status.d.ts +1 -1
  403. package/dist/src/lib/run-status.generated.d.ts +2 -2
  404. package/dist/src/lib/run-status.generated.js +3 -1
  405. package/dist/src/lib/run-status.generated.js.map +1 -1
  406. package/dist/src/lib/run-status.js +1 -1
  407. package/dist/src/lib/schema-codegen/compiledSpace.d.ts +62 -0
  408. package/dist/src/lib/schema-codegen/compiledSpace.js +103 -0
  409. package/dist/src/lib/schema-codegen/compiledSpace.js.map +1 -0
  410. package/dist/src/lib/schema-codegen/generated-db3-bridge.d.ts +86 -0
  411. package/dist/src/lib/schema-codegen/generated-db3-bridge.js +227 -0
  412. package/dist/src/lib/schema-codegen/generated-db3-bridge.js.map +1 -0
  413. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.d.ts +85 -0
  414. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js +86 -0
  415. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js.map +1 -0
  416. package/dist/src/lib/schema-codegen/generated-field-grammar.d.ts +218 -0
  417. package/dist/src/lib/schema-codegen/generated-field-grammar.js +397 -0
  418. package/dist/src/lib/schema-codegen/generated-field-grammar.js.map +1 -0
  419. package/dist/src/lib/schema-codegen/generated-field-table.d.ts +80 -0
  420. package/dist/src/lib/schema-codegen/generated-field-table.js +542 -0
  421. package/dist/src/lib/schema-codegen/generated-field-table.js.map +1 -0
  422. package/dist/src/lib/schema-codegen/generated-prompt-schemas.d.ts +195 -0
  423. package/dist/src/lib/schema-codegen/generated-prompt-schemas.js +503 -0
  424. package/dist/src/lib/schema-codegen/generated-prompt-schemas.js.map +1 -0
  425. package/dist/src/lib/schema-codegen/generated-schema-descriptor.d.ts +258 -0
  426. package/dist/src/lib/schema-codegen/generated-schema-descriptor.js +422 -0
  427. package/dist/src/lib/schema-codegen/generated-schema-descriptor.js.map +1 -0
  428. package/dist/src/lib/schema-codegen/generated-schema-file.d.ts +129 -0
  429. package/dist/src/lib/schema-codegen/generated-schema-file.js +475 -0
  430. package/dist/src/lib/schema-codegen/generated-schema-file.js.map +1 -0
  431. package/dist/src/lib/schema-codegen/generated-schema-provenance.d.ts +115 -0
  432. package/dist/src/lib/schema-codegen/generated-schema-provenance.js +274 -0
  433. package/dist/src/lib/schema-codegen/generated-schema-provenance.js.map +1 -0
  434. package/dist/src/lib/schema-codegen/generated-schema-refs.d.ts +366 -0
  435. package/dist/src/lib/schema-codegen/generated-schema-refs.js +1789 -0
  436. package/dist/src/lib/schema-codegen/generated-schema-refs.js.map +1 -0
  437. package/dist/src/lib/schema-codegen/generated-schema-shape.d.ts +27 -0
  438. package/dist/src/lib/schema-codegen/generated-schema-shape.js +126 -0
  439. package/dist/src/lib/schema-codegen/generated-schema-shape.js.map +1 -0
  440. package/dist/src/lib/schema-codegen/namedRefs.d.ts +56 -0
  441. package/dist/src/lib/schema-codegen/namedRefs.js +143 -0
  442. package/dist/src/lib/schema-codegen/namedRefs.js.map +1 -0
  443. package/dist/src/lib/schema-codegen/naming.d.ts +35 -0
  444. package/dist/src/lib/schema-codegen/naming.js +83 -0
  445. package/dist/src/lib/schema-codegen/naming.js.map +1 -0
  446. package/dist/src/lib/schema-codegen/schemaChanges.d.ts +74 -0
  447. package/dist/src/lib/schema-codegen/schemaChanges.js +277 -0
  448. package/dist/src/lib/schema-codegen/schemaChanges.js.map +1 -0
  449. package/dist/src/lib/schema-codegen/schemaDocs.d.ts +69 -0
  450. package/dist/src/lib/schema-codegen/schemaDocs.js +219 -0
  451. package/dist/src/lib/schema-codegen/schemaDocs.js.map +1 -0
  452. package/dist/src/lib/schema-codegen/schemaIR.d.ts +158 -0
  453. package/dist/src/lib/schema-codegen/schemaIR.js +279 -0
  454. package/dist/src/lib/schema-codegen/schemaIR.js.map +1 -0
  455. package/dist/src/lib/schema-codegen/schemaToTs.d.ts +109 -0
  456. package/dist/src/lib/schema-codegen/schemaToTs.js +269 -0
  457. package/dist/src/lib/schema-codegen/schemaToTs.js.map +1 -0
  458. package/dist/src/lib/schema-codegen/valuesLists.d.ts +48 -0
  459. package/dist/src/lib/schema-codegen/valuesLists.js +144 -0
  460. package/dist/src/lib/schema-codegen/valuesLists.js.map +1 -0
  461. package/dist/src/lib/schema-family-index.d.ts +228 -0
  462. package/dist/src/lib/schema-family-index.js +813 -0
  463. package/dist/src/lib/schema-family-index.js.map +1 -0
  464. package/dist/src/lib/schema-pins.d.ts +82 -0
  465. package/dist/src/lib/schema-pins.js +198 -0
  466. package/dist/src/lib/schema-pins.js.map +1 -0
  467. package/dist/src/lib/schema-preview.d.ts +244 -0
  468. package/dist/src/lib/schema-preview.js +498 -0
  469. package/dist/src/lib/schema-preview.js.map +1 -0
  470. package/dist/src/lib/scope-request.d.ts +23 -11
  471. package/dist/src/lib/scope-request.js +69 -31
  472. package/dist/src/lib/scope-request.js.map +1 -1
  473. package/dist/src/lib/session-scope.d.ts +26 -0
  474. package/dist/src/lib/session-scope.js +58 -0
  475. package/dist/src/lib/session-scope.js.map +1 -0
  476. package/dist/src/lib/skill-installer.d.ts +2 -2
  477. package/dist/src/lib/skill-installer.js +2 -21
  478. package/dist/src/lib/skill-installer.js.map +1 -1
  479. package/dist/src/lib/step-run-table.d.ts +1 -2
  480. package/dist/src/lib/step-run-table.js +1 -2
  481. package/dist/src/lib/step-run-table.js.map +1 -1
  482. package/dist/src/lib/swift-codegen/agentGenerator.d.ts +8 -3
  483. package/dist/src/lib/swift-codegen/agentGenerator.js +76 -22
  484. package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -1
  485. package/dist/src/lib/swift-codegen/banners.d.ts +12 -0
  486. package/dist/src/lib/swift-codegen/banners.js +12 -0
  487. package/dist/src/lib/swift-codegen/banners.js.map +1 -1
  488. package/dist/src/lib/swift-codegen/functionGenerator.d.ts +36 -1
  489. package/dist/src/lib/swift-codegen/functionGenerator.js +169 -51
  490. package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -1
  491. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +33 -9
  492. package/dist/src/lib/swift-codegen/schemaToSwift.js +215 -179
  493. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -1
  494. package/dist/src/lib/swift-codegen/sharedGenerator.d.ts +45 -0
  495. package/dist/src/lib/swift-codegen/sharedGenerator.js +165 -0
  496. package/dist/src/lib/swift-codegen/sharedGenerator.js.map +1 -0
  497. package/dist/src/lib/swift-codegen/swiftKeys.d.ts +19 -0
  498. package/dist/src/lib/swift-codegen/swiftKeys.js +31 -0
  499. package/dist/src/lib/swift-codegen/swiftKeys.js.map +1 -0
  500. package/dist/src/lib/swift-codegen/userPropertiesGenerator.d.ts +30 -0
  501. package/dist/src/lib/swift-codegen/userPropertiesGenerator.js +69 -0
  502. package/dist/src/lib/swift-codegen/userPropertiesGenerator.js.map +1 -0
  503. package/dist/src/lib/sync-resource-types.d.ts +117 -31
  504. package/dist/src/lib/sync-resource-types.js +197 -189
  505. package/dist/src/lib/sync-resource-types.js.map +1 -1
  506. package/dist/src/lib/sync-selectors.d.ts +7 -0
  507. package/dist/src/lib/sync-selectors.js +22 -2
  508. package/dist/src/lib/sync-selectors.js.map +1 -1
  509. package/dist/src/lib/template.d.ts +39 -3
  510. package/dist/src/lib/template.js +103 -14
  511. package/dist/src/lib/template.js.map +1 -1
  512. package/dist/src/lib/test-case-file-names.d.ts +3 -5
  513. package/dist/src/lib/test-case-file-names.js +3 -5
  514. package/dist/src/lib/test-case-file-names.js.map +1 -1
  515. package/dist/src/lib/test-runs.d.ts +45 -0
  516. package/dist/src/lib/test-runs.js +150 -0
  517. package/dist/src/lib/test-runs.js.map +1 -0
  518. package/dist/src/lib/test-users.d.ts +25 -0
  519. package/dist/src/lib/test-users.js +36 -0
  520. package/dist/src/lib/test-users.js.map +1 -0
  521. package/dist/src/lib/toml-database-config.d.ts +4 -2
  522. package/dist/src/lib/toml-database-config.js +11 -6
  523. package/dist/src/lib/toml-database-config.js.map +1 -1
  524. package/dist/src/lib/toml-scalar-edit.js +6 -4
  525. package/dist/src/lib/toml-scalar-edit.js.map +1 -1
  526. package/dist/src/lib/transition-warnings.d.ts +21 -0
  527. package/dist/src/lib/transition-warnings.js +49 -0
  528. package/dist/src/lib/transition-warnings.js.map +1 -0
  529. package/dist/src/lib/user-index.d.ts +80 -0
  530. package/dist/src/lib/user-index.js +166 -0
  531. package/dist/src/lib/user-index.js.map +1 -0
  532. package/dist/src/lib/user-properties/generated-properties-schema.d.ts +159 -0
  533. package/dist/src/lib/user-properties/generated-properties-schema.js +471 -0
  534. package/dist/src/lib/user-properties/generated-properties-schema.js.map +1 -0
  535. package/dist/src/lib/user-properties/user-properties-codegen.d.ts +55 -0
  536. package/dist/src/lib/user-properties/user-properties-codegen.js +129 -0
  537. package/dist/src/lib/user-properties/user-properties-codegen.js.map +1 -0
  538. package/dist/src/lib/user-walk.d.ts +31 -0
  539. package/dist/src/lib/user-walk.js +102 -0
  540. package/dist/src/lib/user-walk.js.map +1 -0
  541. package/dist/src/lib/webhook-capture.d.ts +43 -0
  542. package/dist/src/lib/webhook-capture.js +91 -0
  543. package/dist/src/lib/webhook-capture.js.map +1 -0
  544. package/dist/src/lib/webhook-deliver.d.ts +18 -20
  545. package/dist/src/lib/webhook-deliver.js +34 -89
  546. package/dist/src/lib/webhook-deliver.js.map +1 -1
  547. package/dist/src/lib/webhook-test-run.d.ts +32 -0
  548. package/dist/src/lib/webhook-test-run.js +108 -0
  549. package/dist/src/lib/webhook-test-run.js.map +1 -0
  550. package/dist/src/lib/worker-perf-format.d.ts +22 -0
  551. package/dist/src/lib/worker-perf-format.js +27 -0
  552. package/dist/src/lib/worker-perf-format.js.map +1 -0
  553. package/dist/src/lib/workflow-field-descriptor.d.ts +91 -0
  554. package/dist/src/lib/workflow-field-descriptor.js +153 -0
  555. package/dist/src/lib/workflow-field-descriptor.js.map +1 -0
  556. package/dist/src/types/index.d.ts +20 -65
  557. package/dist/src/validators.d.ts +7 -55
  558. package/dist/src/validators.js +7 -53
  559. package/dist/src/validators.js.map +1 -1
  560. package/dist/src/vite.d.ts +17 -0
  561. package/dist/src/vite.js +18 -0
  562. package/dist/src/vite.js.map +1 -0
  563. package/package.json +20 -9
@@ -14,6 +14,7 @@
14
14
  * `cli/tests/unit/config-surface-drift-guard.test.ts`) fails if this committed
15
15
  * copy does not match the source.
16
16
  */
17
+ import { ONEOF_SIBLING_CONSTRAINT_KEYS, SCHEMA_KEYWORDS, refusedSchemaKeywords, } from "./schema-codegen/generated-schema-descriptor.js";
17
18
  // ── src/config-surface/helpers.ts ────────────────────────────────────────
18
19
  /**
19
20
  * Shared spellings used by every configuration-object definition (issue #2644).
@@ -91,10 +92,11 @@ export function writableFieldNames(table, mode) {
91
92
  .map((f) => f.field);
92
93
  }
93
94
  /**
94
- * The field names the server PERSISTS for this table in `mode`: the writable
95
- * fields, plus the `deprecated` classifications — "still writable, superseded
96
- * by another field" is what that kind means (`types.ts`), so a superseded key
97
- * a handler still honors (`passkeyRpId`) belongs in every accepted set, and a
95
+ * The field names the server ACCEPTS for this table in `mode`: the writable
96
+ * fields, plus the `deprecated` classifications — "still accepted, superseded
97
+ * or scheduled for removal" is what that kind means (`types.ts`), so a
98
+ * superseded key a handler still honors (`protected`) and a retired one it
99
+ * accepts and ignores (`accessRule`, #4872) belong in every accepted set, and a
98
100
  * field that is NOT writable belongs in none of them.
99
101
  *
100
102
  * Stated once here because three consumers need the same answer: the generated
@@ -2160,7 +2162,15 @@ export function requestSchemaKeys(table, mode) {
2160
2162
  */
2161
2163
  export function configRequestSchema(table, mode) {
2162
2164
  const properties = {};
2163
- const deprecatedFields = new Set(table.fields.filter((f) => f.deprecated).map((f) => f.field));
2165
+ // Two sources say a key is deprecated: a field that carries `deprecated`
2166
+ // (#1815), and a model field classified `deprecated` in `notExposed` — a key
2167
+ // still accepted on the wire and kept out of the TOML surface (#4872).
2168
+ const deprecatedFields = new Set([
2169
+ ...table.fields.filter((f) => f.deprecated).map((f) => f.field),
2170
+ ...Object.entries(table.notExposed)
2171
+ .filter(([, classification]) => classification.kind === "deprecated")
2172
+ .map(([field]) => field),
2173
+ ]);
2164
2174
  for (const key of requestSchemaKeys(table, mode)) {
2165
2175
  properties[key] = deprecatedFields.has(key) ? { deprecated: true } : {};
2166
2176
  }
@@ -2402,41 +2412,6 @@ export const RETIRED_CONFIG_KEYS = {
2402
2412
  "spelling is retired (#4283). Send the rule set's id.",
2403
2413
  },
2404
2414
  },
2405
- // #2645 — pausing moved off `state` onto its own field, so `state` stopped
2406
- // being author-writable rather than becoming a second way to say "paused".
2407
- // Every pre-#2645 pull wrote the line, so existing repos hit this on their
2408
- // first push after upgrading: the failure is deliberate (sponsor decision at
2409
- // the approval gate, 2026-08-15), because the line has to be removed, not
2410
- // silently ignored, or the file keeps claiming a pause state push does not
2411
- // apply.
2412
- //
2413
- // #2907 — each of these names TWO verbs, not one. An author writing
2414
- // `status = "archived"` was not asking about availability: they were asking
2415
- // to retire the object, which is the delete flow and is spelled
2416
- // `primitive <noun> archive`. Answering with `enable|disable` alone sent
2417
- // exactly that author away with verbs that cannot do what they asked.
2418
- cronTrigger: {
2419
- state: {
2420
- toml: "`state` is no longer authored in TOML (#2645), and #2803 replaced it " +
2421
- "with the server-owned `status`. Availability is " +
2422
- "`primitive cron-triggers enable|disable`; retiring the trigger is " +
2423
- "`primitive cron-triggers archive` (#2907). Delete the line and push " +
2424
- "again.",
2425
- request: "`state` is server-owned and superseded by `status` (#2645, #2803). " +
2426
- "Use `primitive cron-triggers enable|disable` to change availability, " +
2427
- "or `primitive cron-triggers archive` to retire the trigger (#2907).",
2428
- },
2429
- status: {
2430
- toml: "`status` is no longer authored in TOML (#2803). Availability is " +
2431
- "server-owned: use `primitive cron-triggers enable|disable`. " +
2432
- "Retiring the trigger is `primitive cron-triggers archive` (#2907) — " +
2433
- "the archived row keeps its key and its slot under the per-app cap. " +
2434
- "Delete the line and push again.",
2435
- request: "`status` is server-owned (#2803). Use " +
2436
- "`primitive cron-triggers enable|disable` to change availability, or " +
2437
- "`primitive cron-triggers archive` to retire the trigger (#2907).",
2438
- },
2439
- },
2440
2415
  // #3997 — keyed by each table's TOML prefix. Only `database-type-config`
2441
2416
  // uses `[type]`, so that entry cannot reach another surface. The blob
2442
2417
  // bucket's `[bucket] ruleSetId` has its own entry under `bucket` (#4283).
@@ -2478,6 +2453,8 @@ export const RETIRED_CONFIG_KEYS = {
2478
2453
  "its own readRule and writeRule; omit the field.",
2479
2454
  },
2480
2455
  },
2456
+ // The type-config sections themselves retired in #4731; their #3997 entries
2457
+ // stay, so a section an old tree still carries reads the same guidance.
2481
2458
  groupTypeConfig: { ruleSetId: RULE_SET_ID_RETIRED },
2482
2459
  collectionTypeConfig: { ruleSetId: RULE_SET_ID_RETIRED },
2483
2460
  // #2803 — the OBJECT-level availability leaves TOML. The per-version
@@ -2529,26 +2506,6 @@ export const RETIRED_CONFIG_KEYS = {
2529
2506
  "`primitive integrations archive` to retire the integration (#2907).",
2530
2507
  },
2531
2508
  },
2532
- // #2803 — availability is one server-owned `status`. As a TOML key it made
2533
- // `config push` a second writer: pushing a file pulled before an operator ran
2534
- // `webhooks disable` put the endpoint back in service as a side effect. The
2535
- // tenant app-API create/update also stored the value UNVALIDATED, so any app
2536
- // admin could write any string into the field the receiver gates on.
2537
- webhook: {
2538
- status: {
2539
- toml: "`status` is no longer authored in TOML (#2803). Availability is " +
2540
- "server-owned: use `primitive webhooks enable|disable`. Retiring the " +
2541
- "webhook is `primitive webhooks archive` (#2907) — the archived row " +
2542
- "keeps its key and its slot under the per-app cap. Delete the " +
2543
- "line and push again. If this file describes an ARCHIVED webhook, " +
2544
- "delete the file instead — pull no longer exports tombstones, and the " +
2545
- "next confirmed `config push --prune` hard-deletes the row, freeing " +
2546
- "its slot and its key.",
2547
- request: "`status` is server-owned (#2803). Use " +
2548
- "`primitive webhooks enable|disable` to change availability, or " +
2549
- "`primitive webhooks archive` to retire the webhook (#2907).",
2550
- },
2551
- },
2552
2509
  // #3179 — server functions are the SIXTH status-carrying type, and they take
2553
2510
  // the rule at birth rather than inheriting it: a function's whole point is
2554
2511
  // that it runs code on request, so a `config push` that re-enabled a function
@@ -2637,21 +2594,91 @@ export const RETIRED_CONFIG_KEYS = {
2637
2594
  "`evaluatorConfigName`.",
2638
2595
  },
2639
2596
  },
2640
- // #2803 — availability is one server-owned `status`. As a TOML key it made
2641
- // `config push` a second writer: pushing a file pulled before an operator ran
2642
- // `workflows disable` put the workflow back in service as a side effect.
2643
- workflow: {
2644
- status: {
2645
- toml: "`status` is no longer authored in TOML (#2803). Availability is " +
2646
- "server-owned: use `primitive workflows enable|disable`. Retiring the " +
2647
- "workflow is `primitive workflows archive` (#2907), which keeps its " +
2648
- "runs and revisions resolving. Delete the line and push again.",
2649
- request: "`status` is server-owned (#2803). Use " +
2650
- "`primitive workflows enable|disable` to change availability, or " +
2651
- "`primitive workflows archive` to retire the workflow (#2907).",
2652
- },
2597
+ };
2598
+ // #4872 — nothing evaluates a prompt's or an integration's rule: the only
2599
+ // call paths are a server function's `ctx.prompts.run` and
2600
+ // `ctx.integrations.call`, which skip it. The window is the one `[app].protected`
2601
+ // announced, so the platform schedules one break.
2602
+ function accessRuleDeprecated(noun, decides) {
2603
+ return {
2604
+ toml: `\`accessRule\` is deprecated and ignored: nothing evaluates ${noun}'s ` +
2605
+ `rule, because ${decides}. It will be removed in the first breaking ` +
2606
+ "release after 2026-12-15. Run `primitive config pull` to rewrite this " +
2607
+ "file without it.",
2608
+ };
2609
+ }
2610
+ export const DEPRECATED_CONFIG_KEYS = {
2611
+ prompt: {
2612
+ accessRule: accessRuleDeprecated("a prompt", "the calling function's `authorize` decides who may run it"),
2613
+ },
2614
+ integration: {
2615
+ accessRule: accessRuleDeprecated("an integration", "the calling function's `authorize` and its `integration:<key>` " +
2616
+ "capability decide who may call it"),
2653
2617
  },
2654
2618
  };
2619
+ /** The deprecated-key entry for `key` under `prefix`, or null when it is not deprecated. */
2620
+ export function deprecatedConfigKey(prefix, key) {
2621
+ return DEPRECATED_CONFIG_KEYS[prefix]?.[key] ?? null;
2622
+ }
2623
+ /**
2624
+ * Config-tree directories whose object type retired — #3190, server-functions
2625
+ * phase 7. The DSL engine, the Rhai runtime and the standalone webhook and
2626
+ * cron objects are gone, so `config push` refuses a tree that still holds one
2627
+ * of these directories, by name and before it writes anything, rather than
2628
+ * ignoring files an author still expects to take effect.
2629
+ *
2630
+ * Each entry is one sentence: what retired, what replaces it, and the docs page
2631
+ * that shows the replacement.
2632
+ */
2633
+ export const RETIRED_CONFIG_DIRECTORIES = {
2634
+ workflows: "`workflows/` is no longer part of a config tree (#3190): DSL workflows " +
2635
+ "are retired. Write the logic as a server function under `functions/` " +
2636
+ "(docs: getting-started/server-functions), then delete `workflows/` and " +
2637
+ "push again.",
2638
+ transforms: "`transforms/` is no longer part of a config tree (#3190): scripts and " +
2639
+ "the Rhai runtime are retired. A transform is a pure function under " +
2640
+ "`functions/` (docs: getting-started/server-functions); delete " +
2641
+ "`transforms/` and push again.",
2642
+ webhooks: "`webhooks/` is no longer part of a config tree (#3190): standalone " +
2643
+ "webhooks are retired. Declare the endpoint as " +
2644
+ "`[function.triggers.webhook]` on the server function that handles it " +
2645
+ "(docs: getting-started/inbound-webhooks), then delete `webhooks/` and " +
2646
+ "push again.",
2647
+ "cron-triggers": "`cron-triggers/` is no longer part of a config tree (#3190): standalone " +
2648
+ "cron triggers are retired. Declare the schedule as " +
2649
+ "`[[function.triggers.cron]]` on the server function it runs (docs: " +
2650
+ "getting-started/server-functions), then delete `cron-triggers/` and " +
2651
+ "push again.",
2652
+ };
2653
+ /**
2654
+ * The type-config directories a config tree no longer has (#4731, project
2655
+ * `role-based-groups-collections`). Groups and collections have fixed roles,
2656
+ * so their per-type configuration retired with its routes; `config push`
2657
+ * refuses a tree that still holds a file in either, naming each file, rather
2658
+ * than ignoring files an author still expects to take effect. The rows the
2659
+ * server already stored are not touched.
2660
+ *
2661
+ * Each entry is one sentence: what retired, and what replaces it.
2662
+ */
2663
+ export const RETIRED_TYPE_CONFIG_DIRECTORIES = {
2664
+ "group-type-configs": "`group-type-configs/` is no longer part of a config tree: groups have " +
2665
+ "fixed roles (owner, manager, member). Write a rule the roles do not " +
2666
+ "express as a server function that checks `requireMember` (docs: " +
2667
+ "getting-started/server-functions), and a group metadata manifest as a " +
2668
+ "metadata category config; then delete `group-type-configs/` and push again.",
2669
+ "collection-type-configs": "`collection-type-configs/` is no longer part of a config tree: " +
2670
+ "collections have fixed roles (owner, manager, editor, contributor, " +
2671
+ "viewer). Write a rule the roles do not express as a server function that " +
2672
+ "checks `requireCollectionRole` (docs: getting-started/server-functions), " +
2673
+ "and a collection metadata manifest as a metadata category config; then " +
2674
+ "delete `collection-type-configs/` and push again.",
2675
+ };
2676
+ /** The retirement sentence for a config-tree directory, or null when it is live. */
2677
+ export function retiredConfigDirectory(dir) {
2678
+ return Object.prototype.hasOwnProperty.call(RETIRED_CONFIG_DIRECTORIES, dir)
2679
+ ? RETIRED_CONFIG_DIRECTORIES[dir]
2680
+ : null;
2681
+ }
2655
2682
  /**
2656
2683
  * Top-level TOML tables a configuration object's FILE retired — keyed by the
2657
2684
  * surface's label, then by the table key. Only the TOML half exists: these were
@@ -2713,6 +2740,16 @@ export const RETIRED_TOML_SPELLINGS = {
2713
2740
  // #3642 — the nine chat keys at the prompt `[[configs]]` root. The admin
2714
2741
  // API's create and update bodies still carry them flat; only the TOML
2715
2742
  // grouping (#3626) moved them under `[configs.chat]`.
2743
+ // #4802 — a `db3-types/<name>.toml` file names its type `[type] name`; the
2744
+ // database type file's `databaseType` is a key this surface does not take.
2745
+ // The database type file still declares `databaseType`, so the sentence is
2746
+ // only ever reached from a db3 type file.
2747
+ type: {
2748
+ databaseType: {
2749
+ toml: "`databaseType` names a database type file's type; a db3 type file " +
2750
+ "says `name` (`[type] name = \"<type>\"`). Rename the key and push again.",
2751
+ },
2752
+ },
2716
2753
  configs: {
2717
2754
  systemPrompt: flatChatKeySpelling("systemPrompt", true),
2718
2755
  userPromptTemplate: flatChatKeySpelling("userPromptTemplate", false),
@@ -2725,12 +2762,36 @@ export const RETIRED_TOML_SPELLINGS = {
2725
2762
  reasoningBudget: flatChatKeySpelling("reasoningBudget", true),
2726
2763
  },
2727
2764
  };
2765
+ // #5993 — a db3 type takes no rule set. Nothing evaluates one: every
2766
+ // `db3-types` route is for app admins and owners, who bypass rule sets. The
2767
+ // database type file still takes `ruleSetName`, and its `ruleSetId` keeps the
2768
+ // #3997 sentence, so these are keyed by the db3 type's surface.
2769
+ const DB3_TYPE_RULE_SET_SENTENCE = "A db3 type takes no rule set: nothing evaluated the one this line names, " +
2770
+ "and managing a type is for app admins and owners. Delete the line and " +
2771
+ "push again (`config pull` rewrites the file without it).";
2772
+ /**
2773
+ * Guidance keyed by surface label, then TOML prefix, then key — consulted
2774
+ * before `RETIRED_CONFIG_KEYS` and `RETIRED_TOML_SPELLINGS` when the caller
2775
+ * knows the surface.
2776
+ */
2777
+ export const RETIRED_SURFACE_TOML_KEYS = {
2778
+ "db3-type": {
2779
+ type: {
2780
+ ruleSetName: { toml: DB3_TYPE_RULE_SET_SENTENCE, emptyAccepted: true },
2781
+ ruleSetId: { toml: DB3_TYPE_RULE_SET_SENTENCE },
2782
+ },
2783
+ },
2784
+ };
2728
2785
  /**
2729
- * The TOML guidance for `key` under `prefix`: a fully retired key's, else a
2730
- * retired spelling's, else null when the key is simply unknown.
2786
+ * The TOML guidance for `key` under `prefix`: the surface's own when
2787
+ * `surfaceLabel` names one, else a fully retired key's, else a retired
2788
+ * spelling's, else null when the key is simply unknown.
2731
2789
  */
2732
- export function retiredTomlKey(prefix, key) {
2733
- return (retiredConfigKey(prefix, key) ?? RETIRED_TOML_SPELLINGS[prefix]?.[key] ?? null);
2790
+ export function retiredTomlKey(prefix, key, surfaceLabel) {
2791
+ return ((surfaceLabel ? RETIRED_SURFACE_TOML_KEYS[surfaceLabel]?.[prefix]?.[key] : undefined) ??
2792
+ retiredConfigKey(prefix, key) ??
2793
+ RETIRED_TOML_SPELLINGS[prefix]?.[key] ??
2794
+ null);
2734
2795
  }
2735
2796
  // ── src/config-surface/function-grants.ts ────────────────────────────────
2736
2797
  /**
@@ -2755,7 +2816,10 @@ export function retiredTomlKey(prefix, key) {
2755
2816
  * `secret:<NAME>` credential least privilege — which secret VALUES may
2756
2817
  * cross into the sandbox at all;
2757
2818
  * the high-blast list {@link HIGH_BLAST_CAPABILITIES} — the operations
2758
- * whose blast radius the intent keeps opt-in.
2819
+ * whose blast radius the intent keeps opt-in;
2820
+ * the subject grants {@link SUBJECT_GRANT_CAPABILITIES} — naming another
2821
+ * member on a call about one user, in a run a plain
2822
+ * member invoked.
2759
2823
  *
2760
2824
  * Every other string a function used to declare is RETIRED, and the grammar
2761
2825
  * says so by name: an author who still writes `database:orders/Order:read`
@@ -2808,7 +2872,13 @@ export const KEYED_GRANT_FAMILIES = ["integration", "secret"];
2808
2872
  * other — `databases:create` is not permission to delete a database.
2809
2873
  *
2810
2874
  * The database ROLE mutations are here because they hand out persistent
2811
- * authority: a group grant assigns the manager role (D3279-003). App deletion
2875
+ * authority: a group grant assigns the manager role (D3279-003). A db3's sync
2876
+ * switch (`db3:setSync`, the intent's `db3-sync` grant) is here because
2877
+ * turning sync off suspends every grant on the db3 (#4799); a db3's transfer
2878
+ * and its owner-row change (`db3:transfer`, `db3:setOwnerRow`, the intent's
2879
+ * `db3-grant` grant) because they move who holds the db3 and its owner row
2880
+ * (#4800); its app access (`db3:setAppAccess`, the same grant's third string)
2881
+ * because it grants the db3 to every user of the app (#4801). App deletion
2812
2882
  * and secret writes have no app-API route today; they are recorded, not gated,
2813
2883
  * and the profile generator refuses to admit a future such route without a row
2814
2884
  * here (`HIGH_BLAST_WATCH` in `scripts/lib/function-profile.mjs`).
@@ -2825,17 +2895,49 @@ export const HIGH_BLAST_CAPABILITIES = [
2825
2895
  "users:setRole",
2826
2896
  "blobBuckets:createBucket",
2827
2897
  "blobBuckets:deleteBucket",
2898
+ "db3:setSync",
2899
+ "db3:transfer",
2900
+ "db3:setOwnerRow",
2901
+ "db3:setAppAccess",
2902
+ ];
2903
+ /**
2904
+ * The subject grants — #4909.
2905
+ *
2906
+ * A run a plain member invoked may name nobody but its caller on a call that
2907
+ * is about one user (#4142's subject rule): `SUBJECT_USER_FORBIDDEN`. A
2908
+ * function whose own code chooses that user — a class's teacher removing a
2909
+ * student and reading where else the student is enrolled — declares it here,
2910
+ * in a line a reviewer can find:
2911
+ *
2912
+ * `users:readAny` the user-subject READS may name another member
2913
+ * (memberships, a member's collections, their db3s
2914
+ * (owned and shared), inbox, devices, agent sessions);
2915
+ * `users:actAsAny` the calls that ACT as a member may name another member
2916
+ * (marking their notifications read, their devices, an
2917
+ * agent session as them, `ctx.db3` `asUser`, their
2918
+ * aliases).
2919
+ *
2920
+ * Each admits only its own kind. Neither changes a run with no caller, an
2921
+ * owner- or admin-invoked run, or a run an agent drives (refused either way),
2922
+ * and a nested child reads its own version's. They are not high-blast rows:
2923
+ * those are 1:1 with an operation id, and these name a rule, not an operation.
2924
+ */
2925
+ export const SUBJECT_GRANT_CAPABILITIES = ["users:readAny", "users:actAsAny"];
2926
+ /** The exact strings: the high-blast list and the subject grants. */
2927
+ export const EXACT_GRANT_STRINGS = [
2928
+ ...HIGH_BLAST_CAPABILITIES,
2929
+ ...SUBJECT_GRANT_CAPABILITIES,
2828
2930
  ];
2829
- /** The exact strings, which since #3279 are exactly the high-blast list. */
2830
- export const EXACT_GRANT_STRINGS = HIGH_BLAST_CAPABILITIES;
2831
2931
  /**
2832
2932
  * What stays, in one sentence, for every retirement to point at. An author
2833
2933
  * who reads a refusal should not need the guide to know what to write next.
2834
2934
  */
2835
2935
  const KEPT_KINDS = "Capabilities are declared only for `integration:<key>` (the egress " +
2836
- "allowlist), `secret:<NAME>` (which secret values may enter the sandbox) " +
2837
- "and the high-blast-radius opt-ins (" +
2936
+ "allowlist), `secret:<NAME>` (which secret values may enter the sandbox), " +
2937
+ "the high-blast-radius opt-ins (" +
2838
2938
  HIGH_BLAST_CAPABILITIES.map((entry) => `\`${entry}\``).join(", ") +
2939
+ ") and the subject grants (" +
2940
+ SUBJECT_GRANT_CAPABILITIES.map((entry) => `\`${entry}\``).join(", ") +
2839
2941
  ").";
2840
2942
  /**
2841
2943
  * The retired FAMILIES (#3279), each with the reason it is gone.
@@ -2903,9 +3005,11 @@ const KEYED_FAMILY_PLACEHOLDERS = {
2903
3005
  secret: "NAME",
2904
3006
  };
2905
3007
  /** Every accepted shape, in one sentence, for the unknown-family error. */
2906
- const ACCEPTED_FAMILIES = "`integration:<integrationKey>`, `secret:<NAME>`, and the high-blast " +
3008
+ const ACCEPTED_FAMILIES = "`integration:<integrationKey>`, `secret:<NAME>`, the high-blast " +
2907
3009
  "opt-ins " +
2908
- HIGH_BLAST_CAPABILITIES.map((entry) => `\`${entry}\``).join(", ");
3010
+ HIGH_BLAST_CAPABILITIES.map((entry) => `\`${entry}\``).join(", ") +
3011
+ ", and the subject grants " +
3012
+ SUBJECT_GRANT_CAPABILITIES.map((entry) => `\`${entry}\``).join(", ");
2909
3013
  /**
2910
3014
  * A channel name's ceiling, and the reason it has one.
2911
3015
  *
@@ -3170,7 +3274,37 @@ export function validateKeyedGrantsAgainstTargets(grants, known) {
3170
3274
  * A version-1 manifest still parses: it records registrations only.
3171
3275
  */
3172
3276
  export const FUNCTION_MANIFEST_SCHEMA_VERSION = 2;
3173
- export const FUNCTION_MANIFEST_SCHEMA_VERSIONS = [1, 2];
3277
+ export const FUNCTION_MANIFEST_SCHEMA_VERSIONS = [1, 2, 3];
3278
+ /**
3279
+ * Version 3 (#4730) adds what a version's `authorize` admits: the
3280
+ * `authorize` block and the `writeFamilies` its handler reaches. Only a
3281
+ * FLAGGED build emits it — the manifest is inside the envelope hash, so a
3282
+ * universal bump would make every untouched bare-handler tree a new version
3283
+ * on its next push. A bare-handler tree keeps emitting version 2.
3284
+ */
3285
+ export const FUNCTION_MANIFEST_AUTHORIZE_SCHEMA_VERSION = 3;
3286
+ /** The `auth.*` families an `authorize` can read, as the manifest names them. */
3287
+ export const AUTH_FAMILIES = [
3288
+ "auth.user",
3289
+ "auth.trigger",
3290
+ "auth.memberships",
3291
+ "auth.collections",
3292
+ "auth.doc",
3293
+ "auth.db",
3294
+ "auth.configVar",
3295
+ ];
3296
+ /** The SDK helpers that build an `authorize`, as the manifest names them. */
3297
+ export const AUTHORIZE_HELPERS = [
3298
+ "allowAnyone",
3299
+ "allowCallers",
3300
+ "requireSignedIn",
3301
+ "requireRole",
3302
+ "requireMember",
3303
+ "requireCollectionRole",
3304
+ "requireDocumentOwner",
3305
+ ];
3306
+ /** How many function keys an `allowCallers` block may list. */
3307
+ export const MAX_MANIFEST_CALLER_FUNCTIONS = 200;
3174
3308
  /** Bounds, so a manifest cannot be a way to store an unbounded blob. */
3175
3309
  export const MAX_MANIFEST_QUERIES = 200;
3176
3310
  export const MAX_MANIFEST_NAME_LENGTH = 120;
@@ -3260,7 +3394,8 @@ export function parseFunctionManifest(value) {
3260
3394
  }
3261
3395
  const schemaVersion = Number(document.schemaVersion);
3262
3396
  if (!FUNCTION_MANIFEST_SCHEMA_VERSIONS.includes(schemaVersion)) {
3263
- return fail(`the manifest declares schemaVersion ${JSON.stringify(document.schemaVersion)}; this platform reads versions ${FUNCTION_MANIFEST_SCHEMA_VERSIONS.join(" and ")}.`);
3397
+ return fail(`the manifest declares schemaVersion ${JSON.stringify(document.schemaVersion)}; this platform reads versions ${FUNCTION_MANIFEST_SCHEMA_VERSIONS.slice(0, -1).join(", ")} ` +
3398
+ `and ${FUNCTION_MANIFEST_SCHEMA_VERSIONS[FUNCTION_MANIFEST_SCHEMA_VERSIONS.length - 1]}.`);
3264
3399
  }
3265
3400
  if (!Array.isArray(document.queries)) {
3266
3401
  return fail("the manifest's `queries` must be an array.");
@@ -3405,21 +3540,246 @@ export function parseFunctionManifest(value) {
3405
3540
  if (schemaVersion >= 2 && document.dynamicModels !== undefined && typeof document.dynamicModels !== "boolean") {
3406
3541
  errors.push("the manifest's `dynamicModels` must be a boolean.");
3407
3542
  }
3543
+ // Version 3's additions. Set ONLY for a version-3 document: the server
3544
+ // re-serializes the parsed object into the envelope it hashes, so a key
3545
+ // added to a version-1 or version-2 object would move every legacy hash.
3546
+ const writeFamilies = schemaVersion >= FUNCTION_MANIFEST_AUTHORIZE_SCHEMA_VERSION
3547
+ ? names("writeFamilies", MAX_MANIFEST_FAMILIES)
3548
+ : null;
3549
+ const authorize = schemaVersion >= FUNCTION_MANIFEST_AUTHORIZE_SCHEMA_VERSION
3550
+ ? parseManifestAuthorize(document.authorize, errors)
3551
+ : null;
3408
3552
  if (errors.length > 0)
3409
3553
  return { ok: false, manifest: null, errors };
3410
3554
  queries.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
3555
+ const manifest = {
3556
+ schemaVersion,
3557
+ queries,
3558
+ models: models ?? [],
3559
+ families: families ?? [],
3560
+ dynamicModels: schemaVersion >= 2 && document.dynamicModels === true,
3561
+ };
3562
+ if (schemaVersion >= FUNCTION_MANIFEST_AUTHORIZE_SCHEMA_VERSION) {
3563
+ manifest.writeFamilies = writeFamilies ?? [];
3564
+ manifest.authorize = authorize;
3565
+ }
3566
+ return { ok: true, manifest, errors: [] };
3567
+ }
3568
+ /** One `authorize` block, normalized in a fixed key order, or null with errors pushed. */
3569
+ function parseManifestAuthorize(raw, errors) {
3570
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
3571
+ errors.push("a version-3 manifest must carry an `authorize` object.");
3572
+ return null;
3573
+ }
3574
+ const before = errors.length;
3575
+ if (raw.present !== true)
3576
+ errors.push("the manifest's `authorize.present` must be true.");
3577
+ if (typeof raw.public !== "boolean") {
3578
+ errors.push("the manifest's `authorize.public` must be a boolean.");
3579
+ }
3580
+ const helper = raw.helper === undefined || raw.helper === null ? null : raw.helper;
3581
+ if (helper !== null && !AUTHORIZE_HELPERS.includes(helper)) {
3582
+ errors.push(`the manifest's \`authorize.helper\` must be null or one of ${AUTHORIZE_HELPERS.join(", ")}.`);
3583
+ }
3584
+ if (!Array.isArray(raw.families) ||
3585
+ raw.families.some((f) => !AUTH_FAMILIES.includes(f))) {
3586
+ errors.push(`the manifest's \`authorize.families\` must be an array of ${AUTH_FAMILIES.join(", ")}.`);
3587
+ }
3588
+ let callers = null;
3589
+ if (raw.callers !== undefined && raw.callers !== null) {
3590
+ callers = parseManifestCallers(raw.callers, errors);
3591
+ }
3592
+ if (errors.length > before)
3593
+ return null;
3411
3594
  return {
3412
- ok: true,
3413
- manifest: {
3414
- schemaVersion,
3415
- queries,
3416
- models: models ?? [],
3417
- families: families ?? [],
3418
- dynamicModels: schemaVersion >= 2 && document.dynamicModels === true,
3419
- },
3420
- errors: [],
3595
+ present: true,
3596
+ public: raw.public,
3597
+ helper,
3598
+ callers,
3599
+ families: [...new Set(raw.families.map(String))].sort(),
3600
+ };
3601
+ }
3602
+ function parseManifestCallers(raw, errors) {
3603
+ if (typeof raw !== "object" || Array.isArray(raw)) {
3604
+ errors.push("the manifest's `authorize.callers` must be null or an object.");
3605
+ return null;
3606
+ }
3607
+ const before = errors.length;
3608
+ for (const door of ["webhook", "cron", "manual"]) {
3609
+ if (typeof raw[door] !== "boolean") {
3610
+ errors.push(`the manifest's \`authorize.callers.${door}\` must be a boolean.`);
3611
+ }
3612
+ }
3613
+ const functions = raw.functions;
3614
+ if (!Array.isArray(functions) || functions.some((k) => typeof k !== "string")) {
3615
+ errors.push("the manifest's `authorize.callers.functions` must be an array of function keys.");
3616
+ }
3617
+ else if (functions.length > MAX_MANIFEST_CALLER_FUNCTIONS) {
3618
+ errors.push(`the manifest's \`authorize.callers.functions\` lists ${functions.length} keys, over the ` +
3619
+ `${MAX_MANIFEST_CALLER_FUNCTIONS} limit.`);
3620
+ }
3621
+ else if (functions.some((k) => k === "" || k.length > MAX_MANIFEST_NAME_LENGTH)) {
3622
+ errors.push("the manifest's `authorize.callers.functions` carries a key that is empty or over " +
3623
+ `${MAX_MANIFEST_NAME_LENGTH} characters.`);
3624
+ }
3625
+ if (raw.agents !== true && raw.agents !== false && raw.agents !== "rule") {
3626
+ errors.push('the manifest\'s `authorize.callers.agents` must be true, false or "rule".');
3627
+ }
3628
+ if (raw.users !== false && raw.users !== "rule") {
3629
+ errors.push('the manifest\'s `authorize.callers.users` must be false or "rule".');
3630
+ }
3631
+ if (raw.db3 !== undefined && typeof raw.db3 !== "boolean") {
3632
+ errors.push("the manifest's `authorize.callers.db3` must be a boolean when present.");
3633
+ }
3634
+ const usersBatch = raw.usersBatch;
3635
+ if (usersBatch !== undefined && typeof usersBatch !== "boolean") {
3636
+ if (!Array.isArray(usersBatch) || usersBatch.some((k) => typeof k !== "string")) {
3637
+ errors.push("the manifest's `authorize.callers.usersBatch` must be a boolean or an array of function keys when present.");
3638
+ }
3639
+ else if (usersBatch.length > MAX_MANIFEST_CALLER_FUNCTIONS) {
3640
+ errors.push(`the manifest's \`authorize.callers.usersBatch\` lists ${usersBatch.length} keys, over the ` +
3641
+ `${MAX_MANIFEST_CALLER_FUNCTIONS} limit.`);
3642
+ }
3643
+ else if (usersBatch.some((k) => k === "" || k.length > MAX_MANIFEST_NAME_LENGTH)) {
3644
+ errors.push("the manifest's `authorize.callers.usersBatch` carries a key that is empty or over " +
3645
+ `${MAX_MANIFEST_NAME_LENGTH} characters.`);
3646
+ }
3647
+ }
3648
+ if (errors.length > before)
3649
+ return null;
3650
+ return {
3651
+ webhook: raw.webhook,
3652
+ cron: raw.cron,
3653
+ manual: raw.manual,
3654
+ functions: [...new Set(functions)].sort(),
3655
+ agents: raw.agents,
3656
+ users: raw.users,
3657
+ ...(raw.db3 !== undefined ? { db3: raw.db3 } : {}),
3658
+ ...(usersBatch !== undefined
3659
+ ? { usersBatch: Array.isArray(usersBatch) ? [...new Set(usersBatch)].sort() : usersBatch }
3660
+ : {}),
3661
+ };
3662
+ }
3663
+ /**
3664
+ * Whether a top-level input schema is one the closed-schema default leaves
3665
+ * OPEN under its union exemption — #4730, criterion 9.
3666
+ *
3667
+ * The validator closes an object against the root's OWN `properties` only,
3668
+ * so a root whose `anyOf` or `oneOf` members declare `properties` of their
3669
+ * own would, closed, refuse the very keys its members declare. Such a root is
3670
+ * left open, and `config push` warns its author to say `additionalProperties`
3671
+ * explicitly. Shared by the server (`closedInputSchemaFor`) and the CLI's
3672
+ * push warning, so both sides read one rule.
3673
+ */
3674
+ export function inputSchemaRootLeftOpen(schema) {
3675
+ if (!isClosableObjectSchema(schema))
3676
+ return false;
3677
+ const root = schema;
3678
+ for (const key of ["anyOf", "oneOf"]) {
3679
+ const members = root[key];
3680
+ if (!Array.isArray(members))
3681
+ continue;
3682
+ for (const member of members) {
3683
+ if (member && typeof member === "object" && !Array.isArray(member)) {
3684
+ const properties = member.properties;
3685
+ if (properties && typeof properties === "object")
3686
+ return true;
3687
+ }
3688
+ }
3689
+ }
3690
+ return false;
3691
+ }
3692
+ /**
3693
+ * A top-level object schema that sets no `additionalProperties`: `type` is or
3694
+ * includes `"object"`, or it declares `properties` with no `type`.
3695
+ */
3696
+ function isClosableObjectSchema(schema) {
3697
+ if (!schema || typeof schema !== "object" || Array.isArray(schema))
3698
+ return false;
3699
+ const root = schema;
3700
+ if (root.additionalProperties !== undefined)
3701
+ return false;
3702
+ const type = root.type;
3703
+ if (type === "object")
3704
+ return true;
3705
+ if (Array.isArray(type))
3706
+ return type.includes("object");
3707
+ return type === undefined && !!root.properties && typeof root.properties === "object";
3708
+ }
3709
+ /**
3710
+ * The schema a flagged version validates against — #4730, criterion 9.
3711
+ *
3712
+ * A top-level object schema that sets no `additionalProperties` reads as
3713
+ * closed: a shallow copy with `additionalProperties: false`. Every other
3714
+ * schema is answered as it is — an explicit `additionalProperties`, a
3715
+ * non-object root, an empty `{}`, and a root left open under
3716
+ * {@link inputSchemaRootLeftOpen}. Nested objects are not touched. Applied at
3717
+ * run time and never written to the header.
3718
+ */
3719
+ export function closedObjectSchema(schema) {
3720
+ if (!isClosableObjectSchema(schema) || inputSchemaRootLeftOpen(schema))
3721
+ return schema;
3722
+ return { ...schema, additionalProperties: false };
3723
+ }
3724
+ /**
3725
+ * `[function] public`, read from the authored TOML's `[function]` table —
3726
+ * #4730, criterion 13. Absent reads as false; anything but a boolean is
3727
+ * refused. Read by the CLI's preflight and by the server from the envelope's
3728
+ * TOML, never stored.
3729
+ */
3730
+ export function declaredPublicOf(functionTable) {
3731
+ const value = functionTable && typeof functionTable === "object"
3732
+ ? functionTable.public
3733
+ : undefined;
3734
+ if (value === undefined)
3735
+ return { ok: true, value: false };
3736
+ if (typeof value === "boolean")
3737
+ return { ok: true, value };
3738
+ return {
3739
+ ok: false,
3740
+ error: "`public` under [function] must be true or false.",
3421
3741
  };
3422
3742
  }
3743
+ /**
3744
+ * What makes a version write-capable for the public-writer lint — #4730: a
3745
+ * mutation registration, a family the manifest records a write or send verb
3746
+ * on, or a declared `integration:<key>`, high-blast or subject-grant
3747
+ * capability (#4909: a function anyone may invoke that names any member is
3748
+ * the same hazard). One phrase per reason, for the refusal to quote.
3749
+ */
3750
+ export function writeCapableReasons(manifest, capabilities) {
3751
+ const reasons = [];
3752
+ const mutations = (manifest?.queries ?? []).filter((q) => q.kind === "mutation").map((q) => q.name);
3753
+ if (mutations.length > 0) {
3754
+ reasons.push(`it registers the mutation${mutations.length > 1 ? "s" : ""} ${mutations.map((n) => `'${n}'`).join(", ")}`);
3755
+ }
3756
+ const writes = manifest?.writeFamilies ?? [];
3757
+ if (writes.length > 0)
3758
+ reasons.push(`it writes or sends through ${writes.join(", ")}`);
3759
+ const exact = [...HIGH_BLAST_CAPABILITIES, ...SUBJECT_GRANT_CAPABILITIES];
3760
+ const declared = capabilities.filter((c) => c.startsWith("integration:") || exact.includes(c));
3761
+ if (declared.length > 0)
3762
+ reasons.push(`it declares ${declared.join(", ")}`);
3763
+ return reasons;
3764
+ }
3765
+ /**
3766
+ * The public-writer refusal — #4730, criterion 13: a version whose manifest
3767
+ * records `authorize.public` (an `allowAnyone()`, or an `allowCallers` arm
3768
+ * that is one) and that is write-capable needs `public = true` under
3769
+ * `[function]`. The sentence names the function, what makes it write-capable
3770
+ * and the fix; null when the push is fine. The CLI refuses at preflight and
3771
+ * the server at push, from this one rule.
3772
+ */
3773
+ export function publicWriterRefusal(input) {
3774
+ if (input.declaredPublic || input.manifest?.authorize?.public !== true)
3775
+ return null;
3776
+ const reasons = writeCapableReasons(input.manifest, input.capabilities);
3777
+ if (reasons.length === 0)
3778
+ return null;
3779
+ return (`function '${input.functionKey}': its authorize admits anyone, and the version can write: ` +
3780
+ `${reasons.join("; ")}. If anyone may really call it, add \`public = true\` under [function] in ` +
3781
+ `functions/${input.functionKey}.toml; otherwise require a caller, such as requireSignedIn() or allowCallers({ ... }).`);
3782
+ }
3423
3783
  // ── src/config-surface/function-retired-keys.ts ──────────────────────────
3424
3784
  /**
3425
3785
  * The runtime keys a `functions/<key>.toml` no longer decides anything with —
@@ -3594,6 +3954,77 @@ function retiredDatabaseTriggerValue(functionTable) {
3594
3954
  }
3595
3955
  return triggers.database;
3596
3956
  }
3957
+ // ── src/config-surface/trigger-declaration.ts ────────────────────────────
3958
+ /**
3959
+ * The trigger blocks a function declares, derived from its authored TOML
3960
+ * (#3181, project `server-functions`, criterion 4).
3961
+ *
3962
+ * ── The declaration is derived, never supplied ────────────────────────────
3963
+ *
3964
+ * A config-version push carries the authored `functions/<key>.toml` bytes
3965
+ * inside its envelope, and `envelopeHash` covers them. If the push ALSO
3966
+ * carried a parsed `triggers` payload, the two could disagree: a direct API
3967
+ * caller could ship a public webhook trigger the authored file does not
3968
+ * declare, and two pushes with identical envelopes but different trigger
3969
+ * payloads would collapse to one version. So the server parses the envelope's
3970
+ * own bytes here (D3181-005) and there is no payload field to disagree with —
3971
+ * trigger behavior is bound to the version's identity by construction.
3972
+ *
3973
+ * ── Shape only ────────────────────────────────────────────────────────────
3974
+ *
3975
+ * This module decides what the file SAYS: the accepted key set, the required
3976
+ * values, and the rules that need nothing but the document (scheme `none`,
3977
+ * a nameless or duplicated cron entry, an entry count past the per-function
3978
+ * cap, a webhook or database block on a task version). Everything that needs the
3979
+ * app's state — whether a referenced secret exists, whether the
3980
+ * scheme-specific config is valid, whether the app is at its webhook or cron
3981
+ * cap, whether a standalone webhook holds the key — belongs to the push
3982
+ * boundary, which runs the SAME validators the standalone create runs
3983
+ * (D3181-006).
3984
+ *
3985
+ * ── One implementation, two readers (#3320) ───────────────────────────────
3986
+ *
3987
+ * The CLI checks the same rules against the author's own file before a request
3988
+ * is made. It used to do that from a hand-written restatement
3989
+ * (`cli/src/lib/function-triggers.ts`), kept in step only by a paired-fixture
3990
+ * test — so a rule added here with no fixture drifted silently. The rules
3991
+ * therefore live in `src/config-surface/`, which `cli/scripts/
3992
+ * gen-config-surfaces.mjs` vendors verbatim into the committed artifact
3993
+ * `cli/src/lib/generated-config-surfaces.ts`. There is one implementation, and
3994
+ * a change here that is not regenerated fails `--check` (a build failure)
3995
+ * rather than a fixture list that happens not to cover it.
3996
+ *
3997
+ * Reading the authored BYTES is the one thing that stayed server-side:
3998
+ * `deriveTriggerDeclaration` in `src/server-functions/trigger-declaration.ts`
3999
+ * parses them and calls `normalizeTriggerDeclaration` here. This directory
4000
+ * imports nothing but itself (asserted by `config-surface-drift-guard.test.ts`),
4001
+ * and the CLI has already parsed its own file by the time it asks.
4002
+ */
4003
+ /**
4004
+ * Why a webhook trigger is the request runtime, and a cron fire a task run —
4005
+ * #3482, the intent's "Mode vocabulary?" decision of 2026-09-15.
4006
+ *
4007
+ * Neither is a rule about the FUNCTION any more, so neither is a refusal: a
4008
+ * function is a function, and the DOOR decides which runtime runs it. A
4009
+ * webhook delivery runs inside the receiver because the provider is holding
4010
+ * the connection open waiting for an answer; a cron fire starts a task run
4011
+ * because it is waiting for nothing. A function that must not run under one of
4012
+ * them tests for it in code with `assertRuntime`, which is the only lock left.
4013
+ *
4014
+ * What survives here is the SHAPE of a declaration — the keys, the names, the
4015
+ * cron expression, the caps. The retired `mode` keys are accepted and reported
4016
+ * as ignored by `ignoredFunctionKeys` in `function-retired-keys.ts`.
4017
+ */
4018
+ /** A function's single webhook trigger, normalized. */
4019
+ /**
4020
+ * The db3 type-name prefix the platform reserves for its own types (#4882,
4021
+ * project `agent-sessions-db3`): no app pushes, attaches or watches a type
4022
+ * whose name starts with it.
4023
+ */
4024
+ export const RESERVED_DB3_TYPE_PREFIX = "primitive:";
4025
+ /** The most handshake rules and allowlist entries one webhook block may carry. */
4026
+ export const MAX_WEBHOOK_HANDSHAKE_RULES = 10;
4027
+ export const MAX_WEBHOOK_IP_CIDRS = 50;
3597
4028
  export const EMPTY_TRIGGER_DECLARATION = {
3598
4029
  webhook: null,
3599
4030
  cron: [],
@@ -3608,10 +4039,16 @@ export const EMPTY_TRIGGER_DECLARATION = {
3608
4039
  */
3609
4040
  export const MAX_CRON_TRIGGERS_PER_FUNCTION = 10;
3610
4041
  /**
3611
- * Cron entry names follow the STANDALONE `triggerKey` charset, minus its
3612
- * ability to hold a `:` — the standalone create already rejects `:`, which is
3613
- * exactly what makes `<functionKey>:<name>` a key no standalone row can ever
3614
- * collide with (the intent, "Key namespace?").
4042
+ * The most db3 types one function may watch — the cron cap's per-object
4043
+ * reasoning (#4803). The per-app ceiling is `MAX_DB3_TRIGGERS_PER_APP`, checked
4044
+ * at the push boundary.
4045
+ */
4046
+ export const MAX_DB3_TRIGGERS_PER_FUNCTION = 10;
4047
+ const DB3_KEYS = new Set(["type"]);
4048
+ /**
4049
+ * Cron entry names follow the charset the retired standalone `triggerKey` had
4050
+ * (#3190), minus its ability to hold a `:` — which is exactly what keeps
4051
+ * `<functionKey>:<name>` unambiguous (the intent, "Key namespace?").
3615
4052
  */
3616
4053
  const CRON_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_-]*$/;
3617
4054
  const WEBHOOK_KEYS = new Set([
@@ -3623,6 +4060,8 @@ const WEBHOOK_KEYS = new Set([
3623
4060
  "maxBodyBytes",
3624
4061
  "secretGracePeriodMs",
3625
4062
  "verification",
4063
+ "handshakeRules",
4064
+ "allowedIpCidrs",
3626
4065
  ]);
3627
4066
  const CRON_KEYS = new Set([
3628
4067
  "name",
@@ -3659,6 +4098,8 @@ export const TRIGGER_RULE_IDS = [
3659
4098
  "webhook-trigger-number",
3660
4099
  "webhook-trigger-dedup-boolean",
3661
4100
  "webhook-trigger-verification-table",
4101
+ "webhook-trigger-handshake-rules",
4102
+ "webhook-trigger-ip-allowlist",
3662
4103
  "cron-trigger-cap",
3663
4104
  "cron-trigger-entry",
3664
4105
  "cron-trigger-keys",
@@ -3667,6 +4108,14 @@ export const TRIGGER_RULE_IDS = [
3667
4108
  "cron-trigger-duplicate",
3668
4109
  "cron-trigger-expression-required",
3669
4110
  "cron-trigger-overlap-policy",
4111
+ // #4803 — `[[function.triggers.db3]]`, the db3 change trigger.
4112
+ "db3-trigger-cap",
4113
+ "db3-trigger-entry",
4114
+ "db3-trigger-keys",
4115
+ "db3-trigger-type-required",
4116
+ // #4882 — a `primitive:` type is the platform's.
4117
+ "db3-trigger-type-reserved",
4118
+ "db3-trigger-duplicate",
3670
4119
  ];
3671
4120
  /**
3672
4121
  * A broken trigger rule. `ruleId` names which one, for a reader that wants to
@@ -3687,7 +4136,9 @@ function refuseTrigger(ruleId, message) {
3687
4136
  }
3688
4137
  /** Is anything at all declared? Used to skip work on the common case. */
3689
4138
  export function hasDeclaredTriggers(declaration) {
3690
- return declaration.webhook !== null || declaration.cron.length > 0;
4139
+ return (declaration.webhook !== null ||
4140
+ declaration.cron.length > 0 ||
4141
+ (declaration.db3?.length ?? 0) > 0);
3691
4142
  }
3692
4143
  /**
3693
4144
  * Normalize the `triggers` table of an already-parsed `[function]` table.
@@ -3704,7 +4155,7 @@ export function normalizeTriggerDeclaration(functionTable) {
3704
4155
  return EMPTY_TRIGGER_DECLARATION;
3705
4156
  }
3706
4157
  if (typeof triggers !== "object" || Array.isArray(triggers)) {
3707
- refuseTrigger("triggers-table", "[function.triggers] must be a table declaring `webhook` and/or `cron`");
4158
+ refuseTrigger("triggers-table", "[function.triggers] must be a table declaring `webhook`, `cron` and/or `db3`");
3708
4159
  }
3709
4160
  // #3483 — checked BEFORE the unknown-kind rule, so an author who declares
3710
4161
  // the block hears why it went rather than that `database` is not a word the
@@ -3715,14 +4166,15 @@ export function normalizeTriggerDeclaration(functionTable) {
3715
4166
  refuseTrigger("database-trigger-removed", DATABASE_TRIGGER_REMOVED);
3716
4167
  }
3717
4168
  for (const key of Object.keys(triggers)) {
3718
- if (key !== "webhook" && key !== "cron") {
4169
+ if (key !== "webhook" && key !== "cron" && key !== "db3") {
3719
4170
  refuseTrigger("trigger-kind", `unknown trigger kind '${key}' under [function.triggers]: the kinds are ` +
3720
- "`webhook` and `cron`");
4171
+ "`webhook`, `cron` and `db3`");
3721
4172
  }
3722
4173
  }
3723
4174
  const webhook = normalizeWebhook(triggers.webhook);
3724
4175
  const cron = normalizeCron(triggers.cron);
3725
- return { webhook, cron };
4176
+ const db3 = normalizeDb3(triggers.db3);
4177
+ return db3.length > 0 ? { webhook, cron, db3 } : { webhook, cron };
3726
4178
  }
3727
4179
  /**
3728
4180
  * The sentence an author who declared the block is owed — D3483-001.
@@ -3799,8 +4251,110 @@ function normalizeWebhook(raw) {
3799
4251
  }
3800
4252
  declaration.verification = jsonSafe(verification);
3801
4253
  }
4254
+ if (table.handshakeRules !== undefined) {
4255
+ declaration.handshakeRules = normalizeHandshakeRules(table.handshakeRules);
4256
+ }
4257
+ if (table.allowedIpCidrs !== undefined) {
4258
+ declaration.allowedIpCidrs = normalizeIpAllowlist(table.allowedIpCidrs);
4259
+ }
3802
4260
  return declaration;
3803
4261
  }
4262
+ const HANDSHAKE_RESPONSE_KEYS = new Set(["status", "contentType", "body"]);
4263
+ /**
4264
+ * `[[function.triggers.webhook.handshakeRules]]` — the shape the receiver's
4265
+ * `parseHandshakeRules` reads: a non-empty CEL `when` and a `response` table of
4266
+ * an integer `status`, a `contentType` and a `body` template. The receiver
4267
+ * skips a malformed rule silently, so a typo here would be a handshake that
4268
+ * never answers; the push refuses it instead.
4269
+ */
4270
+ function normalizeHandshakeRules(raw) {
4271
+ const refuse = (detail) => refuseTrigger("webhook-trigger-handshake-rules", `[[function.triggers.webhook.handshakeRules]] ${detail}`);
4272
+ if (!Array.isArray(raw))
4273
+ refuse("must be an array of tables");
4274
+ const entries = raw;
4275
+ if (entries.length > MAX_WEBHOOK_HANDSHAKE_RULES) {
4276
+ refuse(`may declare at most ${MAX_WEBHOOK_HANDSHAKE_RULES} rules`);
4277
+ }
4278
+ return entries.map((entry, index) => {
4279
+ const at = `entry ${index + 1}`;
4280
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
4281
+ refuse(`${at} must be a table with \`when\` and \`response\``);
4282
+ }
4283
+ const rule = entry;
4284
+ for (const key of Object.keys(rule)) {
4285
+ if (key !== "when" && key !== "response") {
4286
+ refuse(`${at}: unknown key '${key}' (accepted keys are when, response)`);
4287
+ }
4288
+ }
4289
+ if (typeof rule.when !== "string" || !rule.when.trim()) {
4290
+ refuse(`${at}: \`when\` must be a non-empty CEL expression`);
4291
+ }
4292
+ const response = rule.response;
4293
+ if (!response || typeof response !== "object" || Array.isArray(response)) {
4294
+ refuse(`${at}: \`response\` must be a table`);
4295
+ }
4296
+ const fields = response;
4297
+ for (const key of Object.keys(fields)) {
4298
+ if (!HANDSHAKE_RESPONSE_KEYS.has(key)) {
4299
+ refuse(`${at}: unknown response key '${key}' (accepted keys are ` +
4300
+ `${[...HANDSHAKE_RESPONSE_KEYS].join(", ")})`);
4301
+ }
4302
+ }
4303
+ const out = {
4304
+ when: String(rule.when),
4305
+ response: {},
4306
+ };
4307
+ if (fields.status !== undefined) {
4308
+ const status = fields.status;
4309
+ if (typeof status !== "number" ||
4310
+ !Number.isInteger(status) ||
4311
+ status < 200 ||
4312
+ status > 599) {
4313
+ refuse(`${at}: response \`status\` must be an integer HTTP status (200-599)`);
4314
+ }
4315
+ out.response.status = status;
4316
+ }
4317
+ for (const key of ["contentType", "body"]) {
4318
+ if (fields[key] === undefined)
4319
+ continue;
4320
+ if (typeof fields[key] !== "string") {
4321
+ refuse(`${at}: response \`${key}\` must be a string`);
4322
+ }
4323
+ out.response[key] = fields[key];
4324
+ }
4325
+ return out;
4326
+ });
4327
+ }
4328
+ /** An IPv4 address, optionally with a prefix length — what the receiver matches. */
4329
+ const IPV4_CIDR = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})(?:\/(\d{1,2}))?$/;
4330
+ /**
4331
+ * `allowedIpCidrs = ["203.0.113.0/24", "198.51.100.7"]` — the sender addresses
4332
+ * the receiver accepts a delivery from, checked before verification. The
4333
+ * receiver matches IPv4 addresses and prefixes, so that is what the push
4334
+ * accepts; an entry it could never match would refuse every delivery.
4335
+ */
4336
+ function normalizeIpAllowlist(raw) {
4337
+ const refuse = (detail) => refuseTrigger("webhook-trigger-ip-allowlist", `[function.triggers.webhook] allowedIpCidrs ${detail}`);
4338
+ if (!Array.isArray(raw))
4339
+ refuse("must be an array of IPv4 addresses or CIDR prefixes");
4340
+ const entries = raw;
4341
+ if (entries.length === 0)
4342
+ refuse("must name at least one address (omit the key to accept any)");
4343
+ if (entries.length > MAX_WEBHOOK_IP_CIDRS) {
4344
+ refuse(`may list at most ${MAX_WEBHOOK_IP_CIDRS} entries`);
4345
+ }
4346
+ return entries.map((entry) => {
4347
+ const value = typeof entry === "string" ? entry.trim() : "";
4348
+ const match = IPV4_CIDR.exec(value);
4349
+ const valid = match !== null &&
4350
+ match.slice(1, 5).every((octet) => Number(octet) <= 255) &&
4351
+ (match[5] === undefined || Number(match[5]) <= 32);
4352
+ if (!valid) {
4353
+ refuse(`entry '${String(entry)}' is not an IPv4 address or CIDR prefix (e.g. 203.0.113.0/24)`);
4354
+ }
4355
+ return value;
4356
+ });
4357
+ }
3804
4358
  function normalizeCron(raw) {
3805
4359
  if (raw === undefined || raw === null)
3806
4360
  return [];
@@ -3868,6 +4422,60 @@ function normalizeCron(raw) {
3868
4422
  normalized.sort((a, b) => a.name.localeCompare(b.name));
3869
4423
  return normalized;
3870
4424
  }
4425
+ /**
4426
+ * `[[function.triggers.db3]]` — the db3 types whose flushes start this
4427
+ * function (#4803). The cron block's shape: an array of tables (the
4428
+ * single-table spelling is one entry), at most ten, each type once, sorted so
4429
+ * the stored declaration is canonical.
4430
+ *
4431
+ * The type is not checked against the app's types here or at push (sponsor,
4432
+ * 2026-10-26): `config push` applies `functions/` before `db3-types/`, so a
4433
+ * same-run push of a type and its watcher would otherwise refuse itself, and a
4434
+ * watcher of a type no db3 holds simply never fires.
4435
+ */
4436
+ function normalizeDb3(raw) {
4437
+ if (raw === undefined || raw === null)
4438
+ return [];
4439
+ const entries = Array.isArray(raw) ? raw : [raw];
4440
+ if (entries.length === 0)
4441
+ return [];
4442
+ if (entries.length > MAX_DB3_TRIGGERS_PER_FUNCTION) {
4443
+ refuseTrigger("db3-trigger-cap", `a function may declare at most ${MAX_DB3_TRIGGERS_PER_FUNCTION} ` +
4444
+ `[[function.triggers.db3]] entries, and this one declares ${entries.length}`);
4445
+ }
4446
+ const seen = new Set();
4447
+ const normalized = [];
4448
+ for (const entry of entries) {
4449
+ if (entry === null || typeof entry !== "object" || Array.isArray(entry)) {
4450
+ refuseTrigger("db3-trigger-entry", "each [[function.triggers.db3]] entry must be a table: " +
4451
+ '[[function.triggers.db3]] type = "<db3 type>"');
4452
+ }
4453
+ const table = entry;
4454
+ for (const key of Object.keys(table)) {
4455
+ if (!DB3_KEYS.has(key)) {
4456
+ refuseTrigger("db3-trigger-keys", `unknown key '${key}' in a [[function.triggers.db3]] entry: the only ` +
4457
+ "key is `type`");
4458
+ }
4459
+ }
4460
+ const type = typeof table.type === "string" ? table.type.trim() : "";
4461
+ if (!type || type.includes("#")) {
4462
+ refuseTrigger("db3-trigger-type-required", "each [[function.triggers.db3]] entry needs a `type`: the name of the " +
4463
+ "db3 type it watches, a non-empty string without '#'");
4464
+ }
4465
+ if (type.startsWith(RESERVED_DB3_TYPE_PREFIX)) {
4466
+ refuseTrigger("db3-trigger-type-reserved", `[[function.triggers.db3]] type '${type}' is reserved: a type whose name starts ` +
4467
+ `'${RESERVED_DB3_TYPE_PREFIX}' is the platform's, and no app function watches it`);
4468
+ }
4469
+ if (seen.has(type)) {
4470
+ refuseTrigger("db3-trigger-duplicate", `duplicate [[function.triggers.db3]] type '${type}': a function watches ` +
4471
+ "each type once");
4472
+ }
4473
+ seen.add(type);
4474
+ normalized.push({ type });
4475
+ }
4476
+ normalized.sort((a, b) => (a.type < b.type ? -1 : a.type > b.type ? 1 : 0));
4477
+ return normalized;
4478
+ }
3871
4479
  /**
3872
4480
  * TOML values that JSON cannot carry (dates, and the bigints `smol-toml`
3873
4481
  * produces for large integers) become their string / number form, so the
@@ -3910,9 +4518,11 @@ export function parseStoredTriggerDeclaration(stored) {
3910
4518
  }
3911
4519
  try {
3912
4520
  const parsed = JSON.parse(stored);
4521
+ const db3 = Array.isArray(parsed?.db3) && parsed.db3.length > 0 ? parsed.db3 : null;
3913
4522
  return {
3914
4523
  webhook: parsed?.webhook ?? null,
3915
4524
  cron: Array.isArray(parsed?.cron) ? parsed.cron : [],
4525
+ ...(db3 ? { db3 } : {}),
3916
4526
  // #3483 — a stored `databases` key is DROPPED, not read. A version
3917
4527
  // pushed before the refusal existed still carries one in its immutable
3918
4528
  // JSON, and the row is never rewritten; answering nothing at all is what
@@ -3957,6 +4567,23 @@ export function cronTriggerNameFrom(functionKey, triggerKey) {
3957
4567
  ? triggerKey.slice(prefix.length)
3958
4568
  : triggerKey;
3959
4569
  }
4570
+ /**
4571
+ * The `ServerFunctionTrigger.triggerKey` a db3 entry owns (#4803):
4572
+ * `<functionKey>:db3:<type>`. A cron name cannot hold `:`, so the key never
4573
+ * collides with a cron entry's `<functionKey>:<name>`.
4574
+ */
4575
+ export function db3TriggerKeyFor(functionKey, type) {
4576
+ return `${functionKey}:db3:${type}`;
4577
+ }
4578
+ /**
4579
+ * The type a db3 trigger key carries, or null when the key is not this
4580
+ * function's db3 key. Read by stripping the prefix, never by splitting: a type
4581
+ * name may hold `:` and `/`.
4582
+ */
4583
+ export function db3TriggerTypeFrom(functionKey, triggerKey) {
4584
+ const prefix = `${functionKey}:db3:`;
4585
+ return triggerKey.startsWith(prefix) ? triggerKey.slice(prefix.length) : null;
4586
+ }
3960
4587
  // ── src/config-surface/secret-reference.ts ───────────────────────────────
3961
4588
  /**
3962
4589
  * The `{{secrets.KEY}}` reference SHAPE, decided from the value alone.
@@ -4265,588 +4892,80 @@ export function validateSigningSecretDeclaration(input) {
4265
4892
  }
4266
4893
  return null;
4267
4894
  }
4268
- // ── src/config-surface/workflow-rules.ts ─────────────────────────────────
4269
- /**
4270
- * The workflow rules two runners share (#3374, project `cli-server-rule-parity`
4271
- * phase 2; intent §Success criteria 3).
4272
- *
4273
- * ── One predicate, two messages ──────────────────────────────────────────
4274
- *
4275
- * `runAs = "system"` beside a non-empty `accessRule` is dead config: a system
4276
- * run can only be started by the system and never evaluates its access rule
4277
- * (#1258, broadening #1172). The server refused it at save time
4278
- * (`validateWorkflowIdentityConfig`) and the CLI refused it in the push
4279
- * preflight (`validateWorkflowIdentity`), and the two carried the conjunction
4280
- * byte-for-byte as separate copies kept in step by a comment. This module is
4281
- * the one copy: it decides, and returns a STRUCTURED violation — the rule id
4282
- * and the server's sentence — that each site renders in its own words. The
4283
- * server pushes the sentence into its `string[]`; the CLI keeps its own hint,
4284
- * which names the preflight remedy. Neither message changed.
4285
- *
4286
- * ── Why a `*-rules.ts` module ────────────────────────────────────────────
4287
- *
4288
- * The registry's unclaimed-export check (`findUnclaimedRuleModuleExports`)
4289
- * keys on this name under `src/config-surface/`: every exported function here
4290
- * is a rule, so one no surface declares fails `cli-unit-tests`. Shared
4291
- * predicates that are not rules live elsewhere (`webhook-signing-secret.ts`).
4292
- * The module is vendored into the CLI artifact like the rest of the
4293
- * directory, which is what lets `workflow`'s declaration call the rule
4294
- * `preflight`.
4295
- */
4296
- /** The rule ids this module owns — the union type below anchors them (#3373). */
4297
- export const WORKFLOW_RULE_IDS = [
4298
- "system-access-rule",
4299
- "retired-database-step-kind",
4895
+ const FIELD_RANGES = [
4896
+ { name: "minute", min: 0, max: 59 },
4897
+ { name: "hour", min: 0, max: 23 },
4898
+ { name: "day-of-month", min: 1, max: 31 },
4899
+ { name: "month", min: 1, max: 12 },
4900
+ { name: "day-of-week", min: 0, max: 6 },
4300
4901
  ];
4301
- /** The one refusal constructor: a new branch cannot compile without an id. */
4302
- function refuseWorkflowRule(ruleId, message) {
4303
- return { ruleId, message };
4304
- }
4305
- /**
4306
- * `runAs = "system"` with a non-empty string `accessRule`, or null.
4307
- *
4308
- * Exactly the conjunction both sites carried: a default, unset, empty or
4309
- * whitespace-only rule is no rule, and a non-string one (`accessRule = false`)
4310
- * is malformed input for another check to name, not dead config. The message
4311
- * is the server's save-time sentence; the CLI renders its own hint from the
4312
- * same answer.
4313
- */
4314
- export function checkWorkflowSystemAccessRule(input) {
4315
- const { runAs, accessRule } = input;
4316
- if (runAs === "system" &&
4317
- typeof accessRule === "string" &&
4318
- accessRule.trim() !== "") {
4319
- return refuseWorkflowRule("system-access-rule", 'runAs:"system" workflows do not evaluate accessRule — remove the accessRule');
4902
+ function parseField(field, min, max, fieldName) {
4903
+ const result = new Set();
4904
+ const parts = field.split(",");
4905
+ for (const partRaw of parts) {
4906
+ const part = partRaw.trim();
4907
+ if (!part) {
4908
+ throw new Error(`Invalid ${fieldName} field: empty segment`);
4909
+ }
4910
+ let step = 1;
4911
+ let rangePart = part;
4912
+ const slashIdx = part.indexOf("/");
4913
+ if (slashIdx !== -1) {
4914
+ rangePart = part.slice(0, slashIdx);
4915
+ const stepStr = part.slice(slashIdx + 1);
4916
+ const stepNum = Number(stepStr);
4917
+ if (!Number.isInteger(stepNum) || stepNum <= 0) {
4918
+ throw new Error(`Invalid ${fieldName} step: "${stepStr}"`);
4919
+ }
4920
+ step = stepNum;
4921
+ }
4922
+ let lo;
4923
+ let hi;
4924
+ if (rangePart === "*") {
4925
+ lo = min;
4926
+ hi = max;
4927
+ }
4928
+ else if (rangePart.includes("-")) {
4929
+ const [loStr, hiStr] = rangePart.split("-");
4930
+ lo = Number(loStr);
4931
+ hi = Number(hiStr);
4932
+ if (!Number.isInteger(lo) || !Number.isInteger(hi)) {
4933
+ throw new Error(`Invalid ${fieldName} range: "${rangePart}"`);
4934
+ }
4935
+ }
4936
+ else {
4937
+ const exact = Number(rangePart);
4938
+ if (!Number.isInteger(exact)) {
4939
+ throw new Error(`Invalid ${fieldName} value: "${rangePart}"`);
4940
+ }
4941
+ lo = exact;
4942
+ hi = exact;
4943
+ }
4944
+ // Normalize day-of-week 7 -> 0 (Sunday). We only do this for bare
4945
+ // values, not inside a range — `5-7` would otherwise become `5-0`
4946
+ // which then fails the `lo > hi` check with a confusing error. Users
4947
+ // who want Fri–Sun should write `5-0,0` or `5,6,0`; we reject 7 in
4948
+ // ranges outright with a clearer message.
4949
+ if (fieldName === "day-of-week") {
4950
+ const isRange = rangePart.includes("-");
4951
+ if (isRange && (lo === 7 || hi === 7)) {
4952
+ throw new Error(`Invalid day-of-week range "${rangePart}": 7 (Sunday) is only allowed as a single value, not inside a range. Use 0 for Sunday in ranges.`);
4953
+ }
4954
+ if (!isRange) {
4955
+ if (lo === 7)
4956
+ lo = 0;
4957
+ if (hi === 7)
4958
+ hi = 0;
4959
+ }
4960
+ }
4961
+ if (lo < min || hi > max || lo > hi) {
4962
+ throw new Error(`Invalid ${fieldName} range: ${lo}-${hi} (allowed ${min}-${max})`);
4963
+ }
4964
+ for (let v = lo; v <= hi; v += step) {
4965
+ result.add(v);
4966
+ }
4320
4967
  }
4321
- return null;
4322
- }
4323
- /**
4324
- * The DSL step kinds that executed a registered database operation (#3189,
4325
- * phase 6 of project `server-functions`, matrix row M8).
4326
- *
4327
- * Every `database.*` runner except `database.syncIndexes` called
4328
- * `DatabaseOperationsController.execute`, so retiring database operations
4329
- * retires these fourteen kinds with them: the seven base kinds and their seven
4330
- * `*ForUser` twins. `database.syncIndexes` (which calls the records index
4331
- * route), `database.create` and `database.delete` (resource lifecycle) are not
4332
- * here and keep running until the engine retires.
4333
- */
4334
- export const RETIRED_DATABASE_STEP_KINDS = [
4335
- "database.query",
4336
- "database.mutate",
4337
- "database.count",
4338
- "database.aggregate",
4339
- "database.pipeline",
4340
- "database.applyToQuery",
4341
- "database.batch",
4342
- "database.queryForUser",
4343
- "database.mutateForUser",
4344
- "database.countForUser",
4345
- "database.aggregateForUser",
4346
- "database.pipelineForUser",
4347
- "database.applyToQueryForUser",
4348
- "database.batchForUser",
4349
- ];
4350
- /**
4351
- * Every step in a definition — or the one step a run has reached — whose kind
4352
- * is a retired database kind, with the sentence naming the replacement.
4353
- *
4354
- * Walks the top-level `steps` and a `collect` step's nested `step`, the one
4355
- * place a step definition nests another. Push (the CLI preflight), save, the
4356
- * activation lint and the engine all ask this one question, so a definition is
4357
- * refused by the same words wherever it is caught, and a run that reaches such
4358
- * a step fails with them.
4359
- */
4360
- export function checkWorkflowRetiredStepKinds(input) {
4361
- const violations = [];
4362
- const visit = (step) => {
4363
- if (!step || typeof step !== "object" || Array.isArray(step))
4364
- return;
4365
- const kind = step.kind;
4366
- const id = step.id;
4367
- if (typeof kind === "string" &&
4368
- RETIRED_DATABASE_STEP_KINDS.includes(kind)) {
4369
- const name = typeof id === "string" && id ? `step "${id}"` : "a step";
4370
- violations.push(refuseWorkflowRule("retired-database-step-kind", `${name} uses ${kind}, which was retired with database operations — ` +
4371
- "move its work into a server function (ctx.db(databaseId).model(name)) " +
4372
- "and call that function from the workflow with a workflow.call step"));
4373
- }
4374
- if (kind === "collect")
4375
- visit(step.step);
4376
- };
4377
- if (Array.isArray(input.steps))
4378
- input.steps.forEach(visit);
4379
- return violations;
4380
- }
4381
- // ── src/config-surface/workflow.ts ───────────────────────────────────────
4382
- /**
4383
- * The `workflow` configuration object's definition (issue #2644, phase 1).
4384
- *
4385
- * One place records the `[workflow]` field surface: which `WorkflowDefinition`
4386
- * fields the server accepts on create/update, which TOML key each carries,
4387
- * whether `config pull` always emits it, and — for every field with real
4388
- * behavior — the handler that owns that behavior. `createAppWorkflow` /
4389
- * `updateAppWorkflow` take their accepted set from here (`pickWritableFields`),
4390
- * the CLI's push builder and pull serializer read the vendored copy, and the
4391
- * coverage guard cross-checks the whole thing against `models.yaml`.
4392
- *
4393
- * Supersedes `cli/src/lib/workflow-field-descriptor.ts` (#2326) and
4394
- * `WORKFLOW_PAYLOAD_FIELDS_CREATE` / `_UPDATE`
4395
- * (`cli/src/lib/workflow-payload.ts`, #1177), both deleted with this change.
4396
- */
4397
- const HANDLERS = "src/workflows/config/workflow-field-handlers.ts";
4398
- const handler = (name) => handledBy(HANDLERS, name, "apply");
4399
- /**
4400
- * The save-time rules the server runs and the CLI does not (#3374). They need
4401
- * the runner's vocabulary (`isValidRunAs`, `GRANTABLE_SENSITIVE_CAPS`), which
4402
- * this directory cannot import, so they are `apply`; the module carries the
4403
- * rule-id anchor and `definition-store.ts` re-exports it.
4404
- */
4405
- const WORKFLOW_SAVE_RULES = "src/workflows/config/workflow-save-rules.ts";
4406
- const workflowApplyRule = (id, exportName, description) => ({
4407
- id,
4408
- description,
4409
- stage: "apply",
4410
- handler: enforcedBy(WORKFLOW_SAVE_RULES, exportName),
4411
- });
4412
- /**
4413
- * The five per-app / per-user queue limits (#1177). All share one handler: a
4414
- * finite non-negative number, floored.
4415
- */
4416
- const QUEUE_LIMITS = [
4417
- "perUserMaxRunning",
4418
- "perUserMaxQueued",
4419
- "perAppMaxRunning",
4420
- "perAppMaxQueued",
4421
- "queueTtlSeconds",
4422
- ];
4423
- const queueLimitFields = QUEUE_LIMITS.map((field) => ({
4424
- field,
4425
- tomlKey: field,
4426
- type: "number",
4427
- emit: "whenSet",
4428
- writableOn: BOTH,
4429
- validation: handler("normalizeWorkflowQueueLimit"),
4430
- }));
4431
- export const WORKFLOW_SURFACE = {
4432
- label: "workflow",
4433
- tables: [
4434
- {
4435
- tomlPath: ["workflow"],
4436
- repeated: false,
4437
- model: "WorkflowDefinition",
4438
- // Declaration order is the order `config pull` writes the keys, so it
4439
- // deliberately matches the pre-#2644 hand-written serializer — migrating
4440
- // to the definition must not reshuffle every workflow TOML file.
4441
- fields: [
4442
- {
4443
- field: "name",
4444
- tomlKey: "name",
4445
- type: "string",
4446
- emit: "always",
4447
- writableOn: BOTH,
4448
- validation: handler("normalizeWorkflowName"),
4449
- },
4450
- {
4451
- field: "description",
4452
- tomlKey: "description",
4453
- type: "string",
4454
- emit: "always",
4455
- writableOn: BOTH,
4456
- validation: handler("normalizeWorkflowDescription"),
4457
- },
4458
- {
4459
- field: "accessRule",
4460
- tomlKey: "accessRule",
4461
- type: "string",
4462
- emit: "whenSet",
4463
- writableOn: BOTH,
4464
- validation: handler("normalizeWorkflowAccessRule"),
4465
- },
4466
- {
4467
- field: "runAs",
4468
- tomlKey: "runAs",
4469
- type: "string",
4470
- emit: "whenSet",
4471
- writableOn: BOTH,
4472
- validation: handler("normalizeWorkflowRunAs"),
4473
- },
4474
- // #1078 Tier 1b — StringSetField on the model, string array in TOML/JSON.
4475
- {
4476
- field: "capabilities",
4477
- tomlKey: "capabilities",
4478
- type: "string[]",
4479
- emit: "whenSet",
4480
- writableOn: BOTH,
4481
- validation: handler("normalizeWorkflowCapabilities"),
4482
- },
4483
- ...queueLimitFields,
4484
- {
4485
- field: "dequeueOrder",
4486
- tomlKey: "dequeueOrder",
4487
- type: "string",
4488
- emit: "always",
4489
- writableOn: BOTH,
4490
- validation: handler("normalizeWorkflowDequeueOrder"),
4491
- },
4492
- {
4493
- field: "requiresClientApply",
4494
- tomlKey: "requiresClientApply",
4495
- type: "boolean",
4496
- emit: "always",
4497
- writableOn: BOTH,
4498
- validation: handler("normalizeWorkflowOptOutFlag"),
4499
- },
4500
- // Accepted on BOTH modes — #807's deferred second PATCH is an update
4501
- // call. The CLI's create-only send is a sequencing invariant owned by
4502
- // `applyWorkflowBody`, not a statement about what the server accepts.
4503
- // #3188 retired the synchronous run route this flag opted into; the
4504
- // field still round-trips (pull, diff, push) until the workflow
4505
- // surface itself retires, and `config push` notes a `true` as
4506
- // ignored. Its step-kind rule went with the route.
4507
- {
4508
- field: "syncCallable",
4509
- tomlKey: "syncCallable",
4510
- type: "boolean",
4511
- emit: "always",
4512
- writableOn: BOTH,
4513
- validation: handler("normalizeWorkflowSyncCallable"),
4514
- },
4515
- // JSON Schema objects. TOML may present them as an inline table OR as a
4516
- // JSON string; the handler owns that parse.
4517
- {
4518
- field: "inputSchema",
4519
- tomlKey: "inputSchema",
4520
- type: "json",
4521
- emit: "whenSet",
4522
- writableOn: BOTH,
4523
- validation: handler("normalizeWorkflowSchemaValue"),
4524
- },
4525
- {
4526
- field: "outputSchema",
4527
- tomlKey: "outputSchema",
4528
- type: "json",
4529
- emit: "whenSet",
4530
- writableOn: BOTH,
4531
- validation: handler("normalizeWorkflowSchemaValue"),
4532
- },
4533
- // #1518/#1972 — declarative run-scoped lock. `[workflow.lock]` inline
4534
- // table on the TOML side, JSON on the wire.
4535
- {
4536
- field: "lock",
4537
- tomlKey: "lock",
4538
- type: "json",
4539
- emit: "whenSet",
4540
- writableOn: BOTH,
4541
- validation: handler("normalizeWorkflowLockValue"),
4542
- },
4543
- ],
4544
- notExposed: {
4545
- workflowId: {
4546
- kind: "server-owned",
4547
- note: "ULID assigned on create; never author-authored.",
4548
- },
4549
- // #2803 — `status` is the ONE availability control and it is
4550
- // server-owned. It used to be a `[workflow]` key, which made `config
4551
- // push` a second writer: pushing a file pulled before an operator ran
4552
- // `workflows disable` put the workflow back in service as a side
4553
- // effect. `server-owned` keeps it out of both the TOML surface and the
4554
- // create/update request schemas, so the only writers are
4555
- // `workflows enable|disable` and create (which assigns `active`).
4556
- status: {
4557
- kind: "server-owned",
4558
- note: "Availability (#2803, #2887): active | inactive | archived. " +
4559
- "Written only by `workflows enable|disable`, the delete flow (a " +
4560
- "plain DELETE writes the `archived` tombstone; `?hard=true` " +
4561
- "destroys), and create, which always assigns `active`. Never " +
4562
- "authored in TOML: `config pull` does not emit it and a file that " +
4563
- "still carries the key fails push (RETIRED_TOML_KEYS).",
4564
- },
4565
- // #2645 criterion 9 — the operational toggle. Configuration is
4566
- // authored in TOML and applied with `config push`, so anything this
4567
- // table exposes has the repo as its single writer. Taking a workflow
4568
- // out of service is an operation with its own single writer
4569
- // (`workflows disable|enable`), so this field must never appear in
4570
- // the `[workflow]` table: `server-owned` keeps it out of both request
4571
- // schemas and the TOML surface, and the coverage guard fails if it is
4572
- // ever moved into `fields`.
4573
- operationallyDisabled: {
4574
- kind: "server-owned",
4575
- note: "Operational toggle (#2645). Written only by the disable/enable " +
4576
- "endpoints (`workflows disable|enable`); read by the dispatch " +
4577
- "path. Never authored in TOML and never accepted on the config " +
4578
- "create/update wire.",
4579
- },
4580
- appId: {
4581
- kind: "server-owned",
4582
- note: "Tenant scope, taken from the route; never on the wire.",
4583
- },
4584
- workflowKey: {
4585
- kind: "structural",
4586
- // Create carries it in the body; update does not read it at all —
4587
- // the URL names the workflow and the CLI checks a contradicting
4588
- // TOML key locally (`workflowKeyMismatchError`).
4589
- requestModes: ["create"],
4590
- note: "The workflow's identity. Comes from the TOML file name / --key and " +
4591
- "is attached by the caller, not spread from the [workflow] table. Its " +
4592
- "TOML spelling is declared in tomlOnlyKeys as `key`.",
4593
- },
4594
- activeConfigId: {
4595
- kind: "server-owned",
4596
- note: "Pointer to the active WorkflowConfiguration, computed on publish.",
4597
- },
4598
- metadataManifest: {
4599
- kind: "structural",
4600
- note: "#1304 declared-access manifest. Travels as the top-level [metadata] / " +
4601
- "secrets tables and is validated by validateManifestShape, not as a " +
4602
- "[workflow] key.",
4603
- },
4604
- // The legacy revision/draft slots are `server-owned`, not `deprecated`:
4605
- // `deprecated` means "still WRITABLE, superseded by another field"
4606
- // (`types.ts`), and phase 5's generated request schemas admit every
4607
- // deprecated key for exactly that reason. None of these six is writable
4608
- // — create and update never read them off the body; the draft save path
4609
- // and the R2 writer assign them — so classifying them `deprecated` made
4610
- // the schema accept a key the handler then dropped, which is the 200-on
4611
- // -a-key-that-did-nothing this issue exists to end. Their models.yaml
4612
- // DEPRECATED marking is about the field's future, not about who writes it.
4613
- latestRevision: {
4614
- kind: "server-owned",
4615
- note: "Legacy revision pointer, marked DEPRECATED in models.yaml. " +
4616
- "Written by the revision save path, never accepted on the wire.",
4617
- },
4618
- stepsR2Key: {
4619
- kind: "server-owned",
4620
- note: "Legacy steps pointer, marked DEPRECATED in models.yaml. Assigned " +
4621
- "by the R2 write, never accepted on the wire.",
4622
- },
4623
- draftStepsR2Key: {
4624
- kind: "server-owned",
4625
- note: "Legacy draft steps pointer, marked DEPRECATED in models.yaml. " +
4626
- "Assigned by the draft save path, never accepted on the wire.",
4627
- },
4628
- draftInputSchema: {
4629
- kind: "server-owned",
4630
- note: "Legacy draft slot, marked DEPRECATED in models.yaml. Written by " +
4631
- "the draft save path from `inputSchema`, never accepted on the wire.",
4632
- },
4633
- draftOutputSchema: {
4634
- kind: "server-owned",
4635
- note: "Legacy draft slot, marked DEPRECATED in models.yaml. Written by " +
4636
- "the draft save path from `outputSchema`, never accepted on the wire.",
4637
- },
4638
- draftModifiedAt: {
4639
- kind: "server-owned",
4640
- note: "Legacy draft timestamp, marked DEPRECATED in models.yaml. Stamped " +
4641
- "by the draft save path, never accepted on the wire.",
4642
- },
4643
- createdBy: {
4644
- kind: "server-owned",
4645
- note: "Admin who created the workflow; assigned server-side.",
4646
- },
4647
- createdAt: {
4648
- kind: "server-owned",
4649
- note: "Timestamp, assigned server-side.",
4650
- },
4651
- modifiedAt: {
4652
- kind: "server-owned",
4653
- note: "Timestamp, assigned server-side.",
4654
- },
4655
- },
4656
- tomlOnlyKeys: {
4657
- key: {
4658
- kind: "structural",
4659
- note: "The workflow key. `config pull` writes it for readability; push takes " +
4660
- "the identity from the file name and attaches `workflowKey` itself.",
4661
- },
4662
- activeConfigName: {
4663
- kind: "structural",
4664
- note: "Names which [[configs]] entry is active. Consumed by the push apply " +
4665
- "path (which activates the matching config by id), not sent as a " +
4666
- "[workflow] field.",
4667
- },
4668
- },
4669
- requestOnlyKeys: {
4670
- steps: {
4671
- // CREATE only: `updateAppWorkflow` never reads `steps` off the body —
4672
- // an update writes them through the workflow-config / draft
4673
- // endpoints (`applyWorkflowBody`) — so a PATCH carrying steps used to
4674
- // return 200 having saved none of them.
4675
- modes: CREATE_ONLY,
4676
- note: "The workflow's step list. Not a `WorkflowDefinition` field — it " +
4677
- "lives on the active WorkflowConfiguration (and in R2) — but the " +
4678
- "create call carries it in the same body so a new workflow lands " +
4679
- "with its steps in one request. Validated by the step allowlist " +
4680
- "(`cli/src/lib/generated-allowlist.ts`, #998) and the server's " +
4681
- "definition validation.",
4682
- },
4683
- expressions: {
4684
- // CREATE only, for the same reason as `steps`: they travel on the
4685
- // steps payload, which an update writes through its own endpoint.
4686
- modes: CREATE_ONLY,
4687
- note: "#1614 — the named `expr.*` definitions, which travel on the same " +
4688
- "steps payload rather than as a definition field.",
4689
- },
4690
- },
4691
- responseOnlyKeys: {
4692
- platformOwned: {
4693
- kind: "server-owned",
4694
- note: "#1660 — derived flag marking a reserved `__internal.` workflow. " +
4695
- "Computed at serialize time; not persisted, never writable.",
4696
- },
4697
- },
4698
- },
4699
- ],
4700
- tomlDocumentKeys: {
4701
- steps: {
4702
- kind: "structural",
4703
- note: "The `[[steps]]` array. Validated by the step allowlist " +
4704
- "(`cli/src/lib/generated-allowlist.ts`, #998) and the server's " +
4705
- "definition validation; its shape is checked by validateWorkflowToml.",
4706
- },
4707
- configs: {
4708
- kind: "structural",
4709
- note: "RETIRED as an inline list (#2645): named configurations are authored " +
4710
- "one per file at `workflows/<key>.configs/<name>.toml` and selected by " +
4711
- "`[workflow].activeConfigName`. Pull writes the sidecars, push applies " +
4712
- "them through the workflow-config endpoints, and a file still carrying " +
4713
- "`[[configs]]` fails validation (validateWorkflowToml) rather than " +
4714
- "having the list quietly ignored. Declared here so the document-shape " +
4715
- "check defers to that targeted message.",
4716
- },
4717
- ...DECLARED_ACCESS_MANIFEST_KEYS,
4718
- expr: {
4719
- kind: "structural",
4720
- note: "#1614 — the named `[expr.cel]` guard definitions, which travel on the " +
4721
- "steps payload (parseWorkflowExpressionsToml).",
4722
- },
4723
- include: {
4724
- kind: "structural",
4725
- note: "Workflow fragments (`include = [\"name\"]` or repeated `[[include]]` " +
4726
- "tables), expanded into `steps` by expandWorkflowTomlData before push.",
4727
- },
4728
- },
4729
- // ── Cross-field rules (#3374) ─────────────────────────────────────────────
4730
- //
4731
- // Two rules the CLI's push preflight runs — through the vendored copy of
4732
- // `workflow-rules.ts` (the server runs both too) — and six more the server
4733
- // runs at save time. What stays
4734
- // UNDECLARED, on purpose: the step-body validation (`validateWorkflowDefinition`
4735
- // and the `steps` structural sub-tree, which is not a field-table rule), and
4736
- // the enable-time activation lint (`workflow-activation-lint.ts`, a transition
4737
- // check rather than a write rule). `runAs`'s VALUE is checked twice today —
4738
- // by its field handler and again inside the identity validator — which is
4739
- // stated here as a finding, not fixed.
4740
- crossFieldRules: [
4741
- {
4742
- id: "system-access-rule",
4743
- description: 'A `runAs = "system"` workflow may not carry a non-empty `accessRule`: ' +
4744
- "a system run never evaluates its rule, so any rule there is dead " +
4745
- "config. The one predicate both runners share; each renders its own " +
4746
- "message.",
4747
- stage: "preflight",
4748
- handler: enforcedBy("src/config-surface/workflow-rules.ts", "checkWorkflowSystemAccessRule"),
4749
- },
4750
- {
4751
- id: "retired-database-step-kind",
4752
- description: "A step may not use a retired `database.*` kind (`database.query`, " +
4753
- "`mutate`, `count`, `aggregate`, `pipeline`, `applyToQuery`, `batch` " +
4754
- "and their `*ForUser` twins): each executed a registered database " +
4755
- "operation, and operations retired (#3189). `database.syncIndexes`, " +
4756
- "`database.create` and `database.delete` stay. Push, save, the " +
4757
- "activation lint and the engine ask the same predicate.",
4758
- stage: "preflight",
4759
- handler: enforcedBy("src/config-surface/workflow-rules.ts", "checkWorkflowRetiredStepKinds"),
4760
- },
4761
- workflowApplyRule("run-as-value", "validateWorkflowIdentityConfig", '`runAs` must be "caller" or "system" when present — the runner has no ' +
4762
- "third identity."),
4763
- workflowApplyRule("capabilities-shape", "validateWorkflowIdentityConfig", "`capabilities` must be an array or set of capability strings."),
4764
- workflowApplyRule("capability-grantable", "validateWorkflowIdentityConfig", "Every declared capability must be one the runner can grant; the " +
4765
- "always-on data baseline is never declared."),
4766
- workflowApplyRule("iterate-users-system-only", "validateWorkflowIdentityConfig", 'An `iterate-users` step may appear only in a `runAs = "system"` ' +
4767
- "workflow — fanning out over every user is not a member-as-themselves " +
4768
- "operation."),
4769
- workflowApplyRule("access-rule-type", "validateWorkflowIdentityConfig", "On create, a supplied `accessRule` must be a string — a non-string is " +
4770
- "malformed input, reported as such rather than as an omission."),
4771
- workflowApplyRule("access-rule-required", "validateWorkflowIdentityConfig", "On create, a caller-mode workflow must state its `accessRule` (`\"true\"` " +
4772
- "for any app member), so a locked workflow is a decision rather than a " +
4773
- "default."),
4774
- ],
4775
- };
4776
- const FIELD_RANGES = [
4777
- { name: "minute", min: 0, max: 59 },
4778
- { name: "hour", min: 0, max: 23 },
4779
- { name: "day-of-month", min: 1, max: 31 },
4780
- { name: "month", min: 1, max: 12 },
4781
- { name: "day-of-week", min: 0, max: 6 },
4782
- ];
4783
- function parseField(field, min, max, fieldName) {
4784
- const result = new Set();
4785
- const parts = field.split(",");
4786
- for (const partRaw of parts) {
4787
- const part = partRaw.trim();
4788
- if (!part) {
4789
- throw new Error(`Invalid ${fieldName} field: empty segment`);
4790
- }
4791
- let step = 1;
4792
- let rangePart = part;
4793
- const slashIdx = part.indexOf("/");
4794
- if (slashIdx !== -1) {
4795
- rangePart = part.slice(0, slashIdx);
4796
- const stepStr = part.slice(slashIdx + 1);
4797
- const stepNum = Number(stepStr);
4798
- if (!Number.isInteger(stepNum) || stepNum <= 0) {
4799
- throw new Error(`Invalid ${fieldName} step: "${stepStr}"`);
4800
- }
4801
- step = stepNum;
4802
- }
4803
- let lo;
4804
- let hi;
4805
- if (rangePart === "*") {
4806
- lo = min;
4807
- hi = max;
4808
- }
4809
- else if (rangePart.includes("-")) {
4810
- const [loStr, hiStr] = rangePart.split("-");
4811
- lo = Number(loStr);
4812
- hi = Number(hiStr);
4813
- if (!Number.isInteger(lo) || !Number.isInteger(hi)) {
4814
- throw new Error(`Invalid ${fieldName} range: "${rangePart}"`);
4815
- }
4816
- }
4817
- else {
4818
- const exact = Number(rangePart);
4819
- if (!Number.isInteger(exact)) {
4820
- throw new Error(`Invalid ${fieldName} value: "${rangePart}"`);
4821
- }
4822
- lo = exact;
4823
- hi = exact;
4824
- }
4825
- // Normalize day-of-week 7 -> 0 (Sunday). We only do this for bare
4826
- // values, not inside a range — `5-7` would otherwise become `5-0`
4827
- // which then fails the `lo > hi` check with a confusing error. Users
4828
- // who want Fri–Sun should write `5-0,0` or `5,6,0`; we reject 7 in
4829
- // ranges outright with a clearer message.
4830
- if (fieldName === "day-of-week") {
4831
- const isRange = rangePart.includes("-");
4832
- if (isRange && (lo === 7 || hi === 7)) {
4833
- throw new Error(`Invalid day-of-week range "${rangePart}": 7 (Sunday) is only allowed as a single value, not inside a range. Use 0 for Sunday in ranges.`);
4834
- }
4835
- if (!isRange) {
4836
- if (lo === 7)
4837
- lo = 0;
4838
- if (hi === 7)
4839
- hi = 0;
4840
- }
4841
- }
4842
- if (lo < min || hi > max || lo > hi) {
4843
- throw new Error(`Invalid ${fieldName} range: ${lo}-${hi} (allowed ${min}-${max})`);
4844
- }
4845
- for (let v = lo; v <= hi; v += step) {
4846
- result.add(v);
4847
- }
4848
- }
4849
- return result;
4968
+ return result;
4850
4969
  }
4851
4970
  export function parseCron(expr) {
4852
4971
  if (!expr || typeof expr !== "string") {
@@ -4936,15 +5055,6 @@ export function isValidTimezone(name) {
4936
5055
  * pins. So the grammar and the `Intl` probe live next door in
4937
5056
  * `cron-expression.ts`, which is a shared-predicate module rather than a rules
4938
5057
  * module, and this one only decides and renders.
4939
- *
4940
- * ── What is NOT shared ───────────────────────────────────────────────────
4941
- *
4942
- * The standalone cron routes ask the same two predicates and render their own
4943
- * `Invalid cron expression: …` / `Invalid timezone: …`, with their own
4944
- * defaulting (create reads an absent timezone as UTC, update does not). That
4945
- * is intent assumption 2 in the form its own fallback describes, and the shape
4946
- * `workflow-rules.ts` set in phase 2: one predicate, each site's message and
4947
- * defaulting preserved. No refusal message changed anywhere.
4948
5058
  */
4949
5059
  /** The rule ids this module owns — the union type below anchors them (#3373). */
4950
5060
  export const CRON_TRIGGER_RULE_IDS = [
@@ -5875,6 +5985,9 @@ export const AGENT_ERROR_CODES = [
5875
5985
  // #4262 — a single-round test case whose seeded history, context or
5876
5986
  // assertions cannot be a round of this agent (`agent-test-case.ts`).
5877
5987
  "AGENT_TEST_CASE_INVALID",
5988
+ // #4549 — a presentation call whose `references` name a number that is not
5989
+ // an earlier call of the turn with a result.
5990
+ "AGENT_PRESENTATION_REFERENCE_INVALID",
5878
5991
  ];
5879
5992
  /**
5880
5993
  * The platform maximums. An agent may lower `maxSteps`, `waitLimitSeconds`
@@ -5900,14 +6013,20 @@ export const AGENT_ANSWERED_BY = ["initiator", "participants"];
5900
6013
  export const AGENT_TOOL_INVOKE = ["request", "task"];
5901
6014
  export const AGENT_TOOL_HISTORY_SCOPES = ["session", "turn"];
5902
6015
  /**
5903
- * The result the platform records for a call to a client tool with
5904
- * `endsTurn = true`: the call is final when its response is committed, and
5905
- * later rounds read this as its tool result.
6016
+ * Where a tool without a `function` runs: `client` is answered by a member's
6017
+ * client; `presentation` is data the model hands the client with its final
6018
+ * answer, which no client executes (#4549).
6019
+ */
6020
+ export const AGENT_TOOL_RUNS = ["client", "presentation"];
6021
+ /**
6022
+ * The result the platform records for a presentation call: the call is final
6023
+ * when its response is committed, and later rounds read this as its tool
6024
+ * result.
5906
6025
  */
5907
6026
  export const AGENT_TERMINAL_CALL_OUTPUT = Object.freeze({
5908
6027
  delivered: true,
5909
6028
  });
5910
- /** The schema of `AGENT_TERMINAL_CALL_OUTPUT`: a terminal client tool's output type. */
6029
+ /** The schema of `AGENT_TERMINAL_CALL_OUTPUT`, the result a presentation call is recorded with. */
5911
6030
  export const AGENT_TERMINAL_CALL_OUTPUT_SCHEMA = Object.freeze({
5912
6031
  type: "object",
5913
6032
  properties: { delivered: { type: "boolean" } },
@@ -5935,6 +6054,7 @@ const AGENT_TOOL_KEYS = [
5935
6054
  "statusText",
5936
6055
  "historyScope",
5937
6056
  "endsTurn",
6057
+ "references",
5938
6058
  "inputSchema",
5939
6059
  "outputSchema",
5940
6060
  ];
@@ -6030,13 +6150,78 @@ function checkAgentName(value, path, seen, what, out) {
6030
6150
  }
6031
6151
  seen.add(value);
6032
6152
  }
6033
- function checkAgentTool(tool, index, names, out) {
6034
- const path = `tools[${index}]`;
6035
- if (!agentIsPlainObject(tool)) {
6036
- out.push(agentInvalid(path, "must be a table declaring the tool"));
6037
- return;
6038
- }
6039
- agentUnknownKeys(tool, AGENT_TOOL_KEYS, path, out);
6153
+ /** Whether a property schema holds one integer, or a list of integers. */
6154
+ function agentIsReferenceProperty(schema) {
6155
+ if (!agentIsPlainObject(schema))
6156
+ return false;
6157
+ if (schema.type === "integer")
6158
+ return true;
6159
+ return (schema.type === "array" &&
6160
+ agentIsPlainObject(schema.items) &&
6161
+ schema.items.type === "integer");
6162
+ }
6163
+ /**
6164
+ * A presentation (#4549): its `inputSchema` is required, the keys of a call
6165
+ * that runs or pauses are refused, and each `references` entry names a
6166
+ * top-level input property declared as an integer or a list of integers.
6167
+ */
6168
+ function checkAgentPresentation(tool, path, out) {
6169
+ const notDeclared = [
6170
+ ["outputSchema", "the platform records a presentation call's result"],
6171
+ ["approval", "a presentation call never pauses"],
6172
+ ["endsTurn", "a presentation call always ends the turn"],
6173
+ ];
6174
+ for (const [key, why] of notDeclared) {
6175
+ if (tool[key] !== undefined) {
6176
+ out.push(agentInvalid(`${path}.${key}`, `is not declared on a presentation: ${why} — remove it`));
6177
+ }
6178
+ }
6179
+ const schemaPath = `${path}.inputSchema`;
6180
+ if (tool.inputSchema === undefined) {
6181
+ out.push(agentInvalid(schemaPath, "is required on a presentation"));
6182
+ }
6183
+ else {
6184
+ const error = agentSchemaError(tool.inputSchema, schemaPath);
6185
+ if (error)
6186
+ out.push(error);
6187
+ }
6188
+ if (tool.references === undefined)
6189
+ return;
6190
+ const referencesPath = `${path}.references`;
6191
+ const references = tool.references;
6192
+ if (!Array.isArray(references) ||
6193
+ references.length === 0 ||
6194
+ !references.every((name) => agentIsNonEmptyString(name))) {
6195
+ out.push(agentInvalid(referencesPath, "must be a non-empty list of input property names, each holding an " +
6196
+ "integer or a list of integers"));
6197
+ return;
6198
+ }
6199
+ const seen = new Set();
6200
+ const properties = agentIsPlainObject(tool.inputSchema) && agentIsPlainObject(tool.inputSchema.properties)
6201
+ ? tool.inputSchema.properties
6202
+ : {};
6203
+ for (const name of references) {
6204
+ if (seen.has(name)) {
6205
+ out.push(agentInvalid(referencesPath, `repeats "${name}"; each property is named once`));
6206
+ continue;
6207
+ }
6208
+ seen.add(name);
6209
+ if (!Object.prototype.hasOwnProperty.call(properties, name)) {
6210
+ out.push(agentInvalid(referencesPath, `names "${name}", which inputSchema.properties does not declare`));
6211
+ }
6212
+ else if (!agentIsReferenceProperty(properties[name])) {
6213
+ out.push(agentInvalid(referencesPath, `names "${name}", which must be declared as { type = "integer" } or ` +
6214
+ 'a list of them ({ type = "array", items = { type = "integer" } })'));
6215
+ }
6216
+ }
6217
+ }
6218
+ function checkAgentTool(tool, index, names, out) {
6219
+ const path = `tools[${index}]`;
6220
+ if (!agentIsPlainObject(tool)) {
6221
+ out.push(agentInvalid(path, "must be a table declaring the tool"));
6222
+ return;
6223
+ }
6224
+ agentUnknownKeys(tool, AGENT_TOOL_KEYS, path, out);
6040
6225
  checkAgentName(tool.name, `${path}.name`, names, "tool", out);
6041
6226
  if (!agentIsNonEmptyString(tool.description)) {
6042
6227
  out.push(agentInvalid(`${path}.description`, "is required — the sentence the model reads to decide when to call it"));
@@ -6045,52 +6230,61 @@ function checkAgentTool(tool, index, names, out) {
6045
6230
  const hasRuns = tool.runs !== undefined;
6046
6231
  if (hasFunction === hasRuns) {
6047
6232
  out.push(agentInvalid(path, hasFunction
6048
- ? 'sets both function and runs; a tool is a server tool (function = "<key>") or a client tool (runs = "client"), not both'
6049
- : 'needs function = "<key>" (a server tool) or runs = "client" (a client tool)'));
6233
+ ? 'sets both function and runs; a tool is a server tool (function = "<key>"), a client tool (runs = "client") or a presentation (runs = "presentation"), not more than one'
6234
+ : 'needs function = "<key>" (a server tool), runs = "client" (a client tool) or runs = "presentation" (a presentation)'));
6050
6235
  }
6051
- if (hasRuns && tool.runs !== "client") {
6052
- out.push(agentInvalid(`${path}.runs`, `must be "client"; found ${JSON.stringify(tool.runs)}`));
6236
+ if (hasRuns && !AGENT_TOOL_RUNS.includes(tool.runs)) {
6237
+ out.push(agentInvalid(`${path}.runs`, `must be ${AGENT_TOOL_RUNS.map((runs) => JSON.stringify(runs)).join(" or ")}; found ${JSON.stringify(tool.runs)}`));
6053
6238
  }
6054
6239
  if (hasFunction && !agentIsNonEmptyString(tool.function)) {
6055
6240
  out.push(agentInvalid(`${path}.function`, "must name a server function by key"));
6056
6241
  }
6057
- const isClient = hasRuns && !hasFunction;
6242
+ const isClient = hasRuns && !hasFunction && tool.runs === "client";
6243
+ const isPresentation = hasRuns && !hasFunction && tool.runs === "presentation";
6058
6244
  if (tool.invoke !== undefined) {
6059
- if (isClient) {
6060
- out.push(agentInvalid(`${path}.invoke`, "is for server tools; a client tool is answered by a member's client"));
6245
+ if (isClient || isPresentation) {
6246
+ out.push(agentInvalid(`${path}.invoke`, isClient
6247
+ ? "is for server tools; a client tool is answered by a member's client"
6248
+ : "is for server tools; a presentation is never executed"));
6061
6249
  }
6062
6250
  else if (!AGENT_TOOL_INVOKE.includes(tool.invoke)) {
6063
6251
  out.push(agentInvalid(`${path}.invoke`, `must be one of ${AGENT_TOOL_INVOKE.join(" | ")}`));
6064
6252
  }
6065
6253
  }
6066
- const terminal = tool.endsTurn === true;
6067
- if (tool.endsTurn !== undefined && typeof tool.endsTurn !== "boolean") {
6068
- out.push(agentInvalid(`${path}.endsTurn`, "must be true or false"));
6069
- }
6070
- if (terminal && tool.approval === true) {
6071
- out.push(agentInvalid(`${path}.endsTurn`, "cannot be set with approval = true: a terminal call never pauses"));
6254
+ if (isPresentation) {
6255
+ checkAgentPresentation(tool, path, out);
6072
6256
  }
6073
- for (const key of ["inputSchema", "outputSchema"]) {
6074
- const schemaPath = `${path}.${key}`;
6075
- if (isClient && terminal && key === "outputSchema") {
6076
- if (tool[key] !== undefined) {
6077
- out.push(agentInvalid(schemaPath, "is not declared on a client tool with endsTurn = true: the " +
6078
- "platform records a terminal client call's result — remove it"));
6257
+ else {
6258
+ const terminal = tool.endsTurn === true;
6259
+ if (tool.endsTurn !== undefined && typeof tool.endsTurn !== "boolean") {
6260
+ out.push(agentInvalid(`${path}.endsTurn`, "must be true or false"));
6261
+ }
6262
+ else if (isClient && terminal) {
6263
+ out.push(agentInvalid(`${path}.endsTurn`, "cannot be set on a client tool: a client tool is answered by a " +
6264
+ "member's client; for data the model hands the client with its " +
6265
+ 'answer, declare runs = "presentation"'));
6266
+ }
6267
+ else if (terminal && tool.approval === true) {
6268
+ out.push(agentInvalid(`${path}.endsTurn`, "cannot be set with approval = true: a terminal call never pauses"));
6269
+ }
6270
+ if (tool.references !== undefined) {
6271
+ out.push(agentInvalid(`${path}.references`, 'is declared only on a presentation (runs = "presentation")'));
6272
+ }
6273
+ for (const key of ["inputSchema", "outputSchema"]) {
6274
+ const schemaPath = `${path}.${key}`;
6275
+ if (isClient) {
6276
+ if (tool[key] === undefined) {
6277
+ out.push(agentInvalid(schemaPath, "is required on a client tool"));
6278
+ continue;
6279
+ }
6280
+ const error = agentSchemaError(tool[key], schemaPath);
6281
+ if (error)
6282
+ out.push(error);
6079
6283
  }
6080
- continue;
6081
- }
6082
- if (isClient) {
6083
- if (tool[key] === undefined) {
6084
- out.push(agentInvalid(schemaPath, "is required on a client tool"));
6085
- continue;
6284
+ else if (hasFunction && tool[key] !== undefined) {
6285
+ out.push(agentInvalid(schemaPath, "is not declared on a server tool; its function's schemas are the " +
6286
+ "tool's (one source of truth) — remove it"));
6086
6287
  }
6087
- const error = agentSchemaError(tool[key], schemaPath);
6088
- if (error)
6089
- out.push(error);
6090
- }
6091
- else if (hasFunction && tool[key] !== undefined) {
6092
- out.push(agentInvalid(schemaPath, "is not declared on a server tool; its function's schemas are the " +
6093
- "tool's (one source of truth) — remove it"));
6094
6288
  }
6095
6289
  }
6096
6290
  if (tool.approval !== undefined && typeof tool.approval !== "boolean") {
@@ -6409,6 +6603,39 @@ export function agentTestCaseRefusal(promptKey, _role = "evaluator") {
6409
6603
  return agentRefusal("AGENT_TEST_CASE_NOT_SUPPORTED", `Prompt "${promptKey}" is an agent (kind = "agent") and cannot be an ` +
6410
6604
  "evaluator: an evaluator is run single-shot. Name a chat prompt");
6411
6605
  }
6606
+ /** The integers a call's argument holds under one referencing property. */
6607
+ function referencedNumbers(value) {
6608
+ const values = Array.isArray(value) ? value : [value];
6609
+ return values.filter((v) => typeof v === "number" && Number.isInteger(v));
6610
+ }
6611
+ /**
6612
+ * The refusal of a presentation call whose `references` name a number that
6613
+ * is not an earlier call of the turn with a result — a refused call, a number
6614
+ * the turn never gave, or a call of the same response — or `null`. `earlier`
6615
+ * is the turn's calls committed before this call's response. The message
6616
+ * lists the offending values by property and the numbers that may be
6617
+ * referenced, with their tools, so the model can correct itself next round.
6618
+ */
6619
+ export function presentationReferenceRefusal(tool, args, earlier) {
6620
+ if (!tool.references?.length || !agentIsPlainObject(args))
6621
+ return null;
6622
+ const valid = earlier.filter((call) => call.state === "output-available");
6623
+ const validNumbers = new Set(valid.map((call) => call.callNumber));
6624
+ const offending = [];
6625
+ for (const property of tool.references) {
6626
+ const bad = [...new Set(referencedNumbers(args[property]).filter((n) => !validNumbers.has(n)))];
6627
+ if (bad.length > 0)
6628
+ offending.push(`${property}: ${bad.join(", ")}`);
6629
+ }
6630
+ if (offending.length === 0)
6631
+ return null;
6632
+ const choices = valid.length > 0
6633
+ ? `Reference one of: ${valid.map((call) => `${call.callNumber} (${call.toolName})`).join(", ")}`
6634
+ : "No earlier call of this turn has a result to reference";
6635
+ return agentRefusal("AGENT_PRESENTATION_REFERENCE_INVALID", `The call to "${tool.name}" references calls this turn has no result for ` +
6636
+ `(${offending.join("; ")}). A reference is the \`call\` number of an ` +
6637
+ `earlier tool result of this turn. ${choices}`);
6638
+ }
6412
6639
  /** A deep copy, so a reader's defaults never reach the caller's value. */
6413
6640
  function agentCopy(value) {
6414
6641
  return value === undefined ? value : JSON.parse(JSON.stringify(value));
@@ -6416,7 +6643,8 @@ function agentCopy(value) {
6416
6643
  /**
6417
6644
  * The declaration with every default applied: `answeredBy = "initiator"`, the
6418
6645
  * platform maximums for the limits, and per tool `invoke = "request"` (server
6419
- * tools), `approval = false`, `historyScope = "session"` and `endsTurn = false`.
6646
+ * tools), `approval = false`, `historyScope = "session"` and `endsTurn = false`
6647
+ * — `endsTurn = true` for a presentation, whose call always ends the turn.
6420
6648
  *
6421
6649
  * The ONLY accessor for defaults — the stored value never carries them
6422
6650
  * (DSO-3798-001). Takes a value `resolveAgentDeclaration` accepted (or `null`)
@@ -6433,10 +6661,10 @@ export function normalizeAgentDeclaration(declaration) {
6433
6661
  history: source.history ?? null,
6434
6662
  tools: (source.tools ?? []).map((tool) => ({
6435
6663
  ...tool,
6436
- ...(tool.runs === "client" ? {} : { invoke: tool.invoke ?? "request" }),
6664
+ ...(tool.runs === undefined ? { invoke: tool.invoke ?? "request" } : {}),
6437
6665
  approval: tool.approval ?? false,
6438
6666
  historyScope: tool.historyScope ?? "session",
6439
- endsTurn: tool.endsTurn ?? false,
6667
+ endsTurn: tool.runs === "presentation" ? true : (tool.endsTurn ?? false),
6440
6668
  })),
6441
6669
  events: source.events ?? [],
6442
6670
  };
@@ -6467,33 +6695,23 @@ const GEMINI_TYPES = [
6467
6695
  "array",
6468
6696
  ];
6469
6697
  /**
6470
- * Keywords Gemini spells the same way, with the same meaning. `required` is
6471
- * here rather than under the structural keywords because Gemini reads it
6472
- * verbatim.
6698
+ * What Gemini's function `Schema` does with one keyword, from the keyword
6699
+ * table: `pass` (spelled the same way, with the same meaning — `required`
6700
+ * among them, and Gemini's own `nullable`, `propertyOrdering` and `example`),
6701
+ * `drop` (an annotation with no value meaning, dropped in silence, spec §3),
6702
+ * `rule` (handled by its own rule below) or `refuse`. A key the table does not
6703
+ * name is refused: a keyword nobody classified could mean anything.
6473
6704
  */
6474
- const GEMINI_PASS_KEYWORDS = [
6475
- "description",
6476
- "title",
6477
- "default",
6478
- "minimum",
6479
- "maximum",
6480
- "minLength",
6481
- "maxLength",
6482
- "pattern",
6483
- "minItems",
6484
- "maxItems",
6485
- "minProperties",
6486
- "maxProperties",
6487
- "required",
6488
- // Gemini's own spellings, accepted as authored.
6489
- "nullable",
6490
- "propertyOrdering",
6491
- "example",
6492
- ];
6493
- /** Annotations with no value meaning: dropped in silence (spec §3). */
6494
- const GEMINI_DROPPED_KEYWORDS = ["$schema", "$id", "$comment"];
6495
- /** Keywords handled by their own rule below, not by the tables. */
6496
- const GEMINI_STRUCTURAL_KEYWORDS = [
6705
+ export function geminiKeywordVerdict(keyword) {
6706
+ return Object.prototype.hasOwnProperty.call(SCHEMA_KEYWORDS, keyword)
6707
+ ? SCHEMA_KEYWORDS[keyword].gemini
6708
+ : "refuse";
6709
+ }
6710
+ /**
6711
+ * Keywords handled by their own rule below: exactly the table's `rule` rows,
6712
+ * which the keyword-table conformance test holds it to.
6713
+ */
6714
+ export const GEMINI_STRUCTURAL_KEYWORDS = [
6497
6715
  "type",
6498
6716
  "enum",
6499
6717
  "const",
@@ -6514,10 +6732,12 @@ const GEMINI_FORMATS = [
6514
6732
  "double",
6515
6733
  ];
6516
6734
  /**
6517
- * Keywords Gemini's function `Schema` has no spelling for. Each is refused
6518
- * rather than dropped: dropping any of them widens what the model may produce.
6735
+ * Why Gemini's function `Schema` cannot carry a refused keyword, for the ones
6736
+ * with a reason of their own. Each is refused rather than dropped: dropping any
6737
+ * of them widens what the model may produce. A refused keyword with no entry
6738
+ * here gets the generic reason.
6519
6739
  */
6520
- const GEMINI_REFUSED_KEYWORDS = {
6740
+ export const GEMINI_REFUSAL_REASONS = {
6521
6741
  $ref: "Gemini's function Schema has no $ref — inline the referenced schema",
6522
6742
  $defs: "Gemini's function Schema has no $defs — inline each definition where it is used",
6523
6743
  definitions: "Gemini's function Schema has no definitions — inline each definition where it is used",
@@ -6544,21 +6764,10 @@ const GEMINI_REFUSED_KEYWORDS = {
6544
6764
  writeOnly: "Gemini's function Schema has no writeOnly — drop it, or say so in description",
6545
6765
  deprecated: "Gemini's function Schema has no deprecated — say so in description",
6546
6766
  };
6547
- /**
6548
- * Sibling keywords that make a `oneOf` node a MIXED schema rather than a clean
6549
- * tagged union. Exactly `describeSchema`'s list
6550
- * (`src/workflows/schema-descriptor.ts`) — the platform's own rule for what a
6551
- * discriminated union is, restated here because that module is vendored
6552
- * separately and cannot be imported from `src/config-surface/`.
6553
- */
6554
- const ONEOF_SIBLING_KEYWORDS = [
6555
- "type",
6556
- "properties",
6557
- "required",
6558
- "additionalProperties",
6559
- "items",
6560
- "enum",
6561
- ];
6767
+ /** The reason a key the table does not classify, or classifies without one, is refused. */
6768
+ const GEMINI_UNCLASSIFIED_REASON = "is not a keyword Gemini's function Schema carries, and dropping a " +
6769
+ "keyword whose meaning the platform does not know could widen what the " +
6770
+ "model may produce";
6562
6771
  function isPlainSchemaObject(value) {
6563
6772
  return typeof value === "object" && value !== null && !Array.isArray(value);
6564
6773
  }
@@ -6612,7 +6821,7 @@ function memberTagLiterals(member) {
6612
6821
  * and the platform validator reject but an `anyOf` of the same members accepts
6613
6822
  * — so the rewrite would widen what the model may produce. The platform
6614
6823
  * validator already rejects a value whose tag is missing
6615
- * (`src/workflows/schema-validation.ts`), so requiring it refuses nothing the
6824
+ * (`src/function-runs/schema-validation.ts`), so requiring it refuses nothing the
6616
6825
  * platform accepts at run time.
6617
6826
  */
6618
6827
  function discriminatedOneOf(node, members) {
@@ -6625,7 +6834,10 @@ function discriminatedOneOf(node, members) {
6625
6834
  'members, every one of them type = "object"',
6626
6835
  };
6627
6836
  }
6628
- const sibling = ONEOF_SIBLING_KEYWORDS.filter((key) => Object.prototype.hasOwnProperty.call(node, key));
6837
+ // Sibling keywords that make a `oneOf` node a MIXED schema rather than a
6838
+ // clean tagged union: `describeSchema`'s own list, the platform's rule for
6839
+ // what a discriminated union is.
6840
+ const sibling = ONEOF_SIBLING_CONSTRAINT_KEYS.filter((key) => Object.prototype.hasOwnProperty.call(node, key));
6629
6841
  if (sibling.length > 0) {
6630
6842
  return {
6631
6843
  ok: false,
@@ -6707,7 +6919,8 @@ function translateGeminiNode(node, path, out) {
6707
6919
  // ── Pass one: the tables, in the author's own key order ────────────────
6708
6920
  const deferred = new Set();
6709
6921
  for (const key of Object.keys(node)) {
6710
- if (GEMINI_DROPPED_KEYWORDS.includes(key))
6922
+ const verdict = geminiKeywordVerdict(key);
6923
+ if (verdict === "drop")
6711
6924
  continue;
6712
6925
  if (key === "additionalProperties") {
6713
6926
  // Dropped for `false` and `true` alike: Gemini has no closed-object
@@ -6722,22 +6935,19 @@ function translateGeminiNode(node, path, out) {
6722
6935
  "but the platform validates the original schema)");
6723
6936
  continue;
6724
6937
  }
6725
- if (Object.prototype.hasOwnProperty.call(GEMINI_REFUSED_KEYWORDS, key)) {
6726
- refuse(key, GEMINI_REFUSED_KEYWORDS[key]);
6727
- continue;
6728
- }
6729
- if (GEMINI_PASS_KEYWORDS.includes(key)) {
6938
+ if (verdict === "pass") {
6730
6939
  result[key] = schemaCopy(node[key]);
6731
6940
  continue;
6732
6941
  }
6733
- if (GEMINI_STRUCTURAL_KEYWORDS.includes(key)) {
6942
+ if (verdict === "rule" && GEMINI_STRUCTURAL_KEYWORDS.includes(key)) {
6734
6943
  deferred.add(key);
6735
6944
  continue;
6736
6945
  }
6737
- // Fail closed: a keyword nobody classified could mean anything.
6738
- refuse(key, "is not a keyword Gemini's function Schema carries, and dropping a " +
6739
- "keyword whose meaning the platform does not know could widen what the " +
6740
- "model may produce");
6946
+ // Fail closed: a refused keyword, or one nobody classified, could mean
6947
+ // anything to the model.
6948
+ refuse(key, Object.prototype.hasOwnProperty.call(GEMINI_REFUSAL_REASONS, key)
6949
+ ? GEMINI_REFUSAL_REASONS[key]
6950
+ : GEMINI_UNCLASSIFIED_REASON);
6741
6951
  }
6742
6952
  // ── Pass two: the structural keywords, in a fixed order ────────────────
6743
6953
  if (deferred.has("enum")) {
@@ -7182,6 +7392,324 @@ export function agentSchemaDeficitRefusal(deficit) {
7182
7392
  `rewrite the schema, or archive every ${provider} config of this prompt`,
7183
7393
  };
7184
7394
  }
7395
+ // ── src/config-surface/prompt-schema-refusals.ts ─────────────────────────
7396
+ /**
7397
+ * What a prompt push refuses — #5536 (project `unified-schemas` phase 5)
7398
+ * reported it, #5538 (phase 6, intent criterion 8) refuses it.
7399
+ *
7400
+ * Two checks judge a prompt's schemas: the lossless Gemini translator
7401
+ * (`translateSchemaForProvider`) on the output schemas a Gemini config sends,
7402
+ * and the engine (the function push's rules) on every schema. A write
7403
+ * carrying a keyword either would refuse is refused, each keyword named with
7404
+ * its fix and a code: `PROMPT_SCHEMA_NOT_TRANSLATABLE` for the translator,
7405
+ * `PROMPT_SCHEMA_UNSUPPORTED_KEYWORD` for the engine. The admin prompt routes,
7406
+ * the CLI preflight (through the vendored copy), the Gemini call path and the
7407
+ * audit (`scripts/lib/schema-audit-core.ts`) all read this module, so they
7408
+ * cannot disagree about which schemas are refused.
7409
+ *
7410
+ * An agent's translator refusals are not here: they are already the push
7411
+ * error `AGENT_SCHEMA_NOT_TRANSLATABLE` (DSO-5536-002).
7412
+ */
7413
+ /**
7414
+ * The code a prompt write is refused with for a keyword the lossless Gemini
7415
+ * translator cannot carry, and the code a run of a stored prompt whose output
7416
+ * schema it cannot carry fails with.
7417
+ */
7418
+ export const PROMPT_SCHEMA_NOT_TRANSLATABLE = "PROMPT_SCHEMA_NOT_TRANSLATABLE";
7419
+ /** The code a prompt write is refused with for a keyword or a shape the schema check would not enforce. */
7420
+ export const PROMPT_SCHEMA_UNSUPPORTED_KEYWORD = "PROMPT_SCHEMA_UNSUPPORTED_KEYWORD";
7421
+ /**
7422
+ * The fix for each keyword the engine refuses: one entry per refused row of
7423
+ * the keyword table, and no other key.
7424
+ */
7425
+ export const ENGINE_REFUSAL_FIXES = {
7426
+ $dynamicRef: "Write a local $ref to #/$defs/<Name> instead",
7427
+ $recursiveRef: "Write a local $ref to #/$defs/<Name> instead",
7428
+ allOf: "Merge the members into one schema",
7429
+ not: "State what is allowed instead",
7430
+ if: "Declare a discriminated oneOf instead",
7431
+ then: "Declare a discriminated oneOf instead",
7432
+ else: "Declare a discriminated oneOf instead",
7433
+ patternProperties: "Name the properties",
7434
+ propertyNames: "Name the properties",
7435
+ dependencies: "Declare a discriminated oneOf instead",
7436
+ dependentRequired: "Declare a discriminated oneOf instead",
7437
+ dependentSchemas: "Declare a discriminated oneOf instead",
7438
+ unevaluatedProperties: "Use additionalProperties: false instead",
7439
+ contains: "Declare items, and bound the count with minItems/maxItems",
7440
+ minContains: "Declare items, and bound the count with minItems/maxItems",
7441
+ maxContains: "Declare items, and bound the count with minItems/maxItems",
7442
+ prefixItems: "Declare one items schema",
7443
+ additionalItems: "Declare one items schema",
7444
+ unevaluatedItems: "Declare one items schema",
7445
+ };
7446
+ /**
7447
+ * The fix for a translator refusal whose reason states only what would be
7448
+ * lost, appended to the refusal line (DSO-5536-008: the translator's own
7449
+ * texts are refusal texts elsewhere and stay as they are). `"*"` is the fix
7450
+ * for a keyword the translator has no reason of its own for.
7451
+ */
7452
+ export const TRANSLATOR_REFUSAL_FIXES = {
7453
+ exclusiveMinimum: "for an integer, write minimum one above the bound; otherwise drop it and check the bound in the code that reads the answer, or run the prompt on a non-Gemini config",
7454
+ exclusiveMaximum: "for an integer, write maximum one below the bound; otherwise drop it and check the bound in the code that reads the answer, or run the prompt on a non-Gemini config",
7455
+ multipleOf: "drop it and check the value in the code that reads the answer, or run the prompt on a non-Gemini config",
7456
+ uniqueItems: "drop it and de-duplicate in the code that reads the answer, or run the prompt on a non-Gemini config",
7457
+ "*": "remove the keyword, or run the prompt on a non-Gemini config",
7458
+ };
7459
+ /** The type names the engine reads. */
7460
+ const ENGINE_SCHEMA_TYPES = ["object", "array", "string", "number", "integer", "boolean", "null"];
7461
+ function isJudgedSchemaObject(value) {
7462
+ return value !== null && typeof value === "object" && !Array.isArray(value);
7463
+ }
7464
+ function judgedPath(path, segment) {
7465
+ if (segment.startsWith("["))
7466
+ return `${path}${segment}`;
7467
+ return path ? `${path}.${segment}` : segment;
7468
+ }
7469
+ /**
7470
+ * Every keyword of `schema` the function push's rules refuse, over the nodes
7471
+ * they check (the root, `properties`, `items`, `anyOf`, `oneOf`; never
7472
+ * `$defs`): the keyword table's refused class, each reason ending with its
7473
+ * fix, and the shape rules. An enforced constraint (`uniqueItems`,
7474
+ * `multipleOf`, …) is never one: only the translator refuses those.
7475
+ *
7476
+ * The walk keeps its own work stack rather than recursing: the compiler
7477
+ * accepts a schema nested deeper than the call stack, and every refusal must
7478
+ * still be named for it.
7479
+ */
7480
+ export function engineSchemaRefusals(schema, path = "") {
7481
+ const out = [];
7482
+ const work = [{ node: schema, path }];
7483
+ while (work.length > 0) {
7484
+ const step = work.pop();
7485
+ if ("refusal" in step) {
7486
+ out.push(step.refusal);
7487
+ continue;
7488
+ }
7489
+ // A node's steps in report order, pushed reversed so they pop in order.
7490
+ const steps = [];
7491
+ const fault = (keyword, reason) => steps.push({ refusal: { path: step.path, keyword, reason } });
7492
+ const node = step.node;
7493
+ if (!isJudgedSchemaObject(node)) {
7494
+ fault("(schema)", "must be a JSON Schema object");
7495
+ }
7496
+ else {
7497
+ for (const keyword of refusedSchemaKeywords()) {
7498
+ if (Object.prototype.hasOwnProperty.call(node, keyword)) {
7499
+ fault(keyword, `${keyword} is not supported: the schema check would not enforce it. ${ENGINE_REFUSAL_FIXES[keyword]}`);
7500
+ }
7501
+ }
7502
+ if (node.additionalProperties !== undefined && typeof node.additionalProperties !== "boolean") {
7503
+ fault("additionalProperties", "must be true or false; a schema for the extra properties is not supported");
7504
+ }
7505
+ if (node.type !== undefined) {
7506
+ const types = Array.isArray(node.type) ? node.type : [node.type];
7507
+ if (types.length === 0)
7508
+ fault("type", "must name at least one JSON Schema type");
7509
+ const unknown = types.find((type) => !ENGINE_SCHEMA_TYPES.includes(type));
7510
+ if (unknown !== undefined)
7511
+ fault("type", `must be one of ${ENGINE_SCHEMA_TYPES.join(", ")}, not ${JSON.stringify(unknown)}`);
7512
+ }
7513
+ if (node.enum !== undefined && !Array.isArray(node.enum))
7514
+ fault("enum", "must be an array of allowed values");
7515
+ if (node.required !== undefined && (!Array.isArray(node.required) || node.required.some((name) => typeof name !== "string"))) {
7516
+ fault("required", "must be an array of property names");
7517
+ }
7518
+ if (node.properties !== undefined) {
7519
+ if (!isJudgedSchemaObject(node.properties)) {
7520
+ fault("properties", "must be an object of property schemas");
7521
+ }
7522
+ else {
7523
+ for (const [name, child] of Object.entries(node.properties)) {
7524
+ steps.push({ node: child, path: judgedPath(judgedPath(step.path, "properties"), name) });
7525
+ }
7526
+ }
7527
+ }
7528
+ if (node.items !== undefined) {
7529
+ if (Array.isArray(node.items))
7530
+ fault("items", "must be one schema for every item; a list of item schemas is not supported");
7531
+ else
7532
+ steps.push({ node: node.items, path: judgedPath(step.path, "items") });
7533
+ }
7534
+ for (const keyword of ["anyOf", "oneOf"]) {
7535
+ const value = node[keyword];
7536
+ if (value === undefined)
7537
+ continue;
7538
+ if (!Array.isArray(value)) {
7539
+ fault(keyword, "must be an array of schemas");
7540
+ continue;
7541
+ }
7542
+ value.forEach((child, index) => steps.push({ node: child, path: judgedPath(judgedPath(step.path, keyword), `[${index}]`) }));
7543
+ }
7544
+ }
7545
+ for (let i = steps.length - 1; i >= 0; i--)
7546
+ work.push(steps[i]);
7547
+ }
7548
+ return out;
7549
+ }
7550
+ /**
7551
+ * The schemas an agent's model reads from its declaration (a table or one
7552
+ * JSON string): each client tool's `inputSchema` and `outputSchema`, each
7553
+ * event's `schema` and the turn context's. Never a server tool's: those are
7554
+ * its function's, judged at the function push.
7555
+ */
7556
+ export function agentDeclarationSchemas(agent) {
7557
+ const declaration = parseAgentDeclarationBlock(agent);
7558
+ if (!declaration)
7559
+ return [];
7560
+ const out = [];
7561
+ for (const tool of Array.isArray(declaration.tools) ? declaration.tools : []) {
7562
+ if (!isJudgedSchemaObject(tool) || (typeof tool.function === "string" && tool.function.trim() !== ""))
7563
+ continue;
7564
+ for (const which of ["inputSchema", "outputSchema"]) {
7565
+ if (tool[which] !== undefined)
7566
+ out.push({ subject: `agent tool "${String(tool.name)}" ${which}`, schema: tool[which] });
7567
+ }
7568
+ }
7569
+ for (const event of Array.isArray(declaration.events) ? declaration.events : []) {
7570
+ if (isJudgedSchemaObject(event) && event.schema !== undefined)
7571
+ out.push({ subject: `agent event "${String(event.name)}" schema`, schema: event.schema });
7572
+ }
7573
+ const turnContext = declaration.turnContext;
7574
+ if (isJudgedSchemaObject(turnContext) && turnContext.schema !== undefined)
7575
+ out.push({ subject: "agent turnContext.schema", schema: turnContext.schema });
7576
+ return out;
7577
+ }
7578
+ /**
7579
+ * A schema field's value as judged: `undefined` for an absent or cleared one
7580
+ * (`null`, `""`), a JSON-string spelling parsed, a string that does not parse
7581
+ * kept as it is (the engine reports it as no schema object).
7582
+ */
7583
+ function judgedSchemaValue(value) {
7584
+ if (value === undefined || value === null || value === "")
7585
+ return undefined;
7586
+ if (typeof value !== "string")
7587
+ return value;
7588
+ try {
7589
+ return JSON.parse(value);
7590
+ }
7591
+ catch {
7592
+ return value;
7593
+ }
7594
+ }
7595
+ /** A config the server would store as non-archived on Gemini: status and provider read as the write normalizes them. */
7596
+ function isLiveGemini(config) {
7597
+ return (String(config.status ?? "active").trim().toLowerCase() !== "archived" &&
7598
+ String(config.provider).trim().toLowerCase() === "gemini");
7599
+ }
7600
+ /** The reason a schema nested deeper than the translator's walk is refused with. */
7601
+ const TRANSLATOR_OVERFLOW_REASON = "is nested deeper than the translator walks; flatten the schema";
7602
+ /**
7603
+ * `translateSchemaForProvider(schema, "gemini")`, failing closed. The
7604
+ * translator recurses, so a schema nested deeper than the call stack cannot be
7605
+ * translated: it is one refusal about the whole document (`(schema)`, the
7606
+ * engine's spelling), so a schema Gemini would never be sent is refused at
7607
+ * push and at call time rather than accepted unread. Any other error is a
7608
+ * fault and propagates.
7609
+ */
7610
+ export function translateSchemaForGemini(schema) {
7611
+ try {
7612
+ return translateSchemaForProvider(schema, "gemini");
7613
+ }
7614
+ catch (error) {
7615
+ if (error instanceof RangeError) {
7616
+ return { ok: false, refusals: [{ path: "", keyword: "(schema)", reason: TRANSLATOR_OVERFLOW_REASON }] };
7617
+ }
7618
+ throw error;
7619
+ }
7620
+ }
7621
+ /** The translator's refusals for one schema: `translateSchemaForGemini`'s, or none. */
7622
+ export function translatorRefusals(schema) {
7623
+ const translated = translateSchemaForGemini(schema);
7624
+ return translated.ok === false ? translated.refusals : [];
7625
+ }
7626
+ /**
7627
+ * Every keyword of a prompt's schemas the translator or the engine would
7628
+ * refuse. The translator judges `outputSchema` when a non-archived config
7629
+ * names Gemini (case-insensitive), and each Gemini config's own
7630
+ * `outputSchema` unless that config is archived; `inputSchema` is never
7631
+ * translated, and an agent's schemas are judged by the engine only. Order:
7632
+ * `inputSchema`, `outputSchema`, the agent's schemas, then each config; per
7633
+ * schema the translator first. A top-level value that is no schema object
7634
+ * is reported once, by the engine.
7635
+ */
7636
+ export function promptSchemaDeficits(input) {
7637
+ const configs = input.configs ?? [];
7638
+ const out = [];
7639
+ const judge = (subject, field, value, translate, config) => {
7640
+ const schema = judgedSchemaValue(value);
7641
+ if (schema === undefined)
7642
+ return;
7643
+ const where = config === undefined ? { subject, field } : { subject, field, config };
7644
+ if (translate && isJudgedSchemaObject(schema)) {
7645
+ for (const refusal of translatorRefusals(schema))
7646
+ out.push({ ...where, check: "translator", provider: "gemini", ...refusal });
7647
+ }
7648
+ for (const refusal of engineSchemaRefusals(schema))
7649
+ out.push({ ...where, check: "engine", ...refusal });
7650
+ };
7651
+ judge("inputSchema", "inputSchema", input.inputSchema, false);
7652
+ judge("outputSchema", "outputSchema", input.outputSchema, configs.some(isLiveGemini));
7653
+ if (judgedSchemaValue(input.agent) !== undefined) {
7654
+ for (const { subject, schema } of agentDeclarationSchemas(input.agent)) {
7655
+ for (const refusal of engineSchemaRefusals(schema))
7656
+ out.push({ subject, field: "agent", check: "engine", ...refusal });
7657
+ }
7658
+ }
7659
+ for (const config of configs) {
7660
+ judge(`config "${config.name}" outputSchema`, "outputSchema", config.outputSchema, isLiveGemini(config), config.name);
7661
+ }
7662
+ return out;
7663
+ }
7664
+ /**
7665
+ * The fix a translator line appends: the table's for a lossy constraint, the
7666
+ * default for a keyword the translator has no reason of its own for, and none
7667
+ * where the reason already says what to write (a keyword with a reason of its
7668
+ * own, or one the translator handles by its own rule).
7669
+ */
7670
+ function translatorFix(keyword) {
7671
+ if (Object.prototype.hasOwnProperty.call(TRANSLATOR_REFUSAL_FIXES, keyword))
7672
+ return TRANSLATOR_REFUSAL_FIXES[keyword];
7673
+ if (Object.prototype.hasOwnProperty.call(GEMINI_REFUSAL_REASONS, keyword))
7674
+ return null;
7675
+ if (keyword === "(schema)" || GEMINI_STRUCTURAL_KEYWORDS.includes(keyword))
7676
+ return null;
7677
+ return TRANSLATOR_REFUSAL_FIXES["*"];
7678
+ }
7679
+ /**
7680
+ * The refusal line for one deficit: the subject, the path, the keyword, why,
7681
+ * and the fix. A translator reason with no fix of its own names what Gemini
7682
+ * needs instead (`properties`, `type`, the overflow's "flatten the schema").
7683
+ */
7684
+ export function promptSchemaRefusalLine(deficit) {
7685
+ const at = `${deficit.subject} at ${schemaPathLabel(deficit.path)}`;
7686
+ if (deficit.check === "translator") {
7687
+ const fix = translatorFix(deficit.keyword);
7688
+ return `${at}: ${deficit.keyword} cannot be translated for gemini without losing meaning — ${deficit.reason}${fix ? `. Fix: ${fix}` : ""}`;
7689
+ }
7690
+ const named = deficit.keyword === "(schema)"
7691
+ ? `the schema ${deficit.reason}`
7692
+ : deficit.reason.startsWith(`${deficit.keyword} `)
7693
+ ? deficit.reason
7694
+ : `${deficit.keyword} ${deficit.reason}`;
7695
+ return `${at}: ${named}`;
7696
+ }
7697
+ /** The code a write is refused with for one deficit. */
7698
+ export function promptSchemaDeficitCode(deficit) {
7699
+ return deficit.check === "translator" ? PROMPT_SCHEMA_NOT_TRANSLATABLE : PROMPT_SCHEMA_UNSUPPORTED_KEYWORD;
7700
+ }
7701
+ /** A refused write's `details.refusals`: one entry per deficit, in `promptSchemaDeficits` order. */
7702
+ export function promptSchemaRefusals(deficits) {
7703
+ return deficits.map((deficit) => ({
7704
+ code: promptSchemaDeficitCode(deficit),
7705
+ message: promptSchemaRefusalLine(deficit),
7706
+ subject: deficit.subject,
7707
+ field: deficit.field,
7708
+ ...(deficit.config !== undefined ? { config: deficit.config } : {}),
7709
+ path: deficit.path,
7710
+ keyword: deficit.keyword,
7711
+ }));
7712
+ }
7185
7713
  // ── src/config-surface/agent-function-change.ts ──────────────────────────
7186
7714
  /**
7187
7715
  * A change to a server function that an agent uses — issue #4441.
@@ -7743,19 +8271,6 @@ export const PROMPT_SURFACE = {
7743
8271
  writableOn: BOTH,
7744
8272
  validation: handledBy(PROMPT_HANDLER, "AdminAPI", "apply"),
7745
8273
  },
7746
- // #2652 — the CEL rule gating who may execute the prompt. Required at
7747
- // create; an explicit null/"" on update clears it (fail-closed). This
7748
- // declaration is the whole authoring channel: the admin routes' unknown
7749
- // key guard reads the same table, so it is what makes `accessRule` an
7750
- // accepted body key as well as a pulled and pushed TOML line.
7751
- {
7752
- field: "accessRule",
7753
- tomlKey: "accessRule",
7754
- type: "string",
7755
- emit: "whenSet",
7756
- writableOn: BOTH,
7757
- validation: handledBy(PROMPT_HANDLER, "AdminAPI", "apply"),
7758
- },
7759
8274
  // #3798 — an AGENT's contract: its tools, event kinds, turn context,
7760
8275
  // history selection, who answers a paused call, and its limits. One
7761
8276
  // prompt-level block because they belong to the prompt, like
@@ -7774,12 +8289,41 @@ export const PROMPT_SURFACE = {
7774
8289
  writableOn: BOTH,
7775
8290
  validation: handledBy("src/config-surface/agent-declaration.ts", "resolveAgentDeclaration", "apply"),
7776
8291
  },
8292
+ // #5249 — the prompt that judges this prompt's test cases by default,
8293
+ // authored as its KEY and resolved to the stored id at push, as #3998
8294
+ // did for a test case's `evaluatorPromptKey`. The id has no TOML
8295
+ // spelling. Present-only (intent decision): an absent key leaves the
8296
+ // stored link alone, so a tree written before this keeps every link
8297
+ // made in the web admin, and `""` clears it.
8298
+ //
8299
+ // UPDATE_ONLY because push links through the update route, after this
8300
+ // push's creates, so a prompt can name an evaluator created in the same
8301
+ // push. The create route is unchanged: it accepts the key and ignores
8302
+ // it (`requestOnlyKeys` below). The resolver needs the app's prompt
8303
+ // listing, so it is not decidable from the file alone.
8304
+ {
8305
+ field: "defaultEvaluatorPromptId",
8306
+ tomlKey: "defaultEvaluatorPromptKey",
8307
+ type: "string",
8308
+ emit: "whenSet",
8309
+ writableOn: UPDATE_ONLY,
8310
+ validation: handledBy("cli/src/commands/sync.ts", "resolvePromptEvaluatorLinks", "apply"),
8311
+ },
7777
8312
  ],
7778
8313
  notExposed: {
7779
8314
  promptId: {
7780
8315
  kind: "server-owned",
7781
8316
  note: "ULID assigned on create; never author-authored.",
7782
8317
  },
8318
+ accessRule: {
8319
+ kind: "deprecated",
8320
+ note: "The CEL rule that once gated who may execute the prompt, " +
8321
+ "retired (#4872): the only call path is a server function's " +
8322
+ "`ctx.prompts.run`, whose `authorize` decides. Still accepted on " +
8323
+ "create and update so a pre-change CLI keeps pushing, and " +
8324
+ "ignored: never parsed, stored, echoed or read. Its TOML " +
8325
+ "spelling is declared in tomlOnlyKeys.",
8326
+ },
7783
8327
  // #2803 — the OBJECT-level availability, server-owned. Distinct from
7784
8328
  // the per-version `[[configs]] status` below, which stays a TOML key:
7785
8329
  // that says which named config is retired, this says whether the
@@ -7811,16 +8355,32 @@ export const PROMPT_SURFACE = {
7811
8355
  kind: "server-owned",
7812
8356
  note: "Provenance stamp written when a prompt is copied from the catalog.",
7813
8357
  },
8358
+ // #5534 — the authored schemas and their provenance, kept beside the
8359
+ // compiled ones in the fields above. Written by the server's compile;
8360
+ // read back as the detail's `source` and `provenance`.
8361
+ schemaSource: {
8362
+ kind: "server-owned",
8363
+ note: "The authored inputSchema, outputSchema and agent of a write whose " +
8364
+ "compile inlined a ref, as one JSON object; returned as `source`.",
8365
+ },
8366
+ schemaSourceR2Key: {
8367
+ kind: "server-owned",
8368
+ note: "Where an oversized schemaSource was offloaded, under a per-write key.",
8369
+ },
8370
+ schemaProvenance: {
8371
+ kind: "server-owned",
8372
+ note: "Each schema field's pointer → ref chain map, with the h1: hash of " +
8373
+ "each inlined definition; returned as `provenance`.",
8374
+ },
8375
+ schemaProvenanceR2Key: {
8376
+ kind: "server-owned",
8377
+ note: "Where an oversized schemaProvenance was offloaded, under a per-write key.",
8378
+ },
7814
8379
  activeConfigId: {
7815
8380
  kind: "server-owned",
7816
8381
  note: "Pointer to the active AppPromptConfig. Activation is its own " +
7817
8382
  "endpoint (activatePromptConfig), not a [prompt] key.",
7818
8383
  },
7819
- defaultEvaluatorPromptId: {
7820
- kind: "server-owned",
7821
- note: "Link to the evaluator prompt, written when an evaluator is created " +
7822
- "against this prompt. Managed through the prompts API, not TOML.",
7823
- },
7824
8384
  createdBy: {
7825
8385
  kind: "server-owned",
7826
8386
  note: "Admin who created the prompt; assigned server-side.",
@@ -7835,11 +8395,25 @@ export const PROMPT_SURFACE = {
7835
8395
  },
7836
8396
  },
7837
8397
  requestOnlyKeys: {
8398
+ // #5534 — the CLI's compile of the schemas the body carries, which the
8399
+ // server recompiles and compares; never stored as sent.
8400
+ compiled: {
8401
+ note: "The compiled form of each schema field the body carries " +
8402
+ "({ inputSchema?, outputSchema?, agent? }), sent by `config push`. " +
8403
+ "The server recompiles and refuses PROMPT_SCHEMA_COMPILED_MISMATCH " +
8404
+ "when they differ.",
8405
+ },
8406
+ provenance: {
8407
+ note: "The provenance of each field in `compiled`, which the server " +
8408
+ "compares with its own; required with `compiled`.",
8409
+ },
7838
8410
  defaultEvaluatorPromptId: {
7839
- note: "Writable through the prompts API (the console links an evaluator " +
7840
- "prompt) but never through TOML, which is why it is classified " +
7841
- "`server-owned` for the sync surface and named here for the request " +
7842
- "surface. Sending it is accepted; sync never does.",
8411
+ // #5249 — the field above is update-only; the create route has always
8412
+ // accepted this key and ignored it, and still does.
8413
+ modes: ["create"],
8414
+ note: "Accepted and ignored by the create route: a create links an " +
8415
+ "evaluator only through `sourcePromptId`. `config push` links " +
8416
+ "through the update route after its creates.",
7843
8417
  },
7844
8418
  },
7845
8419
  tomlOnlyKeys: {
@@ -7853,8 +8427,27 @@ export const PROMPT_SURFACE = {
7853
8427
  "deployed — and typed by `functions codegen` — under the DECLARED " +
7854
8428
  "key (#3330).",
7855
8429
  },
8430
+ accessRule: {
8431
+ kind: "deprecated",
8432
+ note: "`accessRule = \"…\"` — retired (#4872); the calling function's " +
8433
+ "`authorize` decides who may run the prompt. Accepted so an " +
8434
+ "untouched tree still validates, never sent, and `config push` " +
8435
+ "prints the `DEPRECATED_CONFIG_KEYS` sentence once per file. " +
8436
+ "`config pull` rewrites the file without it.",
8437
+ },
7856
8438
  },
7857
8439
  responseOnlyKeys: {
8440
+ // #5534 — the authored schemas and their provenance, on the detail
8441
+ // and the write responses (not the list).
8442
+ source: {
8443
+ kind: "server-owned",
8444
+ note: "The authored schema of each field whose compile inlined a ref " +
8445
+ "(null when none did); `config pull` writes it back.",
8446
+ },
8447
+ provenance: {
8448
+ kind: "server-owned",
8449
+ note: "Each such field's pointer → ref chain map; read by `config diff` for pins.",
8450
+ },
7858
8451
  configs: {
7859
8452
  kind: "structural",
7860
8453
  note: "The prompt's AppPromptConfig rows, returned inline on the detail " +
@@ -8138,6 +8731,27 @@ export const PROMPT_SURFACE = {
8138
8731
  note: "Where an oversized userPromptTemplate was offloaded. Assigned by " +
8139
8732
  "storeField; the value round-trips through `userPromptTemplate`.",
8140
8733
  },
8734
+ // #5534 — the authored schemas and their provenance, kept beside the
8735
+ // compiled ones in the fields above. Written by the server's compile;
8736
+ // read back as the detail's `source` and `provenance`.
8737
+ schemaSource: {
8738
+ kind: "server-owned",
8739
+ note: "The authored outputSchema of a write whose compile inlined a ref, " +
8740
+ "as one JSON object; returned as `source`.",
8741
+ },
8742
+ schemaSourceR2Key: {
8743
+ kind: "server-owned",
8744
+ note: "Where an oversized schemaSource was offloaded, under a per-write key.",
8745
+ },
8746
+ schemaProvenance: {
8747
+ kind: "server-owned",
8748
+ note: "The outputSchema's pointer → ref chain map, with the h1: hash of " +
8749
+ "each inlined definition; returned as `provenance`.",
8750
+ },
8751
+ schemaProvenanceR2Key: {
8752
+ kind: "server-owned",
8753
+ note: "Where an oversized schemaProvenance was offloaded, under a per-write key.",
8754
+ },
8141
8755
  createdBy: {
8142
8756
  kind: "server-owned",
8143
8757
  note: "Admin who created the config; assigned server-side.",
@@ -8164,7 +8778,33 @@ export const PROMPT_SURFACE = {
8164
8778
  "(activatePromptConfig), never as a config-body key.",
8165
8779
  },
8166
8780
  },
8167
- responseOnlyKeys: {},
8781
+ requestOnlyKeys: {
8782
+ // #5534 — the CLI's compile of the schemas the body carries, which the
8783
+ // server recompiles and compares; never stored as sent.
8784
+ compiled: {
8785
+ note: "The compiled form of each schema field the body carries " +
8786
+ "({ outputSchema? }), sent by `config push`. " +
8787
+ "The server recompiles and refuses PROMPT_SCHEMA_COMPILED_MISMATCH " +
8788
+ "when they differ.",
8789
+ },
8790
+ provenance: {
8791
+ note: "The provenance of each field in `compiled`, which the server " +
8792
+ "compares with its own; required with `compiled`.",
8793
+ },
8794
+ },
8795
+ responseOnlyKeys: {
8796
+ // #5534 — the authored schemas and their provenance, on every config
8797
+ // response.
8798
+ source: {
8799
+ kind: "server-owned",
8800
+ note: "The authored schema of each field whose compile inlined a ref " +
8801
+ "(null when none did); `config pull` writes it back.",
8802
+ },
8803
+ provenance: {
8804
+ kind: "server-owned",
8805
+ note: "Each such field's pointer → ref chain map; read by `config diff` for pins.",
8806
+ },
8807
+ },
8168
8808
  },
8169
8809
  ],
8170
8810
  // Both of a prompt file's tables ARE field tables (`[prompt]` and the
@@ -8244,22 +8884,22 @@ export const INTEGRATION_SURFACE = {
8244
8884
  // Same create default, same reason (#2880 DSO-002): 1 MiB.
8245
8885
  serverDefault: 1048576,
8246
8886
  },
8247
- // #2631 — the CEL rule gating who may invoke the integration. Required
8248
- // at create; an explicit null/"" on update clears it (fail-closed).
8249
- {
8250
- field: "accessRule",
8251
- tomlKey: "accessRule",
8252
- type: "string",
8253
- emit: "whenSet",
8254
- writableOn: BOTH,
8255
- validation: handledBy(INTEGRATION_HANDLER, "AdminAPI", "apply"),
8256
- },
8257
8887
  ],
8258
8888
  notExposed: {
8259
8889
  integrationId: {
8260
8890
  kind: "server-owned",
8261
8891
  note: "ULID assigned on create; never author-authored.",
8262
8892
  },
8893
+ accessRule: {
8894
+ kind: "deprecated",
8895
+ note: "The CEL rule that once gated who may invoke the integration, " +
8896
+ "retired (#4872): the only call path is a server function's " +
8897
+ "`ctx.integrations.call`, decided by its `authorize` and its " +
8898
+ "`integration:<key>` capability. Still accepted on create and " +
8899
+ "update so a pre-change CLI keeps pushing, and ignored: never " +
8900
+ "parsed, stored, echoed or read. Its TOML spelling is declared " +
8901
+ "in tomlOnlyKeys.",
8902
+ },
8263
8903
  // #2803 — availability, server-owned. `draft` is gone from the model;
8264
8904
  // a stored one reads `inactive` through the canonical normalizer.
8265
8905
  status: {
@@ -8322,6 +8962,14 @@ export const INTEGRATION_SURFACE = {
8322
8962
  "takes the identity from the file name and attaches " +
8323
8963
  "`integrationKey` itself.",
8324
8964
  },
8965
+ accessRule: {
8966
+ kind: "deprecated",
8967
+ note: "`accessRule = \"…\"` — retired (#4872); the calling function's " +
8968
+ "`authorize` and `integration:<key>` capability decide. Accepted " +
8969
+ "so an untouched tree still validates, never sent, and `config " +
8970
+ "push` prints the `DEPRECATED_CONFIG_KEYS` sentence once per " +
8971
+ "file. `config pull` rewrites the file without it.",
8972
+ },
8325
8973
  },
8326
8974
  responseOnlyKeys: {},
8327
8975
  },
@@ -8335,61 +8983,33 @@ export const INTEGRATION_SURFACE = {
8335
8983
  },
8336
8984
  },
8337
8985
  };
8338
- // ── src/config-surface/webhook.ts ────────────────────────────────────────
8339
- /**
8340
- * The `webhook` configuration object's definition (issue #2644, phase 2).
8341
- *
8342
- * `webhooks/<key>.toml` carries one `[webhook]` field table plus four authored
8343
- * structures with their own channels — `[verification.<scheme>]` (the stored
8344
- * `config` blob), `[allowedIps]`, `[inputMapping]` and `[metadata]`. Each is
8345
- * declared `structural` here with the code that owns it named, so the reason is
8346
- * visible rather than implied by absence.
8347
- *
8348
- * ── Secret-adjacent fields ───────────────────────────────────────────────
8349
- * `signingSecret` is EXPOSED with a reference-only contract (#2254): the server
8350
- * returns a whole `{{secrets.KEY}}` reference or `null` and never the
8351
- * credential, which is exactly what makes `config pull` → `config push` lossless
8352
- * (#1235). `previousSigningSecret` is `notExposed: secret` — a rotation slot the
8353
- * author does not write. The derived `signingSecretStatus` / `…Health` keys are
8354
- * response-only. The coverage guard fails on a bare omission of any of these
8355
- * (`/secret|token|password|credential/i`), so none of it can be decided by
8356
- * silence.
8357
- *
8358
- * On the `validation` classifications: `createAppWebhook` / `updateAppWebhook`
8359
- * are not decomposed into per-field handlers, so a field names the shared
8360
- * validator that owns it where one exists, and `src/admin-api.ts#AdminAPI`
8361
- * otherwise.
8362
- */
8363
- const WEBHOOK_HANDLER = "src/admin-api.ts";
8364
- const WEBHOOK_CONFIG_VALIDATION = "src/app-api/services/webhook-verification/config-validation.ts";
8365
- // #3320 — the reference-only `signingSecret` rule is decidable from the value
8366
- // alone, so it moved beside the definitions where `config push`'s preflight can
8367
- // run the server's own copy of it.
8368
- const WEBHOOK_SIGNING_SECRET_RULE = "src/config-surface/webhook-signing-secret.ts";
8369
- /**
8370
- * Every rule of this object is `apply` (#3374): the standalone webhook's CLI
8371
- * path runs field-shape checks only, and everything else needs the app's state
8372
- * or the STORED row. A module-local builder, named so it cannot collide with a
8373
- * sibling's once the directory is concatenated into the artifact.
8374
- */
8375
- const webhookApplyRules = (modulePath, exportName, entries) => entries.map(([id, description]) => ({
8376
- id,
8377
- description,
8378
- stage: "apply",
8379
- handler: enforcedBy(modulePath, exportName),
8380
- }));
8381
- export const WEBHOOK_SURFACE = {
8382
- label: "webhook",
8986
+ // ── src/config-surface/blob-bucket.ts ────────────────────────────────────
8987
+ /**
8988
+ * The `blob-bucket` configuration object's definition (issue #2644, phase 2).
8989
+ *
8990
+ * `blob-buckets/<key>.toml` carries a single `[bucket]` table.
8991
+ *
8992
+ * `ttlTier` is `writableOn: ["create"]`: the update handler does not read it, so
8993
+ * the retention tier is fixed at creation. `preset` and the rule set are the two
8994
+ * halves of the access model (#1020), and the only access keys: at most one may
8995
+ * change per request, which is the controller's rule and stays there. The rule
8996
+ * set is authored by name (`ruleSetName`) and sent as `ruleSetId`, as the type
8997
+ * configs do (#4116). The id spelling in TOML (#4283) and the pre-#1020
8998
+ * `accessPolicy` spelling (#3996) are retired keys (`retired-keys.ts`).
8999
+ */
9000
+ const BLOB_BUCKET_HANDLER = "src/app-api/controllers/blob-buckets-controller.ts";
9001
+ export const BLOB_BUCKET_SURFACE = {
9002
+ label: "blob-bucket",
8383
9003
  tables: [
8384
9004
  {
8385
- tomlPath: ["webhook"],
9005
+ tomlPath: ["bucket"],
8386
9006
  repeated: false,
8387
- model: "AppWebhook",
9007
+ model: "BlobBucket",
8388
9008
  // Declaration order reproduces the pre-#2644 serializer's key order.
8389
9009
  fields: [
8390
9010
  {
8391
- field: "displayName",
8392
- tomlKey: "displayName",
9011
+ field: "name",
9012
+ tomlKey: "name",
8393
9013
  type: "string",
8394
9014
  emit: "always",
8395
9015
  writableOn: BOTH,
@@ -8404,648 +9024,29 @@ export const WEBHOOK_SURFACE = {
8404
9024
  validation: "passthrough",
8405
9025
  },
8406
9026
  {
8407
- field: "workflowKey",
8408
- tomlKey: "workflowKey",
9027
+ field: "ttlTier",
9028
+ tomlKey: "ttlTier",
8409
9029
  type: "string",
8410
9030
  emit: "always",
8411
- writableOn: BOTH,
8412
- validation: "passthrough",
9031
+ writableOn: CREATE_ONLY,
9032
+ // Immutable after create: `update` never reads it.
9033
+ validation: handledBy(BLOB_BUCKET_HANDLER, "BlobBucketsController", "apply"),
8413
9034
  },
8414
9035
  {
8415
- field: "verificationScheme",
8416
- tomlKey: "verificationScheme",
9036
+ field: "preset",
9037
+ tomlKey: "preset",
8417
9038
  type: "string",
8418
- emit: "always",
9039
+ emit: "whenSet",
8419
9040
  writableOn: BOTH,
8420
- validation: handledBy(WEBHOOK_HANDLER, "AdminAPI", "apply"),
9041
+ // #1020 — the honest access field. A rule-set-backed bucket reports
9042
+ // "custom", which is not written back as a preset.
9043
+ validation: handledBy("src/app-api/resource-types/blob-bucket.ts", "resolveBucketPreset", "apply"),
8421
9044
  },
8422
9045
  {
8423
- field: "toleranceSeconds",
8424
- tomlKey: "toleranceSeconds",
8425
- type: "number",
8426
- emit: "always",
8427
- writableOn: BOTH,
8428
- validation: handledBy(WEBHOOK_CONFIG_VALIDATION, "validateReplayProtection", "apply"),
8429
- },
8430
- {
8431
- field: "deduplicationEnabled",
8432
- tomlKey: "deduplicationEnabled",
8433
- type: "boolean",
8434
- emit: "always",
8435
- writableOn: BOTH,
8436
- validation: handledBy(WEBHOOK_CONFIG_VALIDATION, "validateReplayProtection", "apply"),
8437
- },
8438
- {
8439
- field: "deduplicationWindowMs",
8440
- tomlKey: "deduplicationWindowMs",
8441
- type: "number",
8442
- emit: "always",
8443
- writableOn: BOTH,
8444
- validation: handledBy(WEBHOOK_CONFIG_VALIDATION, "validateReplayProtection", "apply"),
8445
- },
8446
- // Per-webhook inbound body cap. Unset means the platform default
8447
- // (5 MiB), so it is omitted from TOML rather than written as a zero.
8448
- {
8449
- field: "maxBodyBytes",
8450
- tomlKey: "maxBodyBytes",
8451
- type: "number",
8452
- emit: "whenSet",
8453
- writableOn: BOTH,
8454
- validation: handledBy(WEBHOOK_CONFIG_VALIDATION, "validateMaxBodyBytes", "apply"),
8455
- },
8456
- {
8457
- field: "secretGracePeriodMs",
8458
- tomlKey: "secretGracePeriodMs",
8459
- type: "number",
8460
- emit: "always",
8461
- writableOn: BOTH,
8462
- validation: handledBy(WEBHOOK_CONFIG_VALIDATION, "normalizeSecretGracePeriodMs", "apply"),
8463
- },
8464
- // #2254 — reference-only: a whole `{{secrets.KEY}}` reference naming an
8465
- // existing app secret, and nothing else. The server never returns
8466
- // credential material here, so the reference round-trips verbatim
8467
- // (#1235) and a legacy literal is withheld (no line is written).
8468
- {
8469
- field: "signingSecret",
8470
- tomlKey: "signingSecret",
8471
- type: "string",
8472
- emit: "whenSet",
8473
- writableOn: BOTH,
8474
- validation: handledBy(WEBHOOK_SIGNING_SECRET_RULE, "validateWholeSecretReference", "apply"),
8475
- },
8476
- ],
8477
- notExposed: {
8478
- webhookId: {
8479
- kind: "server-owned",
8480
- note: "ULID assigned on create; never author-authored.",
8481
- },
8482
- // #3181 — the two fields a FUNCTION-owned row carries. Neither is ever
8483
- // authored on a `[webhook]` table: a function declares its trigger in
8484
- // its own `functions/<key>.toml`, and this file's whole surface is the
8485
- // standalone object. A hidden row is written only by
8486
- // `function-trigger-reconcile.ts`.
8487
- functionId: {
8488
- kind: "server-owned",
8489
- note: "The server function whose config owns this row (#3181). Set only " +
8490
- "by the trigger reconcile; a standalone webhook never has one, and " +
8491
- "its presence is what every hiding filter branches on.",
8492
- },
8493
- declaredSigningSecret: {
8494
- kind: "secret",
8495
- note: "The authored `{{secrets.KEY}}` reference the last function-trigger " +
8496
- "reconcile applied (#3181, D3181-004). Server-owned bookkeeping " +
8497
- "that makes an operational `rotate-secret` survive later pushes: " +
8498
- "the secret fields move only when THIS marker and the authored " +
8499
- "value disagree. Never authored, and never on a standalone row.",
8500
- },
8501
- // #2803 — availability is server-owned. As a `[webhook]` key it made
8502
- // `config push` a second writer: a file pulled before an operator
8503
- // paused the webhook put the endpoint back in service on the next
8504
- // push. `server-owned` keeps it out of the TOML surface AND out of the
8505
- // create/update request schemas, closing the tenant app-API path that
8506
- // stored `body.status` unvalidated.
8507
- status: {
8508
- kind: "server-owned",
8509
- note: "Availability (#2803): active | inactive | archived. Written only " +
8510
- "by `webhooks enable|disable` and by the delete flow's tombstone. " +
8511
- "Never authored in TOML: pull does not emit it, pull skips " +
8512
- "archived rows entirely, and a file carrying the key fails push.",
8513
- },
8514
- appId: {
8515
- kind: "server-owned",
8516
- note: "Tenant scope, taken from the route; never on the wire.",
8517
- },
8518
- webhookKey: {
8519
- kind: "structural",
8520
- // Both modes: the update handlers ignore it, but the shipped CLI
8521
- // attaches it to every webhook update body (see integration.ts).
8522
- requestModes: ["create", "update"],
8523
- note: "The webhook's identity. Comes from the TOML file name and is " +
8524
- "attached by the caller, not spread from the [webhook] table. Its " +
8525
- "TOML spelling is declared in tomlOnlyKeys as `key`.",
8526
- },
8527
- workflowId: {
8528
- kind: "server-owned",
8529
- note: "Resolved from `workflowKey` server-side; the author writes the key.",
8530
- },
8531
- previousSigningSecret: {
8532
- kind: "secret",
8533
- note: "#2383 rotation slot. Written by the rotate endpoint, never by an " +
8534
- "author, and reported through the derived signingSecretStatus " +
8535
- "fields rather than as a TOML key.",
8536
- },
8537
- secretRotatedAt: {
8538
- kind: "server-owned",
8539
- note: "Stamped by the rotate endpoint; reported, never authored.",
8540
- },
8541
- config: {
8542
- kind: "structural",
8543
- note: "Per-scheme verification settings. Authored as the top-level " +
8544
- "[verification.<scheme>] table and converted by " +
8545
- "webhookConfigToTomlTable / tomlTableToWebhookConfig, whose stored " +
8546
- "shape differs per scheme (#2109), not as a [webhook] key.",
8547
- },
8548
- allowedIpCidrs: {
8549
- kind: "structural",
8550
- note: "Authored as the top-level [allowedIps] table (`cidrs = [...]`) and " +
8551
- "stored as a JSON string, not as a [webhook] key.",
8552
- },
8553
- inputMapping: {
8554
- kind: "structural",
8555
- note: "Authored as the top-level [inputMapping] table and stored as a " +
8556
- "JSON string, not as a [webhook] key.",
8557
- },
8558
- metadata: {
8559
- kind: "structural",
8560
- note: "Authored as the top-level [metadata] table and stored as a JSON " +
8561
- "string, not as a [webhook] key.",
8562
- },
8563
- handshakeRules: {
8564
- kind: "structural",
8565
- note: "Provider handshake/challenge rules, validated by " +
8566
- "src/app-api/services/webhook-handshake.ts. Accepted by the admin " +
8567
- "API but not part of the TOML surface — `config push` never sends it, " +
8568
- "so the stored value is left alone rather than cleared.",
8569
- },
8570
- lastTriggeredAt: {
8571
- kind: "server-owned",
8572
- note: "Stamped by the receiver on delivery; reported, never authored.",
8573
- },
8574
- createdBy: {
8575
- kind: "server-owned",
8576
- note: "User who created the webhook; assigned server-side.",
8577
- },
8578
- createdAt: {
8579
- kind: "server-owned",
8580
- note: "Timestamp, assigned server-side.",
8581
- },
8582
- modifiedAt: {
8583
- kind: "server-owned",
8584
- note: "Timestamp, assigned server-side.",
8585
- },
8586
- },
8587
- tomlOnlyKeys: {
8588
- key: {
8589
- kind: "structural",
8590
- note: "The webhook key. `config pull` writes it for readability; push takes " +
8591
- "the identity from the file name and attaches `webhookKey` itself.",
8592
- },
8593
- },
8594
- responseOnlyKeys: {
8595
- signingSecretStatus: {
8596
- kind: "server-owned",
8597
- note: "#2254 — derived disclosure state of the stored secret (reference / " +
8598
- "withheld literal / unset). Computed at serialize time; read-only.",
8599
- },
8600
- previousSigningSecretStatus: {
8601
- kind: "server-owned",
8602
- note: "Same derivation for the rotation slot. Read-only.",
8603
- },
8604
- signingSecretHealth: {
8605
- kind: "server-owned",
8606
- note: "#2383 — derived health report on the stored secret. Read-only.",
8607
- },
8608
- previousSigningSecretHealth: {
8609
- kind: "server-owned",
8610
- note: "Same report for the rotation slot. Read-only.",
8611
- },
8612
- },
8613
- },
8614
- ],
8615
- tomlDocumentKeys: {
8616
- verification: {
8617
- kind: "structural",
8618
- note: "The `[verification.<scheme>]` table carrying the scheme's settings " +
8619
- "(#2109). Converted to/from the stored `config` blob by " +
8620
- "webhookConfigToTomlTable / tomlTableToWebhookConfig.",
8621
- },
8622
- allowedIps: {
8623
- kind: "structural",
8624
- note: "`[allowedIps] cidrs = [...]` — the source allow-list, stored as the " +
8625
- "JSON string `allowedIpCidrs`.",
8626
- },
8627
- inputMapping: {
8628
- kind: "structural",
8629
- note: "The authored payload mapping, stored as the JSON string " +
8630
- "`inputMapping`; a table rather than a [webhook] key so it can nest.",
8631
- },
8632
- metadata: {
8633
- kind: "structural",
8634
- note: "The webhook's authored metadata table, stored as the JSON string " +
8635
- "`metadata`. Unrelated to the declared-access manifest of the type " +
8636
- "configs, which spells `[metadata]` the same way.",
8637
- },
8638
- },
8639
- // ── Cross-field rules (#3374) ─────────────────────────────────────────────
8640
- //
8641
- // Nothing here is `preflight`. Stage is a property of the (surface, rule)
8642
- // pair, and on THIS surface even the file-decidable signing-secret rule is
8643
- // enforced mid-apply: the standalone webhook CLI path runs no signing-secret
8644
- // preflight (`function-sync.ts` is that rule's only CLI caller), and an
8645
- // update that omits `signingSecret` keeps the stored one, so a local check
8646
- // would need update-retains-stored-secret semantics the intent lists as a
8647
- // non-goal. Declaring `preflight` would promise a refusal that lands after
8648
- // sibling entities are written.
8649
- //
8650
- // The residue, named: `webhook-verification/config-validation.ts` is not a
8651
- // rules module (it builds forty-odd refusals, most single-field). Its
8652
- // cross-field refusals — scheme × config, replay protection, config secret
8653
- // references — reach a write only through `validateWebhookSettings`, which
8654
- // re-builds each under its own pipeline id, so they are declared here under
8655
- // those ids; the module itself is unmigrated.
8656
- crossFieldRules: [
8657
- ...webhookApplyRules(WEBHOOK_SIGNING_SECRET_RULE, "validateSigningSecretDeclaration", [
8658
- [
8659
- "signing-secret-required",
8660
- "A scheme that verifies with an HMAC secret must be given a " +
8661
- "`signingSecret`. The same handler the function surface runs in " +
8662
- "preflight; here it runs at apply because the standalone CLI path " +
8663
- "never calls it and an update preserves an omitted stored secret.",
8664
- ],
8665
- [
8666
- "whole-secret-reference",
8667
- "A supplied `signingSecret` is a whole `{{secrets.KEY}}` reference " +
8668
- "and nothing else — a literal is never stored (#2254).",
8669
- ],
8670
- [
8671
- "signing-secret-not-supported",
8672
- "A scheme whose key material lives in its config (`discord`, `jwt`, " +
8673
- "`plaid`) or that verifies nothing (`none`) refuses a `signingSecret`.",
8674
- ],
8675
- ]),
8676
- ...webhookApplyRules("src/app-api/services/webhook-limits.ts", "validateWebhookCountUnderCap", [
8677
- [
8678
- "webhook-cap",
8679
- "An app holds at most fifty webhook rows, archived included; a " +
8680
- "create that would add one past the cap is refused with " +
8681
- "`WEBHOOK_LIMIT_REACHED` (#2232). Read early by `config push` as an " +
8682
- "advisory check; the server decides.",
8683
- ],
8684
- ]),
8685
- ...webhookApplyRules("src/app-api/services/webhook-settings-validation.ts", "validateWebhookSettings", [
8686
- ["verification-scheme-required", "A webhook names its `verificationScheme`."],
8687
- ["verification-scheme-value", "The scheme is one the receiver knows."],
8688
- [
8689
- "verification-config",
8690
- "The scheme's `config` is valid for that scheme under this " +
8691
- "environment's JWKS policy, and carries no literal credential.",
8692
- ],
8693
- [
8694
- "replay-protection",
8695
- "A signed scheme keeps deduplication on, with a window and tolerance " +
8696
- "in range and long enough to cover the signature's freshness window.",
8697
- ],
8698
- [
8699
- "signing-secret-exists",
8700
- "The app secret a `signingSecret` reference names must exist, so a " +
8701
- "missing key fails the write rather than the first delivery.",
8702
- ],
8703
- [
8704
- "verification-config-secrets-exist",
8705
- "Every secret reference the active scheme's `config` resolves at " +
8706
- "delivery must name an existing app secret.",
8707
- ],
8708
- ]),
8709
- ...webhookApplyRules("src/app-api/services/webhook-verification/signing-secret-migration.ts", "validateSigningSecretMigration", [
8710
- [
8711
- "signing-secret-migration",
8712
- "A row whose STORED `signingSecret` is still a legacy literal cannot " +
8713
- "be updated until the write migrates it to a reference (#2332); " +
8714
- "gated on the scheme and status the row will end up with.",
8715
- ],
8716
- [
8717
- "signing-secret-migration-malformed",
8718
- "The same gate for a stored value carrying reference syntax that does " +
8719
- "not resolve — every signed delivery is already failing, and the " +
8720
- "message says so.",
8721
- ],
8722
- ]),
8723
- ],
8724
- };
8725
- // ── src/config-surface/cron-trigger.ts ───────────────────────────────────
8726
- /**
8727
- * The `cron-trigger` configuration object's definition (issue #2644, phase 2).
8728
- *
8729
- * `cron-triggers/<key>.toml` carries one `[cronTrigger]` field table plus the
8730
- * top-level `[rootInput]` and `[inputMapping]` tables, which are authored JSON
8731
- * structures with their own normalizer and are declared `structural`.
8732
- *
8733
- * `state` is classified `structural` (update-only), not a field (#2645):
8734
- * pausing moved onto the `operationallyDisabled` toggle written by
8735
- * `cron-triggers pause|resume`, so `state` left the TOML surface — pull does
8736
- * not emit it, and push REJECTS a file that still carries the line (with
8737
- * guidance naming the pause verbs; see `RETIRED_TOML_KEYS` in the CLI's
8738
- * `commands/sync.ts`) — while the update handler keeps reading it for the
8739
- * console.
8740
- */
8741
- const CRON_TRIGGER_HANDLER = "src/app-api/controllers/cron-triggers-controller.ts";
8742
- export const CRON_TRIGGER_SURFACE = {
8743
- label: "cron-trigger",
8744
- tables: [
8745
- {
8746
- tomlPath: ["cronTrigger"],
8747
- repeated: false,
8748
- model: "CronTrigger",
8749
- // Declaration order reproduces the pre-#2644 serializer's key order.
8750
- fields: [
8751
- {
8752
- field: "displayName",
8753
- tomlKey: "displayName",
8754
- type: "string",
8755
- emit: "always",
8756
- writableOn: BOTH,
8757
- validation: "passthrough",
8758
- },
8759
- {
8760
- field: "description",
8761
- tomlKey: "description",
8762
- type: "string",
8763
- emit: "whenSet",
8764
- writableOn: BOTH,
8765
- validation: "passthrough",
8766
- },
8767
- {
8768
- field: "cron",
8769
- tomlKey: "cron",
8770
- type: "string",
8771
- emit: "always",
8772
- writableOn: BOTH,
8773
- // #3376 — re-pointed from `src/cron-parser.ts`, which now only
8774
- // re-exports the parser: the drift guard resolves `export function
8775
- // <name>` in the named module's OWN source, so the declaring module
8776
- // is the only one it can name.
8777
- //
8778
- // `apply`, not `preflight`, even though the predicate is vendored
8779
- // and the rule is decidable from the file: no CLI check reads a
8780
- // standalone `cron-triggers/<key>.toml`'s VALUES.
8781
- // `collectConfigFileValidationErrors` is definition-driven and
8782
- // cannot dispatch through a `handledBy` string (#1976), so this
8783
- // file still fails at apply with the controller's message.
8784
- // `preflight` would make the registry promise a refusal that in
8785
- // fact lands mid-apply — and the reachability walker could not
8786
- // catch the lie, because the FUNCTION leg reaches this same
8787
- // predicate. Building that standalone leg, with its `config diff`
8788
- // twin, is a finding for #3379.
8789
- validation: handledBy("src/config-surface/cron-expression.ts", "cronExpressionError", "apply"),
8790
- },
8791
- {
8792
- field: "timezone",
8793
- tomlKey: "timezone",
8794
- type: "string",
8795
- emit: "always",
8796
- writableOn: BOTH,
8797
- // Validated against Intl; unset reads as "UTC". #3376 named the
8798
- // predicate itself rather than the controller class: the probe the
8799
- // three sites used to spell out is one function now, and this is
8800
- // one of the two surfaces that own it. `apply` for the same reason
8801
- // as `cron` above — no standalone CLI preflight runs it (#3379).
8802
- validation: handledBy("src/config-surface/cron-expression.ts", "isValidTimezone", "apply"),
8803
- // `cron-triggers-controller.ts` stores `timezone || "UTC"`, so a file
8804
- // that omits the key describes a trigger running in UTC — compared
8805
- // and pushed as that, rather than as a difference no push can clear
8806
- // (#2880 DSO-002).
8807
- serverDefault: "UTC",
8808
- },
8809
- {
8810
- field: "workflowKey",
8811
- tomlKey: "workflowKey",
8812
- type: "string",
8813
- emit: "always",
8814
- writableOn: BOTH,
8815
- // #1002 — a reserved `__internal.` key is rejected at save time.
8816
- validation: handledBy(CRON_TRIGGER_HANDLER, "CronTriggersController", "apply"),
8817
- },
8818
- {
8819
- field: "overlapPolicy",
8820
- tomlKey: "overlapPolicy",
8821
- type: "string",
8822
- emit: "always",
8823
- writableOn: BOTH,
8824
- // skip | allow.
8825
- validation: handledBy(CRON_TRIGGER_HANDLER, "CronTriggersController", "apply"),
8826
- // Same store-time default as `timezone` (#2880 DSO-002).
8827
- serverDefault: "skip",
8828
- },
8829
- ],
8830
- notExposed: {
8831
- // #3181 — a function-declared cron entry creates a hidden row keyed
8832
- // `<functionKey>:<name>`, and this is the discriminator every standalone
8833
- // surface hides on. Never authored on a `[cronTrigger]` table: the
8834
- // declaration lives in the function's own file.
8835
- functionId: {
8836
- kind: "server-owned",
8837
- note: "The server function whose config owns this row (#3181). Written " +
8838
- "only by the trigger reconcile; a standalone trigger never has one.",
8839
- },
8840
- // #2803 — the ONE availability control, server-owned. Written only by
8841
- // `cron-triggers enable|disable`, the delete flow (the `archived`
8842
- // tombstone) and the alarm's error-pause path. `server-owned` keeps it
8843
- // out of both the TOML surface and the create/update request schemas,
8844
- // so no configuration write can change availability as a side effect.
8845
- status: {
8846
- kind: "server-owned",
8847
- note: "Availability (#2803): active | inactive | archived. Written only " +
8848
- "by `cron-triggers enable|disable`, the delete flow and the " +
8849
- "error-pause path. Never authored in TOML: pull does not emit it " +
8850
- "and a file that still carries the key fails push.",
8851
- },
8852
- // #2645 criterion 9 moved pausing off `state`; #2803 retired the field
8853
- // entirely. It mixed lifecycle (`archived`, `error_paused`) with
8854
- // availability (`paused`), which is what made two writers possible in
8855
- // the first place. `server-owned` now, not `structural` with an
8856
- // update-only mode: the console's carve-out is gone with it, so the
8857
- // generic update rejects a supplied `state` exactly as create always
8858
- // did.
8859
- state: {
8860
- kind: "server-owned",
8861
- note: "DEPRECATED (#2803), superseded by `status`. Read only by " +
8862
- "`canonicalCronStatus()`; normalized back to `active` by " +
8863
- "`cron-triggers enable`. Never authored in TOML and never accepted " +
8864
- "on the wire.",
8865
- },
8866
- operationallyDisabled: {
8867
- kind: "server-owned",
8868
- note: "DEPRECATED (#2803), superseded by `status`. The #2645 operational " +
8869
- "toggle, cleared by `cron-triggers enable|disable` as rows are " +
8870
- "touched. Never authored in TOML and never accepted on the config " +
8871
- "create/update wire.",
8872
- },
8873
- triggerId: {
8874
- kind: "server-owned",
8875
- note: "ULID assigned on create; never author-authored.",
8876
- },
8877
- appId: {
8878
- kind: "server-owned",
8879
- note: "Tenant scope, taken from the route; never on the wire.",
8880
- },
8881
- triggerKey: {
8882
- kind: "structural",
8883
- // Both modes: the update handler ignores it, but the shipped CLI
8884
- // attaches it to every cron-trigger update body (see integration.ts).
8885
- requestModes: ["create", "update"],
8886
- note: "The trigger's identity. Comes from the TOML file name and is " +
8887
- "attached by the caller, not spread from the [cronTrigger] table. " +
8888
- "Its TOML spelling is declared in tomlOnlyKeys as `key`.",
8889
- },
8890
- rootInput: {
8891
- kind: "structural",
8892
- note: "Authored as the top-level [rootInput] table and stored as a JSON " +
8893
- "string (normalizeJsonString), not as a [cronTrigger] key.",
8894
- },
8895
- inputMapping: {
8896
- kind: "structural",
8897
- note: "Authored as the top-level [inputMapping] table and stored as a " +
8898
- "JSON string (normalizeJsonString), not as a [cronTrigger] key.",
8899
- },
8900
- lastError: {
8901
- kind: "server-owned",
8902
- note: "Last fire failure, written by the trigger DO and cleared on resume.",
8903
- },
8904
- lastTriggeredAt: {
8905
- kind: "server-owned",
8906
- note: "Stamped on fire; reported, never authored.",
8907
- },
8908
- lastTriggeredRunId: {
8909
- kind: "server-owned",
8910
- note: "Run started by the last fire; reported, never authored.",
8911
- },
8912
- skippedCount: {
8913
- kind: "server-owned",
8914
- note: "Runtime counter maintained by the trigger DO.",
8915
- },
8916
- firedCount: {
8917
- kind: "server-owned",
8918
- note: "Runtime counter maintained by the trigger DO.",
8919
- },
8920
- consecutiveNotActiveCount: {
8921
- kind: "server-owned",
8922
- note: "Runtime counter behind the auto-pause rule; DO-maintained.",
8923
- },
8924
- nextFireAt: {
8925
- kind: "server-owned",
8926
- note: "Projected next fire, computed from the schedule by the DO.",
8927
- },
8928
- createdBy: {
8929
- kind: "server-owned",
8930
- note: "User who created the trigger; assigned server-side.",
8931
- },
8932
- createdAt: {
8933
- kind: "server-owned",
8934
- note: "Timestamp, assigned server-side.",
8935
- },
8936
- modifiedAt: {
8937
- kind: "server-owned",
8938
- note: "Timestamp, assigned server-side.",
8939
- },
8940
- },
8941
- requestOnlyKeys: {
8942
- key: {
8943
- // CREATE only: `update` never reads it — the trigger is addressed by
8944
- // id in the path, and its key is immutable — so a `key` sent on
8945
- // update is a 400 rather than a silently ignored rename.
8946
- modes: CREATE_ONLY,
8947
- note: "Alias for `triggerKey` on create, accepted by the controller " +
8948
- "(`triggerKey || key`) since before sync existed. Declared so the " +
8949
- "generated request schema keeps accepting a client that uses it.",
8950
- },
8951
- name: {
8952
- note: "Alias for `displayName`, accepted on create and update " +
8953
- "(`displayName ?? name`). Same reason as `key`.",
8954
- },
8955
- },
8956
- tomlOnlyKeys: {
8957
- key: {
8958
- kind: "structural",
8959
- note: "The trigger key. `config pull` writes it for readability; push takes " +
8960
- "the identity from the file name and attaches `triggerKey` itself.",
8961
- },
8962
- },
8963
- responseOnlyKeys: {
8964
- runtime: {
8965
- kind: "server-owned",
8966
- note: "DO-derived schedule status (`scheduledAlarm` / `scheduledAlarmAt`) " +
8967
- "attached to the detail response. Computed, never persisted here.",
8968
- },
8969
- },
8970
- },
8971
- ],
8972
- tomlDocumentKeys: {
8973
- rootInput: {
8974
- kind: "structural",
8975
- note: "The authored root input for each fire, stored as the JSON string " +
8976
- "`rootInput` (normalizeJsonString).",
8977
- },
8978
- inputMapping: {
8979
- kind: "structural",
8980
- note: "The authored input mapping, stored as the JSON string `inputMapping` " +
8981
- "(normalizeJsonString).",
8982
- },
8983
- },
8984
- };
8985
- // ── src/config-surface/blob-bucket.ts ────────────────────────────────────
8986
- /**
8987
- * The `blob-bucket` configuration object's definition (issue #2644, phase 2).
8988
- *
8989
- * `blob-buckets/<key>.toml` carries a single `[bucket]` table.
8990
- *
8991
- * `ttlTier` is `writableOn: ["create"]`: the update handler does not read it, so
8992
- * the retention tier is fixed at creation. `preset` and the rule set are the two
8993
- * halves of the access model (#1020), and the only access keys: at most one may
8994
- * change per request, which is the controller's rule and stays there. The rule
8995
- * set is authored by name (`ruleSetName`) and sent as `ruleSetId`, as the type
8996
- * configs do (#4116). The id spelling in TOML (#4283) and the pre-#1020
8997
- * `accessPolicy` spelling (#3996) are retired keys (`retired-keys.ts`).
8998
- */
8999
- const BLOB_BUCKET_HANDLER = "src/app-api/controllers/blob-buckets-controller.ts";
9000
- export const BLOB_BUCKET_SURFACE = {
9001
- label: "blob-bucket",
9002
- tables: [
9003
- {
9004
- tomlPath: ["bucket"],
9005
- repeated: false,
9006
- model: "BlobBucket",
9007
- // Declaration order reproduces the pre-#2644 serializer's key order.
9008
- fields: [
9009
- {
9010
- field: "name",
9011
- tomlKey: "name",
9012
- type: "string",
9013
- emit: "always",
9014
- writableOn: BOTH,
9015
- validation: "passthrough",
9016
- },
9017
- {
9018
- field: "description",
9019
- tomlKey: "description",
9020
- type: "string",
9021
- emit: "whenSet",
9022
- writableOn: BOTH,
9023
- validation: "passthrough",
9024
- },
9025
- {
9026
- field: "ttlTier",
9027
- tomlKey: "ttlTier",
9028
- type: "string",
9029
- emit: "always",
9030
- writableOn: CREATE_ONLY,
9031
- // Immutable after create: `update` never reads it.
9032
- validation: handledBy(BLOB_BUCKET_HANDLER, "BlobBucketsController", "apply"),
9033
- },
9034
- {
9035
- field: "preset",
9036
- tomlKey: "preset",
9037
- type: "string",
9038
- emit: "whenSet",
9039
- writableOn: BOTH,
9040
- // #1020 — the honest access field. A rule-set-backed bucket reports
9041
- // "custom", which is not written back as a preset.
9042
- validation: handledBy("src/app-api/resource-types/blob-bucket.ts", "resolveBucketPreset", "apply"),
9043
- },
9044
- {
9045
- field: "ruleSetId",
9046
- tomlKey: "ruleSetName",
9047
- type: "string",
9048
- emit: "whenSet",
9046
+ field: "ruleSetId",
9047
+ tomlKey: "ruleSetName",
9048
+ type: "string",
9049
+ emit: "whenSet",
9049
9050
  writableOn: BOTH,
9050
9051
  // Authored as a name, sent as an id (#4116), so a tree copied into
9051
9052
  // another app binds that app's rule set. Existence-checked against
@@ -9387,12 +9388,106 @@ export const DATABASE_TYPE_SURFACE = {
9387
9388
  kind: "server-owned",
9388
9389
  note: "Timestamp, assigned server-side.",
9389
9390
  },
9390
- createdBy: {
9391
- kind: "server-owned",
9392
- note: "User who created the config; assigned server-side.",
9391
+ createdBy: {
9392
+ kind: "server-owned",
9393
+ note: "User who created the config; assigned server-side.",
9394
+ },
9395
+ },
9396
+ tomlOnlyKeys: {},
9397
+ requestOnlyKeys: {},
9398
+ responseOnlyKeys: {},
9399
+ },
9400
+ ],
9401
+ tomlDocumentKeys: {
9402
+ models: {
9403
+ kind: "structural",
9404
+ note: "#666 — the `[models.<Name>.fields.*]` blocks, re-serialized into the " +
9405
+ "stored `schema` TOML string on push and merged back on pull.",
9406
+ },
9407
+ triggers: {
9408
+ kind: "structural",
9409
+ note: "The type's authored trigger table, stored on the type config as " +
9410
+ "`triggers` and validated server-side.",
9411
+ },
9412
+ ...DECLARED_ACCESS_MANIFEST_KEYS,
9413
+ },
9414
+ };
9415
+ // ── src/config-surface/db3-type.ts ───────────────────────────────────────
9416
+ /**
9417
+ * The `db3-type` configuration object's definition (#4802, project
9418
+ * `db3-databases` phase 6).
9419
+ *
9420
+ * `db3-types/<name>.toml` is a db3 type: the `DatabaseTypeConfig` row a
9421
+ * database type is, read by db3s. One namespace, so the file's surface is the
9422
+ * database type file's with two differences: the type is named by `[type]
9423
+ * name`, where a database type file says `databaseType` (a retired spelling
9424
+ * here, `retired-keys.ts`), and it takes no rule set (#5993): nothing
9425
+ * evaluates one for a db3 type, whose management is for app admins and
9426
+ * owners, so `ruleSetName` and `ruleSetId` are refused here with that
9427
+ * sentence. The `[models.*]`, `[triggers]` and `[metadata]` /
9428
+ * `secrets` sub-trees are the database type's, kept by the validators that
9429
+ * own them; a db3 ignores the manifest. `config push` applies the file with
9430
+ * `PUT db3-types/:name`, which pushes the new revision to every db3 of the
9431
+ * type.
9432
+ */
9433
+ const DB3_TYPES_HANDLER = "src/app-api/controllers/db3-types-controller.ts";
9434
+ const LEGACY_TYPE_TABLE = DATABASE_TYPE_SURFACE.tables[0];
9435
+ export const DB3_TYPE_SURFACE = {
9436
+ label: "db3-type",
9437
+ tables: [
9438
+ {
9439
+ tomlPath: ["type"],
9440
+ repeated: false,
9441
+ model: "DatabaseTypeConfig",
9442
+ fields: [
9443
+ {
9444
+ field: "databaseType",
9445
+ tomlKey: "name",
9446
+ type: "string",
9447
+ emit: "always",
9448
+ writableOn: CREATE_ONLY,
9449
+ // The type's identity: taken from the file name's route segment on
9450
+ // a push, `#`-free.
9451
+ validation: handledBy(DB3_TYPES_HANDLER, "Db3TypesController", "apply"),
9452
+ },
9453
+ {
9454
+ field: "autoPopulatedFields",
9455
+ tomlKey: "autoPopulatedFields",
9456
+ type: "json",
9457
+ emit: "whenSet",
9458
+ writableOn: BOTH,
9459
+ validation: handledBy(DB3_TYPES_HANDLER, "Db3TypesController", "apply"),
9460
+ },
9461
+ {
9462
+ field: "timestamps",
9463
+ tomlKey: "timestamps",
9464
+ type: "json",
9465
+ emit: "whenSet",
9466
+ writableOn: BOTH,
9467
+ validation: handledBy(DB3_TYPES_HANDLER, "Db3TypesController", "apply"),
9468
+ },
9469
+ ],
9470
+ // A copy: the database type table's own classification stays as it is.
9471
+ notExposed: {
9472
+ ...LEGACY_TYPE_TABLE.notExposed,
9473
+ ruleSetId: {
9474
+ kind: "structural",
9475
+ // Never in a `PUT db3-types/:name` body: the route refuses a bound one.
9476
+ requestModes: [],
9477
+ note: "The database type's rule set, authored as `ruleSetName` in " +
9478
+ "`database-type-configs/` only. A db3 type takes none: nothing " +
9479
+ "evaluates it, and managing a type is for app admins and owners.",
9480
+ },
9481
+ },
9482
+ tomlOnlyKeys: {
9483
+ models: {
9484
+ kind: "structural",
9485
+ note: "The models this type holds that another file of `db3-types/` " +
9486
+ "declares, by name: `models = [\"securities\"]`. `config push` " +
9487
+ "copies each named `[models.<name>]` declaration into the pushed " +
9488
+ "`schema`, so the server never sees the key.",
9393
9489
  },
9394
9490
  },
9395
- tomlOnlyKeys: {},
9396
9491
  requestOnlyKeys: {},
9397
9492
  responseOnlyKeys: {},
9398
9493
  },
@@ -9400,16 +9495,22 @@ export const DATABASE_TYPE_SURFACE = {
9400
9495
  tomlDocumentKeys: {
9401
9496
  models: {
9402
9497
  kind: "structural",
9403
- note: "#666 — the `[models.<Name>.fields.*]` blocks, re-serialized into the " +
9404
- "stored `schema` TOML string on push and merged back on pull.",
9498
+ note: "The `[models.<Name>.fields.*]` blocks: the declarations a db3 of the " +
9499
+ "type installs, re-serialized into the stored `schema` TOML string on " +
9500
+ "push and merged back on pull.",
9405
9501
  },
9406
9502
  triggers: {
9407
9503
  kind: "structural",
9408
- note: "The type's authored trigger table, stored on the type config as " +
9409
- "`triggers` and validated server-side.",
9504
+ note: "The type's triggers, `[triggers.<Model>] triggers = [...]`, each " +
9505
+ "setting fields (`set`) or refusing the write (`refuse`), validated " +
9506
+ "server-side.",
9410
9507
  },
9411
9508
  ...DECLARED_ACCESS_MANIFEST_KEYS,
9412
9509
  },
9510
+ noCrossFieldRules: {
9511
+ note: "Every rule of a db3 type is a database type's: the type routes' own " +
9512
+ "validators judge the body, and each db3's room judges what it installs.",
9513
+ },
9413
9514
  };
9414
9515
  // ── src/config-surface/rule-set.ts ───────────────────────────────────────
9415
9516
  /**
@@ -9427,6 +9528,33 @@ export const DATABASE_TYPE_SURFACE = {
9427
9528
  * fixed at creation.
9428
9529
  */
9429
9530
  const RULE_SET_HANDLER = "src/app-api/controllers/rule-sets-controller.ts";
9531
+ /**
9532
+ * Rule-set resource types that no longer exist (#4959), with the one refusal
9533
+ * both the rule-set routes and `config push`'s preflight answer for a set of
9534
+ * that type, so the two cannot drift.
9535
+ *
9536
+ * `lock` — locks are server-function-only, and the calling function's
9537
+ * `authorize` decides who may lock which key. A stored row can still be listed
9538
+ * and deleted; nothing evaluates it.
9539
+ */
9540
+ export const RETIRED_RULE_SET_RESOURCE_TYPES = {
9541
+ lock: {
9542
+ code: "LOCK_RULE_SET_RETIRED",
9543
+ message: "`lock` is no longer a rule-set resource type. Locks are " +
9544
+ "server-function-only: the calling function's `authorize` decides who " +
9545
+ "may lock which key, and nothing evaluates a lock rule. Delete " +
9546
+ "`rule-sets/<name>.toml` and run `primitive config push --prune` to " +
9547
+ "remove this rule set.",
9548
+ },
9549
+ };
9550
+ /** The retirement for `resourceType`, or `null` for a live type. */
9551
+ export function retiredRuleSetResourceType(resourceType) {
9552
+ if (typeof resourceType !== "string")
9553
+ return null;
9554
+ return Object.prototype.hasOwnProperty.call(RETIRED_RULE_SET_RESOURCE_TYPES, resourceType)
9555
+ ? RETIRED_RULE_SET_RESOURCE_TYPES[resourceType]
9556
+ : null;
9557
+ }
9430
9558
  export const RULE_SET_SURFACE = {
9431
9559
  label: "rule-set",
9432
9560
  tables: [
@@ -9509,178 +9637,6 @@ export const RULE_SET_SURFACE = {
9509
9637
  },
9510
9638
  },
9511
9639
  };
9512
- // ── src/config-surface/group-type-config.ts ──────────────────────────────
9513
- /**
9514
- * The `group-type-config` configuration object's definition (issue #2644,
9515
- * phase 3).
9516
- *
9517
- * `group-type-configs/<groupType>.toml` carries a single `[groupTypeConfig]`
9518
- * table, plus the declared-access manifest's top-level `[metadata]` / `secrets`
9519
- * fragments — which are `structural`: authored elsewhere in the file, with
9520
- * their own validator (`validateDeclaredAccessManifest` locally,
9521
- * `validateManifestShape` server-side).
9522
- *
9523
- * The rule-set reference is stored as `ruleSetId` but AUTHORED as
9524
- * `ruleSetName`, because a name is portable across apps and an id is not. The
9525
- * name → id resolution is the CLI's (`config push` resolves against the app's
9526
- * rule sets); the server validates that the id exists and has
9527
- * `resourceType: "group"`. The id spelling is refused on push (#3997), with
9528
- * the guidance in `retired-keys.ts`.
9529
- */
9530
- const GROUP_TYPE_HANDLER = "src/app-api/controllers/group-type-config-controller.ts";
9531
- export const GROUP_TYPE_CONFIG_SURFACE = {
9532
- label: "group-type-config",
9533
- tables: [
9534
- {
9535
- tomlPath: ["groupTypeConfig"],
9536
- repeated: false,
9537
- model: "GroupTypeConfig",
9538
- // Declaration order reproduces the pre-#2644 serializer's key order.
9539
- fields: [
9540
- {
9541
- field: "groupType",
9542
- tomlKey: "groupType",
9543
- type: "string",
9544
- emit: "always",
9545
- writableOn: CREATE_ONLY,
9546
- // The config's identity: required and `#`-free on create, taken from
9547
- // the URL on update.
9548
- validation: handledBy(GROUP_TYPE_HANDLER, "GroupTypeConfigController", "apply"),
9549
- },
9550
- {
9551
- field: "ruleSetId",
9552
- tomlKey: "ruleSetName",
9553
- type: "string",
9554
- emit: "always",
9555
- writableOn: BOTH,
9556
- // Authored as a name, sent as an id; existence and resourceType are
9557
- // checked server-side, and an empty value clears the reference. The
9558
- // id spelling is retired in TOML (#3997): `retired-keys.ts`,
9559
- // `groupTypeConfig`.
9560
- validation: handledBy(GROUP_TYPE_HANDLER, "GroupTypeConfigController", "apply"),
9561
- },
9562
- {
9563
- field: "autoAddCreator",
9564
- tomlKey: "autoAddCreator",
9565
- type: "boolean",
9566
- emit: "always",
9567
- writableOn: BOTH,
9568
- // Defaults to `true` when absent on create, and is coerced with `!!`
9569
- // on update — not a stored-as-is passthrough.
9570
- validation: handledBy(GROUP_TYPE_HANDLER, "GroupTypeConfigController", "apply"),
9571
- },
9572
- ],
9573
- notExposed: {
9574
- appId: {
9575
- kind: "server-owned",
9576
- note: "Tenant scope, taken from the route; never on the wire.",
9577
- },
9578
- metadataManifest: {
9579
- kind: "structural",
9580
- note: "The declared-access manifest (#1350, extending #1304): authored " +
9581
- "as the file's top-level `[metadata]` + `secrets` fragments, not " +
9582
- "as a key inside [groupTypeConfig]. Validated by " +
9583
- "`validateDeclaredAccessManifest` (cli/src/lib/toml-metadata-config.ts) " +
9584
- "before push and `validateManifestShape` at persist time.",
9585
- },
9586
- createdAt: {
9587
- kind: "server-owned",
9588
- note: "Timestamp, assigned server-side.",
9589
- },
9590
- modifiedAt: {
9591
- kind: "server-owned",
9592
- note: "Timestamp, assigned server-side.",
9593
- },
9594
- createdBy: {
9595
- kind: "server-owned",
9596
- note: "User who created the config; assigned server-side.",
9597
- },
9598
- },
9599
- tomlOnlyKeys: {},
9600
- responseOnlyKeys: {},
9601
- },
9602
- ],
9603
- tomlDocumentKeys: { ...DECLARED_ACCESS_MANIFEST_KEYS },
9604
- };
9605
- // ── src/config-surface/collection-type-config.ts ─────────────────────────
9606
- /**
9607
- * The `collection-type-config` configuration object's definition (issue #2644,
9608
- * phase 3).
9609
- *
9610
- * `collection-type-configs/<collectionType>.toml` carries a single
9611
- * `[collectionTypeConfig]` table plus the declared-access manifest's top-level
9612
- * `[metadata]` / `secrets` fragments (declared `structural`, as on every other
9613
- * config that carries one).
9614
- *
9615
- * Same shape as `group-type-config` minus `autoAddCreator`: the rule-set
9616
- * reference is stored as `ruleSetId` and authored as `ruleSetName`, and the
9617
- * server checks the referenced set has `resourceType: "collection"`.
9618
- */
9619
- const COLLECTION_TYPE_HANDLER = "src/app-api/controllers/collection-type-config-controller.ts";
9620
- export const COLLECTION_TYPE_CONFIG_SURFACE = {
9621
- label: "collection-type-config",
9622
- tables: [
9623
- {
9624
- tomlPath: ["collectionTypeConfig"],
9625
- repeated: false,
9626
- model: "CollectionTypeConfig",
9627
- // Declaration order reproduces the pre-#2644 serializer's key order.
9628
- fields: [
9629
- {
9630
- field: "collectionType",
9631
- tomlKey: "collectionType",
9632
- type: "string",
9633
- emit: "always",
9634
- writableOn: CREATE_ONLY,
9635
- // The config's identity: required on create, taken from the URL on
9636
- // update.
9637
- validation: handledBy(COLLECTION_TYPE_HANDLER, "CollectionTypeConfigController", "apply"),
9638
- },
9639
- {
9640
- field: "ruleSetId",
9641
- tomlKey: "ruleSetName",
9642
- type: "string",
9643
- emit: "always",
9644
- writableOn: BOTH,
9645
- // Authored as a name, sent as an id; existence and resourceType are
9646
- // checked server-side, and an empty value clears the reference. The
9647
- // id spelling is retired in TOML (#3997): `retired-keys.ts`,
9648
- // `collectionTypeConfig`.
9649
- validation: handledBy(COLLECTION_TYPE_HANDLER, "CollectionTypeConfigController", "apply"),
9650
- },
9651
- ],
9652
- notExposed: {
9653
- appId: {
9654
- kind: "server-owned",
9655
- note: "Tenant scope, taken from the route; never on the wire.",
9656
- },
9657
- metadataManifest: {
9658
- kind: "structural",
9659
- note: "The declared-access manifest (#1304 P-C): authored as the file's " +
9660
- "top-level `[metadata]` + `secrets` fragments, not as a key inside " +
9661
- "[collectionTypeConfig]. Validated by " +
9662
- "`validateDeclaredAccessManifest` (cli/src/lib/toml-metadata-config.ts) " +
9663
- "before push and `validateManifestShape` at persist time.",
9664
- },
9665
- createdAt: {
9666
- kind: "server-owned",
9667
- note: "Timestamp, assigned server-side.",
9668
- },
9669
- modifiedAt: {
9670
- kind: "server-owned",
9671
- note: "Timestamp, assigned server-side.",
9672
- },
9673
- createdBy: {
9674
- kind: "server-owned",
9675
- note: "User who created the config; assigned server-side.",
9676
- },
9677
- },
9678
- tomlOnlyKeys: {},
9679
- responseOnlyKeys: {},
9680
- },
9681
- ],
9682
- tomlDocumentKeys: { ...DECLARED_ACCESS_MANIFEST_KEYS },
9683
- };
9684
9640
  // ── src/config-surface/metadata-category-config.ts ───────────────────────
9685
9641
  /**
9686
9642
  * The `metadata-category-config` configuration object's definition (issue
@@ -9834,47 +9790,6 @@ export const METADATA_CATEGORY_CONFIG_SURFACE = {
9834
9790
  ],
9835
9791
  tomlDocumentKeys: { ...DECLARED_ACCESS_MANIFEST_KEYS },
9836
9792
  };
9837
- // ── src/config-surface/transform.ts ──────────────────────────────────────
9838
- /**
9839
- * The `transform` configuration object's definition (issue #2644, phase 3).
9840
- *
9841
- * Transforms are the one synced type with NO TOML field table: a transform is
9842
- * `transforms/<name>.rhai`, a Rhai source file, and its whole authored surface
9843
- * is the script body. `config pull` writes the active `ScriptConfig`'s body and
9844
- * `config push` sends it back; there is no key/value table to define, and the
9845
- * `Script` / `ScriptConfig` scalars around it (name, description, inputSchema,
9846
- * limits, status) are not authorable through the sync slot today.
9847
- *
9848
- * The entry exists so that is a DECISION rather than an absence. Criterion 3's
9849
- * registry guard reads `SYNC_RESOURCE_TYPES` and requires a surface per label;
9850
- * without this module `transform` would have to sit in an exemption list, which
9851
- * is precisely the "absent from a hand-written list" failure mode this epic
9852
- * exists to end.
9853
- */
9854
- export const TRANSFORM_SURFACE = {
9855
- label: "transform",
9856
- tables: [],
9857
- // No TOML file at all, so no top-level TOML keys either — stated rather than
9858
- // left to `noFieldTable` to imply.
9859
- tomlDocumentKeys: {},
9860
- noFieldTable: {
9861
- note: "A transform is a Rhai source file (`transforms/<name>.rhai`); its " +
9862
- "authored surface is the script body, which config pull writes from the " +
9863
- "active ScriptConfig and config push sends back whole. The Script / " +
9864
- "ScriptConfig scalars (name, description, inputSchema, limits, status) " +
9865
- "are managed through `primitive transforms`, not through a TOML table, " +
9866
- "so this object has no field surface to define. Its sidecar test cases " +
9867
- "(`transforms/<name>.tests/`) are the separate `test-case` surface.",
9868
- },
9869
- noCrossFieldRules: {
9870
- note: "A cross-field rule refuses a COMBINATION of authored fields, and this " +
9871
- "object has no field table at all (see `noFieldTable`) — there are no " +
9872
- "two fields to cross. The Rhai body's own validity is the transform " +
9873
- "compiler's answer, not a configuration rule. Stated rather than left " +
9874
- "absent, so `transform` is a decision instead of the one surface nobody " +
9875
- "got to (#3373).",
9876
- },
9877
- };
9878
9793
  // ── src/config-surface/server-function.ts ────────────────────────────────
9879
9794
  /**
9880
9795
  * The `function` configuration object's definition (#3179, project
@@ -9940,7 +9855,7 @@ const functionRules = (stage, modulePath, exportName, entries) => entries.map(([
9940
9855
  /** The trigger blocks' shape rules — one id per refusal (#3181, #3184, #3334). */
9941
9856
  const TRIGGER_DECLARATION_RULES = functionRules("preflight", "src/config-surface/trigger-declaration.ts", "normalizeTriggerDeclaration", [
9942
9857
  ["triggers-table", "`[function.triggers]` must be a table."],
9943
- ["trigger-kind", "Only `webhook` and `cron` are trigger kinds."],
9858
+ ["trigger-kind", "Only `webhook`, `cron` and `db3` are trigger kinds."],
9944
9859
  [
9945
9860
  "database-trigger-removed",
9946
9861
  "`[[function.triggers.database]]` is refused: the trigger was removed " +
@@ -9966,6 +9881,16 @@ const TRIGGER_DECLARATION_RULES = functionRules("preflight", "src/config-surface
9966
9881
  "webhook-trigger-verification-table",
9967
9882
  "`[function.triggers.webhook.verification]` must be a table.",
9968
9883
  ],
9884
+ [
9885
+ "webhook-trigger-handshake-rules",
9886
+ "`[[function.triggers.webhook.handshakeRules]]` entries carry a CEL " +
9887
+ "`when` and a `response` table (`status`, `contentType`, `body`).",
9888
+ ],
9889
+ [
9890
+ "webhook-trigger-ip-allowlist",
9891
+ "`allowedIpCidrs` lists IPv4 addresses or CIDR prefixes the receiver " +
9892
+ "can match.",
9893
+ ],
9969
9894
  ["cron-trigger-cap", "A function declares at most ten cron entries."],
9970
9895
  ["cron-trigger-entry", "Each `[[function.triggers.cron]]` entry is a table."],
9971
9896
  ["cron-trigger-keys", "A cron entry accepts only its declared keys."],
@@ -9973,10 +9898,23 @@ const TRIGGER_DECLARATION_RULES = functionRules("preflight", "src/config-surface
9973
9898
  "cron-trigger-name-required",
9974
9899
  "A cron entry names itself: the name is half of its trigger key.",
9975
9900
  ],
9976
- ["cron-trigger-name-charset", "A cron name uses the standalone trigger-key charset."],
9901
+ ["cron-trigger-name-charset", "A cron name starts with a letter or digit and uses letters, digits, `_` and `-`."],
9977
9902
  ["cron-trigger-duplicate", "Each cron name appears once within the function."],
9978
9903
  ["cron-trigger-expression-required", "A cron entry carries a `cron` expression."],
9979
9904
  ["cron-trigger-overlap-policy", "`overlapPolicy` is `skip` or `allow`."],
9905
+ ["db3-trigger-cap", "A function watches at most ten db3 types."],
9906
+ ["db3-trigger-entry", "Each `[[function.triggers.db3]]` entry is a table."],
9907
+ ["db3-trigger-keys", "A db3 trigger entry accepts only `type`."],
9908
+ [
9909
+ "db3-trigger-type-required",
9910
+ "A db3 trigger entry names the db3 type it watches: a non-empty string " +
9911
+ "without `#`.",
9912
+ ],
9913
+ [
9914
+ "db3-trigger-type-reserved",
9915
+ "A db3 trigger entry does not name a type starting `primitive:`: those are the platform's.",
9916
+ ],
9917
+ ["db3-trigger-duplicate", "Each db3 type appears once within the function."],
9980
9918
  ]);
9981
9919
  /**
9982
9920
  * The retired runtime keys (#3188). `mode`, `durable` and a cron entry's
@@ -9994,9 +9932,7 @@ const RETIRED_RUNTIME_KEY_RULES = functionRules("preflight", "src/config-surface
9994
9932
  ]);
9995
9933
  /**
9996
9934
  * The file-decidable half of the webhook `signingSecret` rule (#3320). The
9997
- * SAME handler under the SAME ids is declared `apply` on the standalone
9998
- * `webhook` surface, whose CLI path does not run it: stage is a property of
9999
- * the (surface, rule) pair.
9935
+ * standalone `webhook` surface that also declared it retired with #3190.
10000
9936
  */
10001
9937
  const SIGNING_SECRET_RULES = functionRules("preflight", "src/config-surface/webhook-signing-secret.ts", "validateSigningSecretDeclaration", [
10002
9938
  [
@@ -10039,25 +9975,63 @@ const CRON_SCHEDULE_RULES = functionRules("preflight", "src/config-surface/cron-
10039
9975
  const FUNCTION_TRIGGER_STATE_RULES = functionRules("apply", "src/services/function-trigger-validation.ts", "validateFunctionTriggerDeclaration", [
10040
9976
  [
10041
9977
  "webhook-trigger-settings",
10042
- "The webhook block's verification settings pass the same pipeline the " +
10043
- "standalone create runs (scheme config, replay protection, secret " +
10044
- "existence), prefixed `[function.triggers.webhook]: `.",
9978
+ "The webhook block's verification settings pass the shared settings " +
9979
+ "pipeline (scheme config, replay protection, secret existence), " +
9980
+ "prefixed `[function.triggers.webhook]: `.",
10045
9981
  ],
10046
9982
  [
10047
9983
  "webhook-trigger-key-held",
10048
- "A standalone webhook that already holds the function's key blocks the " +
10049
- "trigger — nobody else's webhook is rewritten.",
9984
+ "Another function's trigger row on the function's key blocks the " +
9985
+ "trigger — nobody else's trigger is rewritten.",
10050
9986
  ],
10051
9987
  [
10052
9988
  "function-webhook-cap",
10053
9989
  "The per-app webhook cap, measured prospectively over what this push " +
10054
- "would add (the standalone cap's sentence, this surface's count).",
9990
+ "would add.",
10055
9991
  ],
10056
9992
  [
10057
9993
  "function-cron-cap",
10058
9994
  "The per-app cron-trigger cap, measured prospectively over what this " +
10059
9995
  "push would add.",
10060
9996
  ],
9997
+ [
9998
+ "function-db3-trigger-cap",
9999
+ "The per-app db3-trigger cap (fifty rows, archived included), measured " +
10000
+ "prospectively over what this push would add.",
10001
+ ],
10002
+ ]);
10003
+ /**
10004
+ * The shared verification-settings pipeline the webhook block passes, by its
10005
+ * own rule ids (#3374). `webhook-trigger-settings` above is the refusal the
10006
+ * push renders; these name which rule inside the pipeline refused. The
10007
+ * standalone `webhook` surface declared them until #3190 retired it, which
10008
+ * left the function push the pipeline's one caller.
10009
+ */
10010
+ const WEBHOOK_SETTINGS_RULES = functionRules("apply", "src/app-api/services/webhook-settings-validation.ts", "validateWebhookSettings", [
10011
+ ["verification-scheme-required", "A webhook names its `verificationScheme`."],
10012
+ ["verification-scheme-value", "The scheme is one the receiver knows."],
10013
+ [
10014
+ "verification-config",
10015
+ "The scheme's `config` is valid for that scheme under this " +
10016
+ "environment's JWKS policy, and carries no literal credential.",
10017
+ ],
10018
+ [
10019
+ "replay-protection",
10020
+ "A signed scheme keeps deduplication on, with a window and tolerance " +
10021
+ "in range and long enough to cover the signature's freshness window.",
10022
+ ],
10023
+ [
10024
+ "signing-secret-exists",
10025
+ "The app secret a `signingSecret` reference names must exist, so a " +
10026
+ "missing key fails the push rather than the first delivery — unless " +
10027
+ "the push carries the reference unchanged (#2109).",
10028
+ ],
10029
+ [
10030
+ "verification-config-secrets-exist",
10031
+ "Every secret reference the active scheme's `config` resolves at " +
10032
+ "delivery must name an existing app secret — unless the push carries " +
10033
+ "it unchanged (#2109).",
10034
+ ],
10061
10035
  ]);
10062
10036
  export const SERVER_FUNCTION_SURFACE = {
10063
10037
  label: "function",
@@ -10075,18 +10049,6 @@ export const SERVER_FUNCTION_SURFACE = {
10075
10049
  writableOn: BOTH,
10076
10050
  validation: "passthrough",
10077
10051
  },
10078
- {
10079
- field: "access",
10080
- tomlKey: "access",
10081
- type: "string",
10082
- emit: "always",
10083
- writableOn: BOTH,
10084
- // A CEL expression, and REQUIRED before code can be pushed: a
10085
- // function with no gate fails closed at invoke, so accepting a bundle
10086
- // for one would report a successful push of something that can never
10087
- // run.
10088
- validation: handledBy(FUNCTION_HANDLER, "ServerFunctionsController", "apply"),
10089
- },
10090
10052
  {
10091
10053
  field: "inputSchema",
10092
10054
  tomlKey: "inputSchema",
@@ -10156,6 +10118,14 @@ export const SERVER_FUNCTION_SURFACE = {
10156
10118
  "scan or sees the lease. Held for minutes at a time by one " +
10157
10119
  "request, never authored and never pulled.",
10158
10120
  },
10121
+ access: {
10122
+ kind: "server-owned",
10123
+ note: "The header's CEL gate, FROZEN at its last value (#4738): a " +
10124
+ "version without `authorize` (a legacy version) still runs it, " +
10125
+ "including after it is re-activated, and no route sets or changes " +
10126
+ "it. Never on the wire, never compared and never pulled; its TOML " +
10127
+ "spelling is declared in tomlOnlyKeys.",
10128
+ },
10159
10129
  createdBy: {
10160
10130
  kind: "server-owned",
10161
10131
  note: "Admin who created the function; assigned server-side.",
@@ -10228,6 +10198,23 @@ export const SERVER_FUNCTION_SURFACE = {
10228
10198
  "the file a human reviews is the authority — a push cannot store a " +
10229
10199
  "capability the TOML does not declare.",
10230
10200
  },
10201
+ access: {
10202
+ kind: "deprecated",
10203
+ note: "`access = \"…\"` — superseded by the entry's `authorize` (#4738). " +
10204
+ "Accepted so an untouched legacy tree still validates and reaches " +
10205
+ "the envelope comparison, where an unchanged envelope is a no-op. " +
10206
+ "Never sent; a new version that carries it beside `authorize` is " +
10207
+ "refused as ambiguous.",
10208
+ },
10209
+ public: {
10210
+ kind: "structural",
10211
+ note: "`public = true` (#4730) — the opt-in that confirms a function " +
10212
+ "whose authorize admits anyone (`allowAnyone()`) may write: " +
10213
+ "without it, such a write-capable version is refused at push. A " +
10214
+ "boolean, read from these authored bytes by the CLI preflight and " +
10215
+ "by the server from the envelope's TOML; never stored on its own, " +
10216
+ "and it changes nothing for any other function.",
10217
+ },
10231
10218
  },
10232
10219
  responseOnlyKeys: {},
10233
10220
  },
@@ -10249,16 +10236,66 @@ export const SERVER_FUNCTION_SURFACE = {
10249
10236
  // `functionTomlPreflightErrors` runs them in.
10250
10237
  ...CRON_SCHEDULE_RULES,
10251
10238
  ...FUNCTION_TRIGGER_STATE_RULES,
10239
+ ...WEBHOOK_SETTINGS_RULES,
10252
10240
  ],
10253
10241
  };
10242
+ // ── The break's sentences ───────────────────────────────────────────────────
10243
+ //
10244
+ // Said once here and vendored into the CLI, so the push preflight and the
10245
+ // server's refusal are the same words (#4738).
10246
+ // Spelled through a constant: this directory's import guard reads any quoted
10247
+ // module name after `from` as an import.
10248
+ const SDK_MODULE = JSON.stringify("primitive-functions");
10249
+ /**
10250
+ * The refusal of a new version whose default export has no `authorize`: it
10251
+ * names the function and shows the object form with the function's key. A
10252
+ * `file` prefixes the sentence the way the CLI reports a file it refuses.
10253
+ */
10254
+ export function authorizeRequiredMessage(functionKey, file) {
10255
+ const message = `Function '${functionKey}' has no \`authorize\`: every new version must define one. ` +
10256
+ "Export the object form:\n\n" +
10257
+ ` import { defineFunction, requireSignedIn } from ${SDK_MODULE};\n\n` +
10258
+ ` export default defineFunction(${JSON.stringify(functionKey)}, {\n` +
10259
+ " authorize: requireSignedIn(),\n" +
10260
+ " handler: async (input, ctx) => { /* ... */ },\n" +
10261
+ " });\n\n" +
10262
+ "The deployed version keeps running under its stored `access` rule until a " +
10263
+ "version with `authorize` is pushed. The access-control guide's porting table " +
10264
+ "maps each `access` expression to a helper.";
10265
+ return file ? `${file}: ${message}` : message;
10266
+ }
10267
+ /**
10268
+ * The refusal of a version that declares `public = true` and has no
10269
+ * `authorize` — #5840. `public = true` opens the function to signed-out
10270
+ * callers, and the version's own `authorize` is what decides about them.
10271
+ */
10272
+ export function publicRequiresAuthorizeMessage(functionKey, file) {
10273
+ const message = `Function '${functionKey}' declares \`public = true\` and has no \`authorize\`: ` +
10274
+ "a public function decides who may call it, signed-out callers included, in its own " +
10275
+ "`authorize`. Export the object form with one, such as `authorize: allowAnyone()`, " +
10276
+ `or remove \`public\` from functions/${functionKey}.toml.`;
10277
+ return file ? `${file}: ${message}` : message;
10278
+ }
10279
+ /**
10280
+ * The refusal of a new version that defines `authorize` while its TOML still
10281
+ * carries `access`.
10282
+ */
10283
+ export function accessAmbiguousMessage(functionKey) {
10284
+ return (`Function '${functionKey}' defines \`authorize\` and its TOML still carries ` +
10285
+ "`access`: the two would disagree about who may run it. " +
10286
+ `Remove \`access\` from functions/${functionKey}.toml; \`authorize\` decides.`);
10287
+ }
10288
+ /** The refusal of a create or update body that carries `access`. */
10289
+ export const FUNCTION_ACCESS_FROZEN_REQUEST = "`access` is frozen: a function's stored rule is kept for its legacy versions " +
10290
+ "and can no longer be set or changed. Omit the field; the version's `authorize` " +
10291
+ "decides who may run it.";
10254
10292
  // ── src/config-surface/test-case.ts ──────────────────────────────────────
10255
10293
  /**
10256
10294
  * The `test-case` configuration object's definition (issue #2644, phase 3).
10257
10295
  *
10258
10296
  * Test cases round-trip without being one of the per-entity directories: they
10259
10297
  * live in a sidecar `<key>.tests/` folder beside the block they test — a
10260
- * prompt, a workflow, a transform or (since #2769) an integration — one
10261
- * `[test]` table per file. They are not
10298
+ * prompt or (since #2769) an integration — one `[test]` table per file. They are not
10262
10299
  * a `SYNC_RESOURCE_TYPES` label (that table is per-entity directory metadata),
10263
10300
  * which is exactly why the spec names them explicitly: nothing that syncs sits
10264
10301
  * outside the registry.
@@ -10492,8 +10529,7 @@ export const TEST_CASE_SURFACE = {
10492
10529
  blockType: {
10493
10530
  kind: "structural",
10494
10531
  requestModes: [],
10495
- note: "Which kind of block the case tests (prompt | workflow | script | " +
10496
- "integration). " +
10532
+ note: "Which kind of block the case tests (prompt | integration). " +
10497
10533
  "Comes from the directory the `<key>.tests/` folder sits in and " +
10498
10534
  "travels in the URL path, not in the body.",
10499
10535
  },
@@ -10669,6 +10705,32 @@ export const APP_SETTINGS_SURFACE = {
10669
10705
  // (`parseRootDocumentFormatSetting`).
10670
10706
  validation: handledBy(SETTINGS_HANDLER, "SettingsController", "apply"),
10671
10707
  },
10708
+ {
10709
+ field: "signedOutAccess",
10710
+ tomlKey: "signedOutAccess",
10711
+ type: "boolean",
10712
+ // Always: a pulled file states whether signed-out callers may
10713
+ // invoke the app's `public` functions, rather than leaving it to the
10714
+ // absence of a key (#5840).
10715
+ emit: "always",
10716
+ writableOn: UPDATE_ONLY,
10717
+ // A boolean, refused otherwise; the route answers the functions
10718
+ // turning it on opens (`signedOutFunctions`).
10719
+ validation: handledBy(SETTINGS_HANDLER, "SettingsController", "apply"),
10720
+ },
10721
+ {
10722
+ field: "allowFieldRemoval",
10723
+ tomlKey: "allowFieldRemoval",
10724
+ type: "boolean",
10725
+ // Whenever the app set it. An app that never did may not remove
10726
+ // fields from an in-use db3 type, and a pulled file should not grow
10727
+ // a key for it (#6019).
10728
+ emit: "whenSet",
10729
+ writableOn: UPDATE_ONLY,
10730
+ // A boolean or cleared, refused otherwise; a type write reads the
10731
+ // stored value before it takes `allowFieldRemoval=true`.
10732
+ validation: handledBy(SETTINGS_HANDLER, "SettingsController", "apply"),
10733
+ },
10672
10734
  {
10673
10735
  field: "protection",
10674
10736
  tomlKey: "protection",
@@ -10757,6 +10819,11 @@ export const APP_SETTINGS_SURFACE = {
10757
10819
  kind: "server-owned",
10758
10820
  note: "When the app last saw counted activity; written by the server.",
10759
10821
  },
10822
+ transitions: {
10823
+ kind: "server-owned",
10824
+ note: "The app's platform transition overrides (#5821); set only by a " +
10825
+ "super-admin through the transitions routes, so sync never sees it.",
10826
+ },
10760
10827
  passkeyRpId: {
10761
10828
  kind: "server-owned",
10762
10829
  note: "RETIRED from the write surface by #2891, superseded by " +
@@ -11043,6 +11110,79 @@ export const APP_SETTINGS_SURFACE = {
11043
11110
  // top-level key. (App config VARS live in their own `vars.toml`.)
11044
11111
  tomlDocumentKeys: {},
11045
11112
  };
11113
+ // ── src/config-surface/user-properties.ts ────────────────────────────────
11114
+ /**
11115
+ * The `user-properties` configuration object's definition (#5385, project
11116
+ * `user-index-properties` phase 2).
11117
+ *
11118
+ * `user-properties.toml` is a root singleton beside `app.toml`, so — like
11119
+ * `app-settings` and `test-case` — it is named explicitly rather than reached
11120
+ * through `SYNC_RESOURCE_TYPES`. Its keys are the app's own: each
11121
+ * `[fields.<name>]` table declares a property in the db3 field grammar plus
11122
+ * `client`, and each `[[unique_constraints]]` entry names two or more of them.
11123
+ * There is no fixed key/value table to define, so the surface declares
11124
+ * `noFieldTable`; the file is parsed, normalized and judged by one module,
11125
+ * `src/user-index/properties-schema.ts`, which the CLI vendors byte for byte
11126
+ * (`cli/src/lib/user-properties/generated-properties-schema.ts`) and which
11127
+ * `config push`'s preflight runs before anything is applied. The pushed
11128
+ * schema is stored on the app's `UserPropertiesConfig` row.
11129
+ */
11130
+ export const USER_PROPERTIES_SURFACE = {
11131
+ label: "user-properties",
11132
+ tables: [],
11133
+ noFieldTable: {
11134
+ note: "Every key under [fields] is a property name the app declares; the field grammar, the client values and the " +
11135
+ "constraint rules are the schema module's (src/user-index/properties-schema.ts), run by config push's preflight " +
11136
+ "through its vendored copy and again by the push route",
11137
+ },
11138
+ tomlDocumentKeys: {
11139
+ fields: {
11140
+ kind: "structural",
11141
+ note: "[fields.<name>] tables: one property each, parsed whole by parseUserPropertiesToml and sent as the file's text",
11142
+ },
11143
+ unique_constraints: {
11144
+ kind: "structural",
11145
+ note: "[[unique_constraints]] entries { name, fields }, parsed whole by parseUserPropertiesToml with the fields",
11146
+ },
11147
+ },
11148
+ noCrossFieldRules: {
11149
+ note: "The file's rules span fields and constraints but are not field-table rules: parseUserPropertiesToml " +
11150
+ "(src/user-index/properties-schema.ts) decides every one, from the file alone, at config push's preflight",
11151
+ },
11152
+ };
11153
+ // ── src/config-surface/schema-file.ts ────────────────────────────────────
11154
+ /**
11155
+ * The `schema` configuration object's definition (#5532, project
11156
+ * `unified-schemas` phase 3).
11157
+ *
11158
+ * `schemas/<file>.toml` holds shared shapes: each `[defs.<Name>]` table is
11159
+ * one JSON Schema document, named by the file's stem and the def's name
11160
+ * (`schemas:<file>#/$defs/<Name>`). There is no fixed key/value table to
11161
+ * define, so the surface declares `noFieldTable`; the file is checked and
11162
+ * compiled by one module, `src/function-runs/schema-file.ts`, which the CLI
11163
+ * vendors (`cli/src/lib/schema-codegen/generated-schema-file.ts`), runs in
11164
+ * `config push`'s preflight and sends compiled with the source, and which the
11165
+ * push route runs again.
11166
+ */
11167
+ export const SCHEMA_FILE_SURFACE = {
11168
+ label: "schema",
11169
+ tables: [],
11170
+ noFieldTable: {
11171
+ note: "Every key under [defs] is a def name the file declares, and each def is a JSON Schema document; the shape, " +
11172
+ "keyword and compile rules are the schemas/ file module's (src/function-runs/schema-file.ts), run by config " +
11173
+ "push's preflight through its vendored copy and again by the push route",
11174
+ },
11175
+ tomlDocumentKeys: {
11176
+ defs: {
11177
+ kind: "structural",
11178
+ note: "[defs.<Name>] tables: one shared shape each, compiled whole by compileSchemaFile and sent as the file's text",
11179
+ },
11180
+ },
11181
+ noCrossFieldRules: {
11182
+ note: "The file's rules span defs but are not field-table rules: compileSchemaFile (src/function-runs/schema-file.ts) " +
11183
+ "decides every one, from the file alone, at config push's preflight",
11184
+ },
11185
+ };
11046
11186
  // ── src/config-surface/index.ts ──────────────────────────────────────────
11047
11187
  /**
11048
11188
  * The configuration-object registry (issue #2644).
@@ -11060,30 +11200,28 @@ export const APP_SETTINGS_SURFACE = {
11060
11200
  /**
11061
11201
  * Every configuration object whose field surface is defined here.
11062
11202
  *
11063
- * One entry per `SYNC_RESOURCE_TYPES` label, plus the two surfaces that
11064
- * round-trip without being a per-entity file: `app-settings` (`app.toml`) and
11065
- * `test-case` (`<key>.tests/`). Nothing that syncs sits outside the registry —
11203
+ * One entry per `SYNC_RESOURCE_TYPES` label, plus the three surfaces that
11204
+ * round-trip without being a per-entity file: `app-settings` (`app.toml`),
11205
+ * `user-properties` (`user-properties.toml`, #5385) and `test-case`
11206
+ * (`<key>.tests/`). Nothing that syncs sits outside the registry —
11066
11207
  * `PENDING_MIGRATION`, the migration's temporary exemption list, is gone as of
11067
11208
  * phase 3, so a new synced type has nowhere to be parked and fails the registry
11068
11209
  * guard until it is defined (#2644 criterion 3).
11069
11210
  */
11070
11211
  export const CONFIG_SURFACES = [
11071
- WORKFLOW_SURFACE,
11072
11212
  PROMPT_SURFACE,
11073
11213
  INTEGRATION_SURFACE,
11074
- WEBHOOK_SURFACE,
11075
- CRON_TRIGGER_SURFACE,
11076
11214
  BLOB_BUCKET_SURFACE,
11077
11215
  EMAIL_TEMPLATE_SURFACE,
11078
11216
  DATABASE_TYPE_SURFACE,
11217
+ DB3_TYPE_SURFACE,
11079
11218
  RULE_SET_SURFACE,
11080
- GROUP_TYPE_CONFIG_SURFACE,
11081
- COLLECTION_TYPE_CONFIG_SURFACE,
11082
11219
  METADATA_CATEGORY_CONFIG_SURFACE,
11083
- TRANSFORM_SURFACE,
11084
11220
  SERVER_FUNCTION_SURFACE,
11085
11221
  TEST_CASE_SURFACE,
11086
11222
  APP_SETTINGS_SURFACE,
11223
+ USER_PROPERTIES_SURFACE,
11224
+ SCHEMA_FILE_SURFACE,
11087
11225
  ];
11088
11226
  /**
11089
11227
  * The configuration surfaces that have not declared their CROSS-FIELD rules yet
@@ -11105,13 +11243,10 @@ export const CONFIG_SURFACES = [
11105
11243
  export const CROSS_FIELD_RULES_UNMIGRATED = [
11106
11244
  "prompt",
11107
11245
  "integration",
11108
- "cron-trigger",
11109
11246
  "blob-bucket",
11110
11247
  "email-template",
11111
11248
  "database-type-config",
11112
11249
  "rule-set",
11113
- "group-type-config",
11114
- "collection-type-config",
11115
11250
  "metadata-category-config",
11116
11251
  "test-case",
11117
11252
  "app-settings",
@@ -11183,6 +11318,8 @@ export const GENERATED_CONFIG_MODEL_FIELDS = {
11183
11318
  "memberInvitationLimit",
11184
11319
  "largeDocumentWindowDays",
11185
11320
  "rootDocumentFormat",
11321
+ "signedOutAccess",
11322
+ "allowFieldRemoval",
11186
11323
  "protection",
11187
11324
  "protected",
11188
11325
  "parentAppId",
@@ -11197,6 +11334,7 @@ export const GENERATED_CONFIG_MODEL_FIELDS = {
11197
11334
  "previewOrigins",
11198
11335
  "childPartition",
11199
11336
  "lastActivityAt",
11337
+ "transitions",
11200
11338
  "createdAt",
11201
11339
  "modifiedAt",
11202
11340
  ],
@@ -11229,6 +11367,10 @@ export const GENERATED_CONFIG_MODEL_FIELDS = {
11229
11367
  "copiedFromCatalogId",
11230
11368
  "inputSchema",
11231
11369
  "outputSchema",
11370
+ "schemaSource",
11371
+ "schemaSourceR2Key",
11372
+ "schemaProvenance",
11373
+ "schemaProvenanceR2Key",
11232
11374
  "activeConfigId",
11233
11375
  "defaultEvaluatorPromptId",
11234
11376
  "status",
@@ -11255,6 +11397,10 @@ export const GENERATED_CONFIG_MODEL_FIELDS = {
11255
11397
  "maxTokens",
11256
11398
  "outputFormat",
11257
11399
  "outputSchema",
11400
+ "schemaSource",
11401
+ "schemaSourceR2Key",
11402
+ "schemaProvenance",
11403
+ "schemaProvenanceR2Key",
11258
11404
  "providerConfig",
11259
11405
  "questions",
11260
11406
  "reasoningEffort",
@@ -11265,36 +11411,6 @@ export const GENERATED_CONFIG_MODEL_FIELDS = {
11265
11411
  "createdAt",
11266
11412
  "modifiedAt",
11267
11413
  ],
11268
- "AppWebhook": [
11269
- "webhookId",
11270
- "appId",
11271
- "webhookKey",
11272
- "displayName",
11273
- "description",
11274
- "status",
11275
- "workflowKey",
11276
- "workflowId",
11277
- "verificationScheme",
11278
- "signingSecret",
11279
- "previousSigningSecret",
11280
- "secretRotatedAt",
11281
- "functionId",
11282
- "declaredSigningSecret",
11283
- "secretGracePeriodMs",
11284
- "toleranceSeconds",
11285
- "deduplicationEnabled",
11286
- "deduplicationWindowMs",
11287
- "maxBodyBytes",
11288
- "inputMapping",
11289
- "allowedIpCidrs",
11290
- "handshakeRules",
11291
- "config",
11292
- "metadata",
11293
- "lastTriggeredAt",
11294
- "createdBy",
11295
- "createdAt",
11296
- "modifiedAt",
11297
- ],
11298
11414
  "BlobBucket": [
11299
11415
  "bucketId",
11300
11416
  "appId",
@@ -11337,42 +11453,6 @@ export const GENERATED_CONFIG_MODEL_FIELDS = {
11337
11453
  "createdAt",
11338
11454
  "modifiedAt",
11339
11455
  ],
11340
- "CollectionTypeConfig": [
11341
- "appId",
11342
- "collectionType",
11343
- "ruleSetId",
11344
- "metadataManifest",
11345
- "createdAt",
11346
- "modifiedAt",
11347
- "createdBy",
11348
- ],
11349
- "CronTrigger": [
11350
- "triggerId",
11351
- "appId",
11352
- "triggerKey",
11353
- "displayName",
11354
- "description",
11355
- "cron",
11356
- "timezone",
11357
- "workflowKey",
11358
- "functionId",
11359
- "overlapPolicy",
11360
- "rootInput",
11361
- "inputMapping",
11362
- "status",
11363
- "state",
11364
- "operationallyDisabled",
11365
- "lastError",
11366
- "lastTriggeredAt",
11367
- "lastTriggeredRunId",
11368
- "skippedCount",
11369
- "firedCount",
11370
- "consecutiveNotActiveCount",
11371
- "nextFireAt",
11372
- "createdBy",
11373
- "createdAt",
11374
- "modifiedAt",
11375
- ],
11376
11456
  "DatabaseTypeConfig": [
11377
11457
  "appId",
11378
11458
  "databaseType",
@@ -11397,16 +11477,6 @@ export const GENERATED_CONFIG_MODEL_FIELDS = {
11397
11477
  "createdAt",
11398
11478
  "modifiedAt",
11399
11479
  ],
11400
- "GroupTypeConfig": [
11401
- "appId",
11402
- "groupType",
11403
- "ruleSetId",
11404
- "metadataManifest",
11405
- "autoAddCreator",
11406
- "createdAt",
11407
- "modifiedAt",
11408
- "createdBy",
11409
- ],
11410
11480
  "MetadataCategoryConfig": [
11411
11481
  "appId",
11412
11482
  "categoryKey",
@@ -11441,39 +11511,5 @@ export const GENERATED_CONFIG_MODEL_FIELDS = {
11441
11511
  "createdAt",
11442
11512
  "modifiedAt",
11443
11513
  ],
11444
- "WorkflowDefinition": [
11445
- "workflowId",
11446
- "appId",
11447
- "workflowKey",
11448
- "name",
11449
- "status",
11450
- "latestRevision",
11451
- "description",
11452
- "stepsR2Key",
11453
- "draftStepsR2Key",
11454
- "draftInputSchema",
11455
- "draftOutputSchema",
11456
- "draftModifiedAt",
11457
- "activeConfigId",
11458
- "inputSchema",
11459
- "outputSchema",
11460
- "perUserMaxRunning",
11461
- "perUserMaxQueued",
11462
- "perAppMaxRunning",
11463
- "perAppMaxQueued",
11464
- "queueTtlSeconds",
11465
- "dequeueOrder",
11466
- "requiresClientApply",
11467
- "syncCallable",
11468
- "accessRule",
11469
- "metadataManifest",
11470
- "runAs",
11471
- "lock",
11472
- "capabilities",
11473
- "operationallyDisabled",
11474
- "createdBy",
11475
- "createdAt",
11476
- "modifiedAt",
11477
- ],
11478
11514
  };
11479
11515
  //# sourceMappingURL=generated-config-surfaces.js.map