spine-framework 0.3.145 → 0.4.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 (451) hide show
  1. package/.env.example +76 -0
  2. package/.framework/.spine-manifest.json +19 -0
  3. package/.framework/cli/commands/agents.ts +61 -33
  4. package/.framework/cli/commands/auth.ts +60 -28
  5. package/.framework/cli/commands/create-app.ts +212 -80
  6. package/.framework/cli/commands/dev.ts +184 -68
  7. package/.framework/cli/commands/doctor.ts +324 -152
  8. package/.framework/cli/commands/generate.ts +119 -68
  9. package/.framework/cli/commands/init.ts +141 -242
  10. package/.framework/cli/commands/install-app.ts +1336 -314
  11. package/.framework/cli/commands/items.ts +31 -29
  12. package/.framework/cli/commands/migrate.ts +299 -156
  13. package/.framework/cli/commands/migrations.ts +62 -30
  14. package/.framework/cli/commands/pipelines.ts +31 -29
  15. package/.framework/cli/commands/status.ts +105 -45
  16. package/.framework/cli/commands/system.ts +47 -42
  17. package/.framework/cli/commands/test.ts +161 -102
  18. package/.framework/cli/commands/upgrade.ts +260 -0
  19. package/.framework/cli/commands/validate-app.ts +517 -161
  20. package/.framework/cli/context.ts +117 -85
  21. package/.framework/cli/env-loader.ts +74 -43
  22. package/.framework/cli/index.ts +70 -46
  23. package/.framework/cli/lib/project-files.ts +404 -0
  24. package/.framework/docs/guides/testing-guide.md +1 -1
  25. package/.framework/docs/runtime-types.md +72 -72
  26. package/.framework/functions/_shared/access.ts +84 -0
  27. package/.framework/functions/_shared/agent-runner.ts +5051 -1026
  28. package/.framework/functions/_shared/app-manifest.ts +214 -94
  29. package/.framework/functions/_shared/ast.ts +214 -0
  30. package/.framework/functions/_shared/audit.ts +91 -55
  31. package/.framework/functions/_shared/cil.ts +368 -127
  32. package/.framework/functions/_shared/db.ts +337 -68
  33. package/.framework/functions/_shared/funnel.ts +228 -0
  34. package/.framework/functions/_shared/geo.ts +105 -0
  35. package/.framework/functions/_shared/hash-api-key.ts +94 -17
  36. package/.framework/functions/_shared/index.ts +22 -224
  37. package/.framework/functions/_shared/kb.ts +832 -58
  38. package/.framework/functions/_shared/llm.ts +118 -18
  39. package/.framework/functions/_shared/logging.ts +317 -19
  40. package/.framework/functions/_shared/middleware.ts +701 -131
  41. package/.framework/functions/_shared/notify.ts +70 -0
  42. package/.framework/functions/_shared/outcomes.ts +34 -19
  43. package/.framework/functions/_shared/permissions.ts +501 -315
  44. package/.framework/functions/_shared/pipeline-runner.ts +704 -155
  45. package/.framework/functions/_shared/principal.ts +436 -263
  46. package/.framework/functions/_shared/rate-limit.ts +233 -0
  47. package/.framework/functions/_shared/resolve-credentials.ts +86 -19
  48. package/.framework/functions/_shared/resolve-ids.ts +203 -139
  49. package/.framework/functions/_shared/retry-deliveries.ts +51 -16
  50. package/.framework/functions/_shared/schema-utils.ts +602 -521
  51. package/.framework/functions/_shared/security.ts +345 -0
  52. package/.framework/functions/_shared/testing.ts +197 -172
  53. package/.framework/functions/_shared/tracing.ts +351 -21
  54. package/.framework/functions/_shared/trigger-engine.ts +425 -136
  55. package/.framework/functions/_shared/webhook-registration.ts +71 -70
  56. package/.framework/functions/_shared/webhook-registry.ts +126 -83
  57. package/.framework/functions/account-nodes.ts +30 -30
  58. package/.framework/functions/adapters/generic-webhook-inbound.ts +49 -16
  59. package/.framework/functions/adapters/generic-webhook-outbound.ts +17 -17
  60. package/.framework/functions/adapters/openai-outbound.ts +15 -16
  61. package/.framework/functions/admin-data.ts +596 -173
  62. package/.framework/functions/admin-funnel.ts +64 -60
  63. package/.framework/functions/admin-install-funnel.ts +84 -66
  64. package/.framework/functions/admin-signals.ts +69 -51
  65. package/.framework/functions/ai-agents.ts +431 -106
  66. package/.framework/functions/ai-interactions.ts +186 -112
  67. package/.framework/functions/api-keys.ts +107 -107
  68. package/.framework/functions/apps.ts +154 -136
  69. package/.framework/functions/auth.ts +83 -65
  70. package/.framework/functions/cil-agent-ingest.ts +189 -232
  71. package/.framework/functions/cil-agent.ts +433 -177
  72. package/.framework/functions/cil-callmap.ts +642 -430
  73. package/.framework/functions/cil-config.ts +139 -135
  74. package/.framework/functions/cil-context.ts +214 -127
  75. package/.framework/functions/cil-doc.ts +587 -458
  76. package/.framework/functions/cil-embeddings.ts +453 -364
  77. package/.framework/functions/cil-graph.ts +427 -142
  78. package/.framework/functions/cil-ingest.ts +1418 -1154
  79. package/.framework/functions/cil-pipeline.ts +276 -21
  80. package/.framework/functions/cil-project.ts +659 -132
  81. package/.framework/functions/cil-validate.ts +198 -164
  82. package/.framework/functions/debug-auth.ts +57 -55
  83. package/.framework/functions/deliveries.ts +80 -21
  84. package/.framework/functions/embeddings.ts +1023 -318
  85. package/.framework/functions/eval-harness.ts +146 -108
  86. package/.framework/functions/integration-outbound.ts +205 -75
  87. package/.framework/functions/integration-routes.ts +128 -23
  88. package/.framework/functions/integrations.ts +125 -100
  89. package/.framework/functions/invites.ts +1095 -460
  90. package/.framework/functions/item-progress.ts +158 -102
  91. package/.framework/functions/kb.ts +34 -10
  92. package/.framework/functions/logs.ts +133 -133
  93. package/.framework/functions/observability.ts +152 -122
  94. package/.framework/functions/pipeline-executions.ts +147 -132
  95. package/.framework/functions/pipelines.ts +134 -119
  96. package/.framework/functions/prompt-configs.ts +96 -80
  97. package/.framework/functions/roles.ts +112 -82
  98. package/.framework/functions/security.ts +450 -0
  99. package/.framework/functions/system-cron.ts +117 -80
  100. package/.framework/functions/system.ts +158 -98
  101. package/.framework/functions/tests.ts +29 -29
  102. package/.framework/functions/timers.ts +94 -95
  103. package/.framework/functions/trigger-scheduler.ts +10 -0
  104. package/.framework/functions/triggers.ts +179 -149
  105. package/.framework/functions/types.ts +137 -125
  106. package/.framework/mcp/index.ts +133 -0
  107. package/.framework/mcp/load-env.ts +60 -0
  108. package/.framework/mcp/shared/app-manifest.ts +275 -0
  109. package/.framework/mcp/shared/db.ts +477 -0
  110. package/.framework/mcp/shared/kb.ts +118 -0
  111. package/.framework/mcp/tools/architect.ts +431 -0
  112. package/.framework/mcp/tools/cil/context.ts +345 -0
  113. package/.framework/mcp/tools/cil/graph.ts +242 -0
  114. package/.framework/mcp/tools/cil/ingest.ts +1217 -0
  115. package/.framework/mcp/tools/cil/pipeline-orchestrator.ts +693 -0
  116. package/.framework/mcp/tools/cil/pipeline.ts +767 -0
  117. package/.framework/mcp/tools/cil/project.ts +791 -0
  118. package/.framework/mcp/tools/cil/retrieval.ts +336 -0
  119. package/.framework/mcp/tools/cil/search-core.ts +454 -0
  120. package/.framework/mcp/tools/cil/search.ts +97 -0
  121. package/.framework/mcp/tools/cil/suggest.ts +186 -0
  122. package/.framework/mcp/tools/cil/validate.ts +1369 -0
  123. package/.framework/mcp/tools/kb/delete.ts +139 -0
  124. package/.framework/mcp/tools/kb/index.ts +52 -0
  125. package/.framework/mcp/tools/kb/ingest.ts +84 -0
  126. package/.framework/mcp/tools/kb/list-types.ts +102 -0
  127. package/.framework/mcp/tools/kb/publish.ts +100 -0
  128. package/.framework/mcp/tools/kb/reindex.ts +86 -0
  129. package/.framework/mcp/tools/kb/revoke.ts +85 -0
  130. package/.framework/mcp/tools/kb/search.ts +101 -0
  131. package/.framework/mcp/tools/kb/upsert.ts +125 -0
  132. package/.framework/mcp/tools/observability.ts +510 -0
  133. package/.framework/migrations/001_core_schema.sql +15 -0
  134. package/.framework/migrations/002_core_rls_and_functions.sql +15 -0
  135. package/.framework/migrations/003_core_system_data.sql +16 -1
  136. package/.framework/migrations/004_core_rpc_and_broker.sql +17 -1
  137. package/.framework/migrations/005_core_observability.sql +17 -1
  138. package/.framework/migrations/006_security_hardening_rls.sql +15 -0
  139. package/.framework/migrations/007_kb_article_list.sql +17 -1
  140. package/.framework/migrations/008_items_target.sql +15 -0
  141. package/.framework/migrations/009_roles_slug_unique.sql +15 -0
  142. package/.framework/migrations/010_auth_user_trigger.sql +15 -0
  143. package/.framework/migrations/011_spine_system_account.sql +16 -0
  144. package/.framework/migrations/012_service_role_grants.sql +16 -0
  145. package/.framework/migrations/013_get_account_apps_role_filter.sql +15 -0
  146. package/.framework/migrations/014_apps_required_roles.sql +16 -0
  147. package/.framework/migrations/015_types_kind_slug_unique.sql +15 -0
  148. package/.framework/migrations/016_cil_types.sql +281 -0
  149. package/.framework/migrations/017_cil_stable_ids.sql +37 -0
  150. package/.framework/migrations/018_runtime_tables.sql +129 -0
  151. package/.framework/migrations/019_agent_prompt_columns.sql +56 -0
  152. package/.framework/migrations/020_schema_reconciliation.sql +67 -0
  153. package/.framework/migrations/021_kb_embedding_lifecycle.sql +31 -0
  154. package/.framework/migrations/032_cil_status_migration.sql +73 -0
  155. package/.framework/migrations/033_cil_versioning.sql +73 -0
  156. package/.framework/migrations/034_match_embeddings_knn.sql +115 -0
  157. package/.framework/migrations/035_rate_limits.sql +55 -0
  158. package/.framework/migrations/036_demo_record_flags.sql +72 -0
  159. package/.framework/migrations/037_kb_types_canonical.sql +244 -0
  160. package/.framework/migrations/038_drop_demo_record_flags.sql +38 -0
  161. package/.framework/migrations/042_registration_hierarchy.sql +309 -0
  162. package/.framework/migrations/043_policy_actor_cleanup.sql +39 -0
  163. package/.framework/migrations/044_match_embeddings_filtered_knn.sql +151 -0
  164. package/.framework/migrations/045_security_critical_rls.sql +139 -0
  165. package/.framework/migrations/046_security_missing_rls.sql +79 -0
  166. package/.framework/migrations/047_people_updated_by.sql +27 -0
  167. package/.framework/migrations/048_watcher_last_seen_at.sql +24 -0
  168. package/.framework/migrations/049_security_blocklist.sql +148 -0
  169. package/.framework/migrations/050_notifications.sql +49 -0
  170. package/.framework/migrations/051_message_agent_fields.sql +74 -0
  171. package/.framework/migrations/052_registration_security.sql +421 -0
  172. package/.framework/migrations/053_builtin_action_seeds.sql +66 -0
  173. package/.framework/migrations/054_kb_ingest_lease.sql +157 -0
  174. package/.framework/migrations/055_type_id_drift_reconciliation.sql +33 -0
  175. package/.framework/migrations/056_slug_column_reconciliation.sql +38 -0
  176. package/.framework/migrations/057_pipelines_slug_identity.sql +14 -0
  177. package/.framework/migrations/058_account_data_field_declarations.sql +53 -0
  178. package/.framework/migrations/059_registration_placement_fixes.sql +269 -0
  179. package/.framework/migrations/060_account_person_record_permissions.sql +38 -0
  180. package/.framework/migrations/061_fk_dedup.sql +32 -0
  181. package/.framework/public/spine-logo.svg +10 -3
  182. package/.framework/scripts/app-install-cli.ts +190 -93
  183. package/.framework/scripts/assemble-frontend.sh +127 -44
  184. package/.framework/scripts/assemble-functions.sh +128 -30
  185. package/.framework/scripts/boundary-check.sh +6 -2
  186. package/.framework/scripts/build-manifest.sh +24 -68
  187. package/.framework/scripts/check-core-integrity.sh +15 -76
  188. package/.framework/scripts/checksum-manifest.mts +343 -0
  189. package/.framework/scripts/cil-migrate-markers.ts +403 -0
  190. package/.framework/scripts/fix-cil-markers.mjs +176 -0
  191. package/.framework/scripts/verify-integrity.sh +21 -57
  192. package/.framework/scripts/verify-manifest.mts +305 -0
  193. package/.framework/seeds/types/funnel_signal_use.json +74 -21
  194. package/.framework/seeds/types/spine_instance.json +73 -21
  195. package/.framework/src/App.tsx +118 -72
  196. package/.framework/src/apps/admin/index.tsx +855 -58
  197. package/.framework/src/components/AppWrapper.tsx +43 -45
  198. package/.framework/src/components/CustomAppLoader.tsx +160 -116
  199. package/.framework/src/components/admin/AdminListPage.tsx +46 -44
  200. package/.framework/src/components/admin/AdminSidebar.tsx +57 -47
  201. package/.framework/src/components/admin/AdminStatsCard.tsx +46 -44
  202. package/.framework/src/components/admin/PageInstructions.tsx +98 -2
  203. package/.framework/src/components/admin/SortableTableHeader.tsx +44 -45
  204. package/.framework/src/components/app-shell/GenericAppShell.tsx +64 -65
  205. package/.framework/src/components/app-shell/GenericDetailPage.tsx +44 -47
  206. package/.framework/src/components/app-shell/GenericListPage.tsx +45 -49
  207. package/.framework/src/components/app-sidebar.tsx +42 -45
  208. package/.framework/src/components/auth/ProtectedRoute.tsx +48 -41
  209. package/.framework/src/components/auth/TurnstileWidget.tsx +27 -0
  210. package/.framework/src/components/kb/KBArticleEditor.tsx +231 -22
  211. package/.framework/src/components/kb/KBArticleList.tsx +251 -10
  212. package/.framework/src/components/layout/AppShell.tsx +51 -45
  213. package/.framework/src/components/layout/Header.tsx +42 -43
  214. package/.framework/src/components/layout/Layout.tsx +46 -46
  215. package/.framework/src/components/layout/Sidebar.tsx +196 -96
  216. package/.framework/src/components/runtime/DataDetailHeader.tsx +55 -30
  217. package/.framework/src/components/runtime/DataDetailPage.tsx +31 -269
  218. package/.framework/src/components/runtime/DataFilters.tsx +49 -74
  219. package/.framework/src/components/runtime/DataHeader.tsx +53 -32
  220. package/.framework/src/components/runtime/DataListPage.tsx +51 -155
  221. package/.framework/src/components/runtime/DataStats.tsx +66 -44
  222. package/.framework/src/components/runtime/DataTable.tsx +49 -149
  223. package/.framework/src/components/runtime/SchemaDetailForm.tsx +45 -75
  224. package/.framework/src/components/runtime/index.ts +119 -16
  225. package/.framework/src/components/search-form.tsx +46 -29
  226. package/.framework/src/components/shared/AgentView.tsx +65 -48
  227. package/.framework/src/components/shared/FieldRenderer.tsx +144 -50
  228. package/.framework/src/components/shared/InviteManager.tsx +207 -97
  229. package/.framework/src/components/shared/MemberList.tsx +97 -0
  230. package/.framework/src/components/shared/SchemaFields.tsx +107 -86
  231. package/.framework/src/components/ui/DataTable.tsx +80 -68
  232. package/.framework/src/components/ui/Form.tsx +157 -146
  233. package/.framework/src/components/ui/ItemCard.tsx +74 -67
  234. package/.framework/src/components/ui/ItemListView.tsx +73 -68
  235. package/.framework/src/components/ui/LoadingSpinner.tsx +43 -48
  236. package/.framework/src/components/ui/Modal.tsx +78 -68
  237. package/.framework/src/components/ui/RichTextEditor.tsx +89 -69
  238. package/.framework/src/components/ui/accordion.tsx +85 -86
  239. package/.framework/src/components/ui/alert-dialog.tsx +197 -184
  240. package/.framework/src/components/ui/alert.tsx +105 -94
  241. package/.framework/src/components/ui/aspect-ratio.tsx +57 -43
  242. package/.framework/src/components/ui/avatar.tsx +122 -107
  243. package/.framework/src/components/ui/badge.tsx +60 -55
  244. package/.framework/src/components/ui/breadcrumb.tsx +127 -128
  245. package/.framework/src/components/ui/button-group.tsx +86 -72
  246. package/.framework/src/components/ui/button.tsx +71 -50
  247. package/.framework/src/components/ui/calendar.tsx +72 -57
  248. package/.framework/src/components/ui/card.tsx +136 -129
  249. package/.framework/src/components/ui/carousel.tsx +226 -107
  250. package/.framework/src/components/ui/chart.tsx +252 -147
  251. package/.framework/src/components/ui/checkbox.tsx +43 -44
  252. package/.framework/src/components/ui/collapsible.tsx +86 -71
  253. package/.framework/src/components/ui/combobox.tsx +282 -249
  254. package/.framework/src/components/ui/command.tsx +158 -146
  255. package/.framework/src/components/ui/context-menu.tsx +239 -240
  256. package/.framework/src/components/ui/dialog.tsx +174 -157
  257. package/.framework/src/components/ui/direction.tsx +72 -56
  258. package/.framework/src/components/ui/drawer.tsx +168 -169
  259. package/.framework/src/components/ui/dropdown-menu.tsx +254 -223
  260. package/.framework/src/components/ui/empty.tsx +131 -120
  261. package/.framework/src/components/ui/field.tsx +205 -173
  262. package/.framework/src/components/ui/hover-card.tsx +71 -72
  263. package/.framework/src/components/ui/input-group.tsx +148 -133
  264. package/.framework/src/components/ui/input-otp.tsx +99 -86
  265. package/.framework/src/components/ui/input.tsx +43 -41
  266. package/.framework/src/components/ui/item.tsx +207 -185
  267. package/.framework/src/components/ui/kbd.tsx +57 -56
  268. package/.framework/src/components/ui/label.tsx +45 -41
  269. package/.framework/src/components/ui/menubar.tsx +268 -236
  270. package/.framework/src/components/ui/native-select.tsx +85 -86
  271. package/.framework/src/components/ui/navigation-menu.tsx +166 -156
  272. package/.framework/src/components/ui/pagination.tsx +131 -141
  273. package/.framework/src/components/ui/popover.tsx +125 -128
  274. package/.framework/src/components/ui/progress.tsx +47 -44
  275. package/.framework/src/components/ui/radio-group.tsx +60 -55
  276. package/.framework/src/components/ui/resizable.tsx +85 -72
  277. package/.framework/src/components/ui/scroll-area.tsx +57 -58
  278. package/.framework/src/components/ui/select.tsx +182 -169
  279. package/.framework/src/components/ui/separator.tsx +42 -43
  280. package/.framework/src/components/ui/sheet.tsx +170 -159
  281. package/.framework/src/components/ui/sidebar.tsx +395 -398
  282. package/.framework/src/components/ui/skeleton.tsx +42 -43
  283. package/.framework/src/components/ui/slider.tsx +61 -44
  284. package/.framework/src/components/ui/sonner.tsx +44 -44
  285. package/.framework/src/components/ui/spinner.tsx +47 -42
  286. package/.framework/src/components/ui/switch.tsx +56 -42
  287. package/.framework/src/components/ui/table-primitives.tsx +272 -132
  288. package/.framework/src/components/ui/table.tsx +140 -142
  289. package/.framework/src/components/ui/tabs.tsx +110 -93
  290. package/.framework/src/components/ui/textarea.tsx +43 -44
  291. package/.framework/src/components/ui/toggle-group.tsx +87 -71
  292. package/.framework/src/components/ui/toggle.tsx +56 -56
  293. package/.framework/src/components/ui/tooltip.tsx +99 -85
  294. package/.framework/src/contexts/AppContext.tsx +166 -114
  295. package/.framework/src/contexts/AuthContext.tsx +232 -137
  296. package/.framework/src/hooks/use-mobile.ts +43 -44
  297. package/.framework/src/hooks/useApi.ts +185 -172
  298. package/.framework/src/hooks/useAppPath.ts +31 -29
  299. package/.framework/src/hooks/useApps.ts +77 -42
  300. package/.framework/src/hooks/useEntityList.ts +66 -29
  301. package/.framework/src/hooks/useEntityRecord.ts +76 -32
  302. package/.framework/src/hooks/useForm.ts +62 -30
  303. package/.framework/src/hooks/useListSchema.ts +60 -43
  304. package/.framework/src/hooks/useSchemaRecord.ts +115 -95
  305. package/.framework/src/lib/api.ts +258 -134
  306. package/.framework/src/lib/registration.ts +181 -0
  307. package/.framework/src/lib/supabase.ts +118 -81
  308. package/.framework/src/lib/utils.ts +266 -266
  309. package/.framework/src/main.tsx +43 -44
  310. package/.framework/src/pages/DashboardPage.tsx +44 -43
  311. package/.framework/src/pages/NoAppPage.tsx +50 -0
  312. package/.framework/src/pages/NotFoundPage.tsx +32 -29
  313. package/.framework/src/pages/SetupPage.tsx +34 -33
  314. package/.framework/src/pages/admin/AIAgentDetailPage.tsx +69 -58
  315. package/.framework/src/pages/admin/AIAgentsPage.tsx +43 -40
  316. package/.framework/src/pages/admin/APIKeyDetailPage.tsx +63 -55
  317. package/.framework/src/pages/admin/APIKeysPage.tsx +44 -42
  318. package/.framework/src/pages/admin/AlertsConfigPage.tsx +117 -94
  319. package/.framework/src/pages/admin/AppDetailPage.tsx +48 -42
  320. package/.framework/src/pages/admin/AppsPage.tsx +45 -42
  321. package/.framework/src/pages/admin/DeliveriesPage.tsx +49 -17
  322. package/.framework/src/pages/admin/DesignedPage.tsx +31 -30
  323. package/.framework/src/pages/admin/EmbeddingDetailPage.tsx +58 -0
  324. package/.framework/src/pages/admin/EmbeddingsPage.tsx +49 -0
  325. package/.framework/src/pages/admin/ExtendedShadcnTestPage.tsx +31 -29
  326. package/.framework/src/pages/admin/IncrementalShadcnTestPage.tsx +46 -29
  327. package/.framework/src/pages/admin/IntegratedDashboard.tsx +32 -29
  328. package/.framework/src/pages/admin/IntegrationDetailPage.tsx +68 -55
  329. package/.framework/src/pages/admin/IntegrationsPage.tsx +45 -42
  330. package/.framework/src/pages/admin/InvitesPage.tsx +60 -44
  331. package/.framework/src/pages/admin/LogsPage.tsx +87 -137
  332. package/.framework/src/pages/admin/MinimalShadcnTestPage.tsx +31 -29
  333. package/.framework/src/pages/admin/ObservabilityDashboard.tsx +150 -89
  334. package/.framework/src/pages/admin/PipelineDetailPage.tsx +77 -104
  335. package/.framework/src/pages/admin/PipelineExecutionsPage.tsx +44 -43
  336. package/.framework/src/pages/admin/PipelinesPage.tsx +59 -145
  337. package/.framework/src/pages/admin/PromptConfigDetailPage.tsx +53 -42
  338. package/.framework/src/pages/admin/PromptConfigsPage.tsx +47 -117
  339. package/.framework/src/pages/admin/ProperlyDesignedPage.tsx +31 -44
  340. package/.framework/src/pages/admin/RoleDetailPage.tsx +49 -92
  341. package/.framework/src/pages/admin/RolesPage.tsx +47 -164
  342. package/.framework/src/pages/admin/SecurityPage.tsx +310 -0
  343. package/.framework/src/pages/admin/SelectTestPage.tsx +30 -32
  344. package/.framework/src/pages/admin/ShadcnTestPage.tsx +37 -44
  345. package/.framework/src/pages/admin/SimpleDashboard.tsx +32 -44
  346. package/.framework/src/pages/admin/TestRunDetailPage.tsx +97 -44
  347. package/.framework/src/pages/admin/TestingDashboard.tsx +126 -71
  348. package/.framework/src/pages/admin/TimerDetailPage.tsx +67 -55
  349. package/.framework/src/pages/admin/TimersPage.tsx +44 -42
  350. package/.framework/src/pages/admin/TriggerDetailPage.tsx +47 -42
  351. package/.framework/src/pages/admin/TriggersPage.tsx +58 -57
  352. package/.framework/src/pages/admin/TypeDetailPage.tsx +91 -55
  353. package/.framework/src/pages/admin/TypesPage.tsx +45 -42
  354. package/.framework/src/pages/admin/cil/CILAgentPage.tsx +258 -128
  355. package/.framework/src/pages/admin/cil/CILChunkDetailPage.tsx +127 -123
  356. package/.framework/src/pages/admin/cil/CILDashboardPage.tsx +308 -235
  357. package/.framework/src/pages/admin/cil/CILFileListPage.tsx +159 -110
  358. package/.framework/src/pages/admin/cil/CILFileSelectPage.tsx +432 -0
  359. package/.framework/src/pages/admin/cil/CILGraphPage.tsx +200 -178
  360. package/.framework/src/pages/admin/cil/CILIngestionPage.tsx +286 -239
  361. package/.framework/src/pages/admin/cil/CILProjectsPage.tsx +211 -90
  362. package/.framework/src/pages/admin/cil/CILSearchPage.tsx +156 -143
  363. package/.framework/src/pages/admin/cil/CILSuggestionsPage.tsx +379 -0
  364. package/.framework/src/pages/admin/cil/CILVersionsPage.tsx +337 -0
  365. package/.framework/src/pages/admin/cil/FlexiblePipelinePage.tsx +219 -214
  366. package/.framework/src/pages/admin/kb/KBAdminPage.tsx +64 -0
  367. package/.framework/src/pages/auth/AuthConfirmPage.tsx +135 -65
  368. package/.framework/src/pages/auth/ForgotPasswordPage.tsx +39 -31
  369. package/.framework/src/pages/auth/LoginPage.tsx +38 -32
  370. package/.framework/src/pages/auth/PendingApprovalPage.tsx +31 -28
  371. package/.framework/src/pages/auth/RegisterPage.tsx +429 -155
  372. package/.framework/src/pages/spine-framework/APIPage.tsx +33 -30
  373. package/.framework/src/pages/spine-framework/CLIPage.tsx +32 -30
  374. package/.framework/src/types/auth.ts +101 -93
  375. package/.framework/src/types/types.ts +283 -262
  376. package/.framework/templates/project.json +87 -0
  377. package/.framework/templates/spine.config.neutral.json +7 -0
  378. package/.framework/tests/api/api-surface.test.ts +381 -0
  379. package/.framework/tests/fixtures/seed.ts +427 -0
  380. package/.framework/tests/fixtures/teardown.ts +228 -0
  381. package/.framework/tests/reporter.ts +351 -0
  382. package/.framework/tests/setup.ts +135 -0
  383. package/.framework/tests/ui/ui-sweep.ts +278 -0
  384. package/.framework/tests/unit/admin-data-logger.test.ts +310 -0
  385. package/.framework/tests/unit/agent-runner.test.ts +2389 -0
  386. package/.framework/tests/unit/ai-interactions.test.ts +81 -0
  387. package/.framework/tests/unit/app-manifest.test.ts +359 -0
  388. package/.framework/tests/unit/assembly-scripts.test.ts +172 -0
  389. package/.framework/tests/unit/cil-determinism.test.ts +85 -0
  390. package/.framework/tests/unit/core-isolation.test.ts +153 -0
  391. package/.framework/tests/unit/funnel-signals.test.ts +135 -0
  392. package/.framework/tests/unit/install-app.test.ts +1759 -0
  393. package/.framework/tests/unit/invites-security.test.ts +572 -0
  394. package/.framework/tests/unit/kb-ingest-lease.test.ts +287 -0
  395. package/.framework/tests/unit/kb-search.test.ts +119 -0
  396. package/.framework/tests/unit/migrate.test.ts +509 -0
  397. package/.framework/tests/unit/notify.test.ts +136 -0
  398. package/.framework/tests/unit/permissions.test.ts +269 -0
  399. package/.framework/tests/unit/pipeline-runner.test.ts +755 -0
  400. package/.framework/tests/unit/principal-cache.test.ts +138 -0
  401. package/.framework/tests/unit/retrieval-golden.test.ts +520 -0
  402. package/.framework/tests/unit/runtime-isolation.test.ts +642 -0
  403. package/.framework/tests/unit/schema-utils.test.ts +225 -0
  404. package/.framework/tests/unit/trigger-engine.test.ts +513 -0
  405. package/.framework/tests/unit/validate-app.test.ts +527 -0
  406. package/README.md +34 -3
  407. package/bin/spine-framework.cjs +1 -0
  408. package/config/tailwind.config.cjs +7 -0
  409. package/config/tsconfig.functions.json +42 -0
  410. package/config/tsconfig.json +37 -9
  411. package/config/vite.config.ts +31 -2
  412. package/netlify.toml +31 -3
  413. package/package.json +46 -29
  414. package/scripts/assemble-frontend.sh +127 -44
  415. package/scripts/assemble-functions.sh +127 -29
  416. package/scripts/boundary-check.sh +6 -2
  417. package/scripts/build-manifest.sh +24 -68
  418. package/scripts/checksum-manifest.mts +345 -0
  419. package/scripts/dev-clean.sh +86 -0
  420. package/scripts/dev-netlify.sh +49 -0
  421. package/scripts/netlify-dev-wrapper.sh +2 -0
  422. package/scripts/verify-install.ts +358 -0
  423. package/scripts/verify-integrity.sh +21 -57
  424. package/scripts/verify-manifest.mts +305 -0
  425. package/templates/project/gitignore +45 -0
  426. package/{config → templates/project}/package-lock.json +22335 -9366
  427. package/vitest.config.ts +46 -0
  428. package/.framework/public/spine.config.json +0 -91
  429. package/config/deno.lock +0 -108
  430. package/config/tsconfig.node.tsbuildinfo +0 -1
  431. package/config/tsconfig.tsbuildinfo +0 -1
  432. package/config/vite.config.d.ts +0 -2
  433. package/custom/.devin/AGENT.md +0 -357
  434. package/custom/.devin/skills/install-app/SKILL.md +0 -39
  435. package/custom/.devin/skills/spine-workbench-discovery/SKILL.md +0 -39
  436. package/custom/.devin/skills/spine-workbench-idea/SKILL.md +0 -36
  437. package/custom/.devin/skills/spine-workbench-implement/SKILL.md +0 -46
  438. package/custom/.devin/skills/spine-workbench-initiative/SKILL.md +0 -28
  439. package/custom/.devin/skills/spine-workbench-plan/SKILL.md +0 -38
  440. package/custom/.devin/workflows/app-install.yaml +0 -83
  441. package/custom/README.md +0 -79
  442. package/docs/README.md +0 -15
  443. package/scripts/app-install-cli.ts +0 -286
  444. package/scripts/check-core-integrity.sh +0 -82
  445. package/scripts/ingest-chunks.cjs +0 -202
  446. package/scripts/kb-chunk-parser.cjs +0 -312
  447. package/scripts/kb-chunk-parser.ts +0 -330
  448. package/scripts/kb-ingest-docs.ts +0 -203
  449. package/scripts/load-test-app-install.ts +0 -484
  450. package/scripts/test-login.js +0 -33
  451. package/spine.config.json +0 -91
@@ -1,3 +1,11 @@
1
+ -- CIL[BEGIN stable_id="~/.framework/migrations/006_security_hardening_rls.sql:security_hardening_rls:file" type="file" identity="security_hardening_rls" parent="~/.framework/migrations/006_security_hardening_rls.sql"]
2
+ -- CIL[DOC-MACRO purpose="Apply migration 006 to close RLS bypasses for unauthenticated PostgREST requests and replace over-permissive types/watchers policies."]
3
+ -- CIL[DOC-RESPONSIBILITY responsibility="Update Row Level Security policies on integrations, api_keys, api_key_usage_logs, webhook_handlers, webhook_deliveries, items, types, and watchers to require authenticated or service-role access."]
4
+ -- CIL[DOC-CONTEXT module="migrations" layer="database" related_files=".framework/migrations/006_security_hardening_rls.sql"]
5
+ -- CIL[DOC-CONTRACT inputs="none" outputs="Recreated RLS policies for integrations, api_keys, api_key_usage_logs, webhook_handlers, webhook_deliveries, items, types, and watchers" errors="SQL errors if referenced helper functions or tables are missing" side_effects="Drops and recreates RLS policies on public tables, affecting PostgREST access control."]
6
+ -- CIL[DOC-MICRO logic_summary="Removes OR auth.uid() IS NULL / OR public.current_actor_id() IS NULL / OR true clauses from existing policies, then creates account-scoped policies using public.get_accessible_accounts and public.person_is_system_admin; types is split into a public read policy and admin-only write policies, while watchers is scoped to accessible accounts." notable_decisions="types: split SELECT for everyone from INSERT/UPDATE/DELETE for system-admins; watchers: remove always-true OR clause and scope to accessible accounts"]
7
+ -- CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
8
+ -- CIL[DOC-STABILITY stability="stable"]
1
9
  -- Security hardening: close RLS bypasses that allowed unauthenticated
2
10
  -- (no-JWT / anon-key-only) requests to read and write sensitive tables
3
11
  -- directly via PostgREST, and remove `OR true` policies that made
@@ -95,3 +103,10 @@ CREATE POLICY watchers_access ON public.watchers FOR ALL
95
103
 
96
104
  DROP POLICY IF EXISTS watchers_service_role ON public.watchers;
97
105
  CREATE POLICY watchers_service_role ON public.watchers FOR ALL TO service_role USING (true) WITH CHECK (true);
106
+ -- CIL[DOC-VECTOR type="context" content="purpose='Apply migration 006 to close RLS bypasses for unauthenticated PostgREST requests and replace over-permissive types/watchers policies.'; No verified external callers; imports: none"]
107
+ -- CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
108
+ -- CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
109
+ -- CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
110
+ -- CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
111
+ -- CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
112
+ -- CIL[END stable_id="~/.framework/migrations/006_security_hardening_rls.sql:security_hardening_rls:file"]
@@ -1,3 +1,12 @@
1
+ -- CIL[BEGIN stable_id="~/.framework/migrations/007_kb_article_list.sql:kb_article_list:file" type="file" identity="kb_article_list" parent="~/.framework/migrations/007_kb_article_list.sql"]
2
+ -- CIL[DOC-MACRO purpose="Creates the kb-article-list type, rebuild cache function, cache trigger, and seeds cache records for existing accounts."]
3
+ -- CIL[DOC-RESPONSIBILITY responsibility="Installs and maintains the cached ordered KB article tree for each account by rebuilding on structural item changes."]
4
+ -- CIL[DOC-CONTEXT module="knowledge-base" layer="migrations" related_files=".framework/migrations/007_kb_article_list.sql"]
5
+ -- CIL[DOC-CONTRACT inputs="none" outputs="public.types row for kb-article-list, public.rebuild_kb_cache function, public.trg_rebuild_kb_article_list trigger, seeded cache records" errors="none expected; slug conflicts upserted; trigger ignores non-KB types and cache record recursion" side_effects="Inserts or updates public.items cache rows, recalculates article trees on structural changes"]
6
+ -- CIL[DOC-MICRO logic_summary="Upserts the kb-article-list type with design and validation schemas, defines a function that aggregates ordered article trees by scope into a jsonb trees field, attaches an AFTER INSERT/UPDATE/DELETE trigger on public.items to rebuild when parent, order, title, status, or type change, and seeds global and account caches for existing data." notable_decisions="[]"]
7
+ -- CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
8
+ -- CIL[DOC-STABILITY stability="stable"]
9
+ -- CIL[DOC-NOTE type="caution" content="cil_validate_file reports perpetual drift_detected on whole-file .sql chunks (32-char stored vs ~16-char computed hash) — also true of untouched 008/009 migrations. Pre-existing hash-format quirk for SQL file chunks, not real drift."]
1
10
  -- KB article list cache: a single row per scope/account that stores the
2
11
  -- pre-built ordered tree of KB articles. Updated by trigger on structural
3
12
  -- changes (parent, order, title, status, type) but NOT on content edits.
@@ -50,7 +59,7 @@ VALUES (
50
59
  },
51
60
  "record_permissions": {
52
61
  "all": ["read"],
53
- "system-admin": ["create", "read", "update", "delete"],
62
+ "system_admin": ["create", "read", "update", "delete"],
54
63
  "admin": ["create", "read", "update", "delete"],
55
64
  "member": ["read"]
56
65
  },
@@ -235,3 +244,10 @@ BEGIN
235
244
  PERFORM public.rebuild_kb_cache(acc_id, 'account');
236
245
  END LOOP;
237
246
  END $$;
247
+ -- CIL[DOC-VECTOR type="context" content="purpose='Creates the kb-article-list type, rebuild cache function, cache trigger, and seeds cache records for existing accounts.'; No verified external callers; imports: none"]
248
+ -- CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
249
+ -- CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
250
+ -- CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
251
+ -- CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
252
+ -- CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
253
+ -- CIL[END stable_id="~/.framework/migrations/007_kb_article_list.sql:kb_article_list:file"]
@@ -1,3 +1,11 @@
1
+ -- CIL[BEGIN stable_id="~/.framework/migrations/008_items_target.sql:items_target:file" type="file" identity="items_target" parent="~/.framework/migrations/008_items_target.sql"]
2
+ -- CIL[DOC-MACRO purpose="Add target scoping columns to public.items so any item can be explicitly scoped to a person or account."]
3
+ -- CIL[DOC-RESPONSIBILITY responsibility="Apply schema migration that introduces target_type and target_id columns and an index for target-based lookups."]
4
+ -- CIL[DOC-CONTEXT module="schema" layer="migration" related_files=".framework/migrations/008_items_target.sql"]
5
+ -- CIL[DOC-CONTRACT inputs="Existing public.items table." outputs="public.items with target_type and target_id columns and idx_items_target index." errors="Fails if public.items does not exist or if the executing role lacks ALTER/CREATE INDEX privileges." side_effects="Modifies public.items table schema and creates a new index."]
6
+ -- CIL[DOC-MICRO logic_summary="Use IF NOT EXISTS clauses to idempotently add target_type text and target_id uuid columns, then create a composite index on (target_type, target_id)." notable_decisions="[]"]
7
+ -- CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
8
+ -- CIL[DOC-STABILITY stability="stable"]
1
9
  -- Add target scoping columns to public.items to align with threads, links, and watchers.
2
10
  -- This lets any item (note, ticket, deal, etc.) be explicitly scoped to a person or account.
3
11
 
@@ -6,3 +14,10 @@ ALTER TABLE public.items
6
14
  ADD COLUMN IF NOT EXISTS target_id uuid;
7
15
 
8
16
  CREATE INDEX IF NOT EXISTS idx_items_target ON public.items (target_type, target_id);
17
+ -- CIL[DOC-VECTOR type="context" content="purpose='Add target scoping columns to public.items so any item can be explicitly scoped to a person or account.'; No verified external callers; imports: none"]
18
+ -- CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
19
+ -- CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
20
+ -- CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
21
+ -- CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
22
+ -- CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
23
+ -- CIL[END stable_id="~/.framework/migrations/008_items_target.sql:items_target:file"]
@@ -1,3 +1,11 @@
1
+ -- CIL[BEGIN stable_id="~/.framework/migrations/009_roles_slug_unique.sql:roles_slug_unique:file" type="file" identity="roles_slug_unique" parent="~/.framework/migrations/009_roles_slug_unique.sql"]
2
+ -- CIL[DOC-MACRO purpose="Ensure the public.roles slug column has a unique index, dropping any prior app_id+slug constraints."]
3
+ -- CIL[DOC-RESPONSIBILITY responsibility="Apply a one-time, idempotent schema change to enforce slug uniqueness across roles."]
4
+ -- CIL[DOC-CONTEXT module="roles" layer="migrations" related_files=".framework/migrations/009_roles_slug_unique.sql"]
5
+ -- CIL[DOC-CONTRACT inputs="public.roles table with slug column" outputs="Unique index roles_slug_key on public.roles(slug)" errors="Constraint-violation if duplicate slugs exist" side_effects="Drops roles_app_id_slug_key constraint and index if present"]
6
+ -- CIL[DOC-MICRO logic_summary="Drops the old constraint and index, then creates a unique index on slug" notable_decisions="[]"]
7
+ -- CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
8
+ -- CIL[DOC-STABILITY stability="stable"]
1
9
  -- Idempotent: safe for fresh (001 already has this) and existing DBs.
2
10
  -- If duplicates exist, the DBA must dedupe before running; this migration
3
11
  -- will fail with a clear constraint-violation error until they do.
@@ -9,3 +17,10 @@ DROP INDEX IF EXISTS roles_app_id_slug_key;
9
17
 
10
18
  CREATE UNIQUE INDEX IF NOT EXISTS roles_slug_key
11
19
  ON public.roles (slug);
20
+ -- CIL[DOC-VECTOR type="context" content="purpose='Ensure the public.roles slug column has a unique index, dropping any prior app_id+slug constraints.'; No verified external callers; imports: none"]
21
+ -- CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
22
+ -- CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
23
+ -- CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
24
+ -- CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
25
+ -- CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
26
+ -- CIL[END stable_id="~/.framework/migrations/009_roles_slug_unique.sql:roles_slug_unique:file"]
@@ -1,3 +1,11 @@
1
+ -- CIL[BEGIN stable_id="~/.framework/migrations/010_auth_user_trigger.sql:auth_user_trigger:file" type="file" identity="auth_user_trigger" parent="~/.framework/migrations/010_auth_user_trigger.sql"]
2
+ -- CIL[DOC-MACRO purpose="PostgreSQL trigger function and trigger that synchronizes newly created auth.users records into public.people, linking existing stubs and promoting the first user to system admin."]
3
+ -- CIL[DOC-RESPONSIBILITY responsibility="Keep the public.people table in sync with auth.users on insert, resolve pending or invited person stubs, and assign the first registered user the system_admin role."]
4
+ -- CIL[DOC-CONTEXT module="auth" layer="migrations" related_files=".framework/migrations/010_auth_user_trigger.sql"]
5
+ -- CIL[DOC-CONTRACT inputs="NEW auth.users row with id, email, raw_user_meta_data" outputs="Unchanged NEW row; public.people row inserted or updated" errors="No raised errors; warnings emitted if spine-system account or person type is missing" side_effects="Inserts or updates public.people and installs an AFTER INSERT trigger on auth.users"]
6
+ -- CIL[DOC-MICRO logic_summary="Resolve the spine-system account and person type, then either link an existing pending/invited people stub by email or insert a new people record, assigning the system_admin role to the first registered user. Finally, drop and recreate the trigger." notable_decisions="[]"]
7
+ -- CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
8
+ -- CIL[DOC-STABILITY stability="stable"]
1
9
  -- Create trigger function to sync new auth users to people records
2
10
  CREATE OR REPLACE FUNCTION public.handle_new_auth_user()
3
11
  RETURNS TRIGGER LANGUAGE plpgsql SECURITY DEFINER SET search_path = public AS $$
@@ -80,3 +88,10 @@ DROP TRIGGER IF EXISTS on_auth_user_created ON auth.users;
80
88
  CREATE TRIGGER on_auth_user_created
81
89
  AFTER INSERT ON auth.users
82
90
  FOR EACH ROW EXECUTE FUNCTION public.handle_new_auth_user();
91
+ -- CIL[DOC-VECTOR type="context" content="purpose='PostgreSQL trigger function and trigger that synchronizes newly created auth.users records into public.people, linking existing stubs and promoting the first user to system admin.'; No verified external callers; imports: none"]
92
+ -- CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
93
+ -- CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
94
+ -- CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
95
+ -- CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
96
+ -- CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
97
+ -- CIL[END stable_id="~/.framework/migrations/010_auth_user_trigger.sql:auth_user_trigger:file"]
@@ -1,3 +1,12 @@
1
+ -- CIL[BEGIN stable_id="~/.framework/migrations/011_spine_system_account.sql:spine_system_account:file" type="file" identity="spine_system_account" parent="~/.framework/migrations/011_spine_system_account.sql"]
2
+ -- CIL[DOC-MACRO purpose="Seed the account type and spine-system master account"]
3
+ -- CIL[DOC-RESPONSIBILITY responsibility="Ensure the runtime account type and master account exist for auth and registration flows"]
4
+ -- CIL[DOC-CONTEXT module="migrations" layer="data" related_files=".framework/migrations/011_spine_system_account.sql"]
5
+ -- CIL[DOC-CONTRACT inputs="none" outputs="public.types row for account; public.accounts row for spine-system" errors="none" side_effects="Inserts rows into public.types and public.accounts when missing"]
6
+ -- CIL[DOC-MICRO logic_summary="Inserts the account type into public.types with a full design schema if absent, then inserts the spine-system master account using that type if it does not already exist." notable_decisions="[]"]
7
+ -- CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
8
+ -- CIL[DOC-STABILITY stability="stable"]
9
+
1
10
  -- Seed the account type and Spine system master account required by the auth trigger and existing-account registration flow
2
11
 
3
12
  -- Ensure the runtime account type exists
@@ -60,3 +69,10 @@ SELECT
60
69
  FROM public.types t
61
70
  WHERE t.kind = 'account' AND t.slug = 'account'
62
71
  AND NOT EXISTS (SELECT 1 FROM public.accounts a WHERE a.slug = 'spine-system');
72
+ -- CIL[DOC-VECTOR type="context" content="purpose='Seed the account type and spine-system master account'; No verified external callers; imports: none"]
73
+ -- CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
74
+ -- CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
75
+ -- CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
76
+ -- CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
77
+ -- CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
78
+ -- CIL[END stable_id="~/.framework/migrations/011_spine_system_account.sql:spine_system_account:file"]
@@ -1,3 +1,12 @@
1
+ -- CIL[BEGIN stable_id="~/.framework/migrations/012_service_role_grants.sql:service_role_grants:file" type="file" identity="service_role_grants" parent="~/.framework/migrations/012_service_role_grants.sql"]
2
+ -- CIL[DOC-MACRO purpose="Define core schema privileges for Supabase auth roles to enable first-user registration and auth lookups."]
3
+ -- CIL[DOC-RESPONSIBILITY responsibility="Grant usage, select, and CRUD privileges on the public schema to anon, authenticated, and service_role, and set default privileges for future objects."]
4
+ -- CIL[DOC-CONTEXT module="migrations" layer="database" related_files=".framework/migrations/012_service_role_grants.sql"]
5
+ -- CIL[DOC-CONTRACT inputs="SQL execution context in a Supabase migration" outputs="Granted privileges on public schema and default privileges for auth roles" errors="Migration failure if roles or schema public are missing" side_effects="Modifies database grants and default privileges for future objects"]
6
+ -- CIL[DOC-MICRO logic_summary="Grant USAGE on schema public to anon, authenticated, and service_role; grant SELECT on all tables and sequences to authenticated; grant full CRUD on tables and sequences to service_role; configure default privileges for future objects." notable_decisions="[]"]
7
+ -- CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
8
+ -- CIL[DOC-STABILITY stability="stable"]
9
+
1
10
  -- Spine v2: core schema privileges for Supabase auth roles
2
11
  --
3
12
  -- Without these grants, a fresh Supabase project denies "schema public"
@@ -20,3 +29,10 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO authenticate
20
29
  ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE, SELECT ON SEQUENCES TO authenticated;
21
30
  ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO service_role;
22
31
  ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE, SELECT ON SEQUENCES TO service_role;
32
+ -- CIL[DOC-VECTOR type="context" content="purpose='Define core schema privileges for Supabase auth roles to enable first-user registration and auth lookups.'; No verified external callers; imports: none"]
33
+ -- CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
34
+ -- CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
35
+ -- CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
36
+ -- CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
37
+ -- CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
38
+ -- CIL[END stable_id="~/.framework/migrations/012_service_role_grants.sql:service_role_grants:file"]
@@ -1,3 +1,11 @@
1
+ -- CIL[BEGIN stable_id="~/.framework/migrations/013_get_account_apps_role_filter.sql:get_account_apps_role_filter:file" type="file" identity="get_account_apps_role_filter" parent="~/.framework/migrations/013_get_account_apps_role_filter.sql"]
2
+ -- CIL[DOC-MACRO purpose="Adds role-based filtering to the public.get_account_apps function so non-system-admin users only see apps allowed by their assigned role slugs."]
3
+ -- CIL[DOC-RESPONSIBILITY responsibility="Define the security-definer get_account_apps SQL function, including overload cleanup and role-aware access filtering."]
4
+ -- CIL[DOC-CONTEXT module="migrations" layer="database" related_files=".framework/migrations/013_get_account_apps_role_filter.sql"]
5
+ -- CIL[DOC-CONTRACT inputs="uuid account_id, boolean include_system=true, boolean include_inactive=false, text[] user_role_slugs=null, boolean is_system_admin=false" outputs="TABLE of app columns filtered by ownership, active state, and role requirements" errors="none" side_effects="Drops and recreates get_account_apps function overloads in the public schema."]
6
+ -- CIL[DOC-MICRO logic_summary="Drops overloaded get_account_apps signatures, then creates a security-definer function returning app rows. Filters combine active/owner/system rules with optional role checks: when user_role_slugs is provided and the caller is not a system admin, only apps with matching required_roles or min_role are returned." notable_decisions="[]"]
7
+ -- CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
8
+ -- CIL[DOC-STABILITY stability="stable"]
1
9
  -- Update get_account_apps to support role-based filtering.
2
10
  -- This signature matches the .rpc call in .framework/functions/apps.ts,
3
11
  -- which passes user_role_slugs and is_system_admin.
@@ -98,3 +106,10 @@ BEGIN
98
106
  a.name;
99
107
  END;
100
108
  $$;
109
+ -- CIL[DOC-VECTOR type="context" content="purpose='Adds role-based filtering to the public.get_account_apps function so non-system-admin users only see apps allowed by their assigned role slugs.'; No verified external callers; imports: none"]
110
+ -- CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
111
+ -- CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
112
+ -- CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
113
+ -- CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
114
+ -- CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
115
+ -- CIL[END stable_id="~/.framework/migrations/013_get_account_apps_role_filter.sql:get_account_apps_role_filter:file"]
@@ -1,3 +1,12 @@
1
+ -- CIL[BEGIN stable_id="~/.framework/migrations/014_apps_required_roles.sql:apps_required_roles:file" type="file" identity="apps_required_roles" parent="~/.framework/migrations/014_apps_required_roles.sql"]
2
+ -- CIL[DOC-MACRO purpose="Adds and backfills a required_roles jsonb column on the public.apps table so that app records can carry a list of roles needed for access."]
3
+ -- CIL[DOC-RESPONSIBILITY responsibility="Schema migration: add required_roles column to public.apps and backfill from min_role."]
4
+ -- CIL[DOC-CONTEXT module="framework" layer="migrations" related_files=".framework/migrations/014_apps_required_roles.sql"]
5
+ -- CIL[DOC-CONTRACT inputs="public.apps table with existing min_role column" outputs="public.apps table with required_roles jsonb column populated for rows having min_role" errors="SQL execution errors, jsonb cast issues" side_effects="Adds column if missing; updates existing rows."]
6
+ -- CIL[DOC-MICRO logic_summary="Add required_roles jsonb defaulting to empty array; then set it to a jsonb array containing the existing min_role for rows with min_role and empty/null required_roles." notable_decisions="[]"]
7
+ -- CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
8
+ -- CIL[DOC-STABILITY stability="stable"]
9
+
1
10
  -- Add required_roles jsonb column to apps table for get_account_apps filtering.
2
11
  ALTER TABLE public.apps
3
12
  ADD COLUMN IF NOT EXISTS required_roles jsonb DEFAULT '[]'::jsonb;
@@ -7,3 +16,10 @@ UPDATE public.apps
7
16
  SET required_roles = jsonb_build_array(min_role)
8
17
  WHERE min_role IS NOT NULL
9
18
  AND (required_roles = '[]'::jsonb OR required_roles IS NULL);
19
+ -- CIL[DOC-VECTOR type="context" content="purpose='Adds and backfills a required_roles jsonb column on the public.apps table so that app records can carry a list of roles needed for access.'; No verified external callers; imports: none"]
20
+ -- CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
21
+ -- CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
22
+ -- CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
23
+ -- CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
24
+ -- CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
25
+ -- CIL[END stable_id="~/.framework/migrations/014_apps_required_roles.sql:apps_required_roles:file"]
@@ -1,5 +1,20 @@
1
+ -- CIL[BEGIN stable_id="~/.framework/migrations/015_types_kind_slug_unique.sql:types_kind_slug_unique:file" type="file" identity="types_kind_slug_unique" parent="~/.framework/migrations/015_types_kind_slug_unique.sql"]
2
+ -- CIL[DOC-MACRO purpose="Enforce global uniqueness of type slugs across all apps"]
3
+ -- CIL[DOC-RESPONSIBILITY responsibility="Ensure deterministic resolveTypeId and resolveTypeRecord single lookups for shared kind/slug values"]
4
+ -- CIL[DOC-CONTEXT module="migrations" layer="data" related_files=".framework/migrations/015_types_kind_slug_unique.sql"]
5
+ -- CIL[DOC-CONTRACT inputs="public.types table with kind and slug columns" outputs="types_kind_slug_unique unique index on public.types(kind, slug)" errors="Duplicate (kind, slug) values cause uniqueness violation" side_effects="Creates a database index that enforces uniqueness on public.types writes"]
6
+ -- CIL[DOC-MICRO logic_summary="Create a unique composite index IF NOT EXISTS on public.types(kind, slug)" notable_decisions="[]"]
7
+ -- CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
8
+ -- CIL[DOC-STABILITY stability="stable"]
1
9
  -- Enforce global uniqueness of type slugs across all apps.
2
10
  -- This lets multiple apps share the same kind/slug (e.g. funnel_signal, support_ticket)
3
11
  -- and makes resolveTypeId/resolveTypeRecord .single() lookups deterministic.
4
12
  CREATE UNIQUE INDEX IF NOT EXISTS types_kind_slug_unique
5
13
  ON public.types (kind, slug);
14
+ -- CIL[DOC-VECTOR type="context" content="purpose='Enforce global uniqueness of type slugs across all apps'; No verified external callers; imports: none"]
15
+ -- CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
16
+ -- CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
17
+ -- CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
18
+ -- CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
19
+ -- CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
20
+ -- CIL[END stable_id="~/.framework/migrations/015_types_kind_slug_unique.sql:types_kind_slug_unique:file"]
@@ -0,0 +1,281 @@
1
+ -- CIL[BEGIN stable_id="~/.framework/migrations/016_cil_types.sql:cil_types:file" type="file" identity="cil_types" parent="~/.framework/migrations/016_cil_types.sql"]
2
+ -- CIL[DOC-MACRO purpose="Upsert core CIL runtime types and link relation types for spine-core"]
3
+ -- CIL[DOC-RESPONSIBILITY responsibility="Ensure public.types and public.link_types contain the CIL account, project, file, chunk, proposal, config, learning, version, suggestion, and link-type rows needed by the CIL pipeline"]
4
+ -- CIL[DOC-CONTEXT module="migrations" layer="framework" related_files=".framework/migrations/016_cil_types.sql"]
5
+ -- CIL[DOC-CONTRACT inputs="Existing public.apps row with slug 'spine-core'" outputs="Active type and link_type rows for all CIL kinds" errors="NULL app_id selected if spine-core app missing" side_effects="Inserts or updates rows in public.types and public.link_types"]
6
+ -- CIL[DOC-MICRO logic_summary="Resolves the spine-core app id, then loops through UPSERT statements for each CIL item type and each CIL link type using ON CONFLICT (kind, slug) / (app_id, slug)" notable_decisions="[]"]
7
+ -- CIL[DOC-CONFIDENCE pass="second" score="0.90" flags="none"]
8
+ -- CIL[DOC-STABILITY stability="stable"]
9
+ -- CIL types: move to core, add version/suggestion types, align permissions and stable-ID fields.
10
+ -- This migration upserts types on (kind, slug) so existing CIL records keep their type_id.
11
+ DO $$
12
+ DECLARE
13
+ v_spine_core_app_id uuid;
14
+ BEGIN
15
+ SELECT id INTO v_spine_core_app_id FROM public.apps WHERE slug = 'spine-core' LIMIT 1;
16
+
17
+ INSERT INTO public.types (id, app_id, kind, slug, name, description, icon, color, design_schema, validation_schema, ownership, is_active)
18
+ VALUES (
19
+ gen_random_uuid(),
20
+ v_spine_core_app_id,
21
+ 'item',
22
+ 'cil_project',
23
+ 'CIL Project',
24
+ 'A codebase registered in the Code Intelligence Layer for graph ingestion and analysis',
25
+ 'folder-git-2',
26
+ '#6366F1',
27
+ $DESIGN${"scope":"account","fields":{"repo_path":{"label":"Repository Path","data_type":"text","required":false},"language_mix":{"label":"Languages","data_type":"text","required":false},"file_count":{"label":"File Count","data_type":"number","required":false},"chunk_count":{"label":"Chunk Count","data_type":"number","required":false},"ingestion_status":{"label":"Ingestion Status","data_type":"select","options":[{"label":"Not Started","value":"not_started"},{"label":"In Progress","value":"in_progress"},{"label":"Complete","value":"complete"}],"required":false},"total_ingestion_cost_usd":{"label":"Total Ingestion Cost (USD)","data_type":"number","required":false},"last_ingested_at":{"label":"Last Ingested At","data_type":"text","required":false},"kb_type":{"label":"KB Type","data_type":"text","required":false},"npm_name":{"data_type":"text","label":"NPM Package Name","required":true},"canonical_root":{"data_type":"text","label":"Canonical Root","required":false},"active_version_id":{"data_type":"text","label":"Active Version ID","required":false},"default_version_id":{"data_type":"text","label":"Default Version ID","required":false},"dependencies":{"data_type":"json","label":"Dependencies","required":false}},"record_permissions":{"system_admin":["create","read","update","delete"],"engineering_admin":["create","read","update","delete"],"engineering":["create","read","update"],"devops":["create","read","update"],"product":["create","read","update"],"docs":["create","read","update"],"qa":["create","read","update"],"management":["create","read","update"],"support_admin":["create","read","update"],"support":["read"],"csm":["read"],"tam":["read"],"sales":["read"],"member_admin":["read","update"],"member":["read"]},"functionality":null,"vector_types":["semantic"]}$DESIGN$::jsonb,
28
+ '{}'::jsonb,
29
+ 'tenant',
30
+ true
31
+ )
32
+ ON CONFLICT (kind, slug) DO UPDATE SET
33
+ app_id = EXCLUDED.app_id,
34
+ name = EXCLUDED.name,
35
+ description = EXCLUDED.description,
36
+ icon = EXCLUDED.icon,
37
+ color = EXCLUDED.color,
38
+ design_schema = EXCLUDED.design_schema,
39
+ validation_schema = EXCLUDED.validation_schema,
40
+ ownership = EXCLUDED.ownership,
41
+ is_active = EXCLUDED.is_active;
42
+
43
+ INSERT INTO public.types (id, app_id, kind, slug, name, description, icon, color, design_schema, validation_schema, ownership, is_active)
44
+ VALUES (
45
+ gen_random_uuid(),
46
+ v_spine_core_app_id,
47
+ 'item',
48
+ 'cil_file',
49
+ 'CIL File',
50
+ 'A source file within a CIL project — tracks ingestion pass, hash, and dead code status',
51
+ 'file-code-2',
52
+ '#8B5CF6',
53
+ $DESIGN${"scope":"account","fields":{"file_path":{"label":"File Path","data_type":"text","required":false},"language":{"label":"Language","data_type":"text","required":false},"project_id":{"label":"Project ID","data_type":"text","required":false},"stored_hash":{"label":"Stored Hash","data_type":"text","required":false},"ingestion_pass":{"label":"Ingestion Pass","data_type":"number","required":false},"chunk_count":{"label":"Chunk Count","data_type":"number","required":false},"has_existing_markers":{"label":"Had Existing Markers","data_type":"boolean","required":false},"is_dead_code":{"label":"Dead Code","data_type":"boolean","required":false},"git_last_commit":{"label":"Git Last Commit","data_type":"text","required":false},"existing_marker_agreement_count":{"label":"Marker Agreement Count","data_type":"number","required":false},"existing_marker_disagreement_count":{"label":"Marker Disagreement Count","data_type":"number","required":false},"line_count":{"label":"Line Count","data_type":"number","required":false},"existing_marker_names":{"label":"Existing Marker Names","data_type":"text","required":false},"existing_marker_count":{"label":"Existing Marker Count","data_type":"number","required":false},"kb_type":{"label":"KB Type","data_type":"text","required":false},"stable_id":{"data_type":"text","label":"Stable ID","required":true},"version_id":{"data_type":"text","label":"Version ID","required":true},"file_hash":{"data_type":"text","label":"File Hash","required":false},"content_hash":{"data_type":"text","label":"Content Hash","required":false},"dead_reason":{"data_type":"text","label":"Dead Reason","required":false}},"record_permissions":{"system_admin":["create","read","update","delete"],"engineering_admin":["create","read","update","delete"],"engineering":["create","read","update"],"devops":["create","read","update"],"product":["create","read","update"],"docs":["create","read","update"],"qa":["create","read","update"],"management":["create","read","update"],"support_admin":["create","read","update"],"support":["read"],"csm":["read"],"tam":["read"],"sales":["read"],"member_admin":["read","update"],"member":["read"]},"functionality":null}$DESIGN$::jsonb,
54
+ '{}'::jsonb,
55
+ 'tenant',
56
+ true
57
+ )
58
+ ON CONFLICT (kind, slug) DO UPDATE SET
59
+ app_id = EXCLUDED.app_id,
60
+ name = EXCLUDED.name,
61
+ description = EXCLUDED.description,
62
+ icon = EXCLUDED.icon,
63
+ color = EXCLUDED.color,
64
+ design_schema = EXCLUDED.design_schema,
65
+ validation_schema = EXCLUDED.validation_schema,
66
+ ownership = EXCLUDED.ownership,
67
+ is_active = EXCLUDED.is_active;
68
+
69
+ INSERT INTO public.types (id, app_id, kind, slug, name, description, icon, color, design_schema, validation_schema, ownership, is_active)
70
+ VALUES (
71
+ gen_random_uuid(),
72
+ v_spine_core_app_id,
73
+ 'item',
74
+ 'cil_chunk',
75
+ 'CIL Chunk',
76
+ 'A semantically meaningful chunk within a CIL file — carries inline contract, hash, and graph edges',
77
+ 'code-2',
78
+ '#10B981',
79
+ $DESIGN${"scope":"account","fields":{"chunk_name":{"label":"Chunk Name","data_type":"text","required":false},"file_id":{"label":"File ID","data_type":"text","required":false},"project_id":{"label":"Project ID","data_type":"text","required":false},"file_path":{"label":"File Path","data_type":"text","required":false},"line_start":{"label":"Line Start","data_type":"number","required":false},"line_end":{"label":"Line End","data_type":"number","required":false},"chunk_type":{"label":"Chunk Type","data_type":"select","options":[{"label":"Function","value":"function"},{"label":"Class","value":"class"},{"label":"Interface","value":"interface"},{"label":"Type","value":"type"},{"label":"Component","value":"component"},{"label":"Hook","value":"hook"},{"label":"Route","value":"route"},{"label":"Config","value":"config"}],"required":false},"stored_hash":{"label":"Stored Hash","data_type":"text","required":false},"boundary_confidence":{"label":"Boundary Confidence","data_type":"select","options":[{"label":"High","value":"high"},{"label":"Low","value":"low"},{"label":"Human Verified","value":"human_verified"}],"required":false},"boundary_source":{"label":"Boundary Source","data_type":"select","options":[{"label":"AST Auto","value":"ast_auto"},{"label":"AST Approved","value":"ast_approved"},{"label":"Human Override","value":"human_override"}],"required":false},"review_status":{"label":"Review Status","data_type":"select","options":[{"label":"Pending Review","value":"pending_review"},{"label":"Approved","value":"approved"},{"label":"Rejected","value":"rejected"}],"required":false},"doc_confidence":{"label":"Doc Confidence","data_type":"select","options":[{"label":"AI Generated","value":"ai_generated"},{"label":"Human Verified","value":"human_verified"},{"label":"Unverified Legacy","value":"unverified_legacy"}],"required":false},"is_dead_code":{"label":"Dead Code","data_type":"boolean","required":false},"description":{"label":"Description","data_type":"textarea","required":false},"macro":{"label":"Macro (Purpose)","data_type":"text","required":false},"micro":{"label":"Micro (Detail)","data_type":"text","required":false},"input_spec":{"label":"Input Spec","data_type":"textarea","required":false},"output_spec":{"label":"Output Spec","data_type":"text","required":false},"throws":{"label":"Throws","data_type":"text","required":false},"side_effects":{"label":"Side Effects","data_type":"text","required":false},"calls":{"label":"Calls","data_type":"text","required":false},"called_by":{"label":"Called By","data_type":"text","required":false},"error_handling":{"label":"Error Handling","data_type":"text","required":false},"tags":{"label":"Tags","data_type":"text","required":false},"complexity":{"label":"Complexity","data_type":"select","options":[{"label":"Simple","value":"simple"},{"label":"Moderate","value":"moderate"},{"label":"Complex","value":"complex"}],"required":false},"stability":{"label":"Stability","data_type":"select","options":[{"label":"Stable","value":"stable"},{"label":"Internal","value":"internal"},{"label":"Experimental","value":"experimental"},{"label":"Deprecated","value":"deprecated"}],"required":false},"module":{"label":"Module Name","data_type":"text","required":false},"audience":{"label":"Audience","data_type":"select","options":[{"label":"Internal","value":"internal"},{"label":"External","value":"external"},{"label":"Both","value":"both"}],"required":false},"layer":{"label":"Layer","data_type":"select","options":[{"label":"Shared Core","value":"shared-core"},{"label":"App Specific","value":"app-specific"},{"label":"Infrastructure","value":"infrastructure"},{"label":"Test","value":"test"}],"required":false},"see_also":{"label":"See Also","data_type":"textarea","required":false},"doc_validation_errors":{"label":"Doc Validation Errors","data_type":"text","required":false},"test_unit_path":{"label":"Unit Test Path","data_type":"text","required":false},"test_e2e_path":{"label":"E2E Test Path","data_type":"text","required":false},"token_count":{"label":"Token Count","data_type":"number","required":false},"existing_marker_agreement":{"label":"Existing Marker Agreement","data_type":"select","options":[{"label":"None (no prior marker)","value":"none"},{"label":"Agreed","value":"agreed"},{"label":"Disagreed","value":"disagreed"}],"required":false},"code_content":{"label":"Code Content","data_type":"textarea","required":false},"hash_updated_at":{"label":"Hash Updated At","data_type":"text","required":false},"kb_type":{"label":"KB Type","data_type":"text","required":false},"stable_id":{"data_type":"text","label":"Stable ID","required":true},"version_id":{"data_type":"text","label":"Version ID","required":true},"parent_stable_id":{"data_type":"text","label":"Parent Stable ID","required":false},"content_hash":{"data_type":"text","label":"Content Hash","required":false},"file_hash":{"data_type":"text","label":"File Hash","required":false},"legacy_chunk_id":{"data_type":"text","label":"Legacy Chunk ID","required":false},"embedding_types":{"data_type":"json","label":"Embedding Types","required":false},"embedding_ids":{"data_type":"json","label":"Embedding IDs","required":false}},"record_permissions":{"system_admin":["create","read","update","delete"],"engineering_admin":["create","read","update","delete"],"engineering":["create","read","update"],"devops":["create","read","update"],"product":["create","read","update"],"docs":["create","read","update"],"qa":["create","read","update"],"management":["create","read","update"],"support_admin":["create","read","update"],"support":["read"],"csm":["read"],"tam":["read"],"sales":["read"],"member_admin":["read","update"],"member":["read"]},"functionality":null,"vector_types":["semantic","structural","contract"],"embedding_fields":{"structural":["chunk_type","file_path","stability","is_dead_code","boundary_confidence","doc_confidence","review_status"]}}$DESIGN$::jsonb,
80
+ '{}'::jsonb,
81
+ 'tenant',
82
+ true
83
+ )
84
+ ON CONFLICT (kind, slug) DO UPDATE SET
85
+ app_id = EXCLUDED.app_id,
86
+ name = EXCLUDED.name,
87
+ description = EXCLUDED.description,
88
+ icon = EXCLUDED.icon,
89
+ color = EXCLUDED.color,
90
+ design_schema = EXCLUDED.design_schema,
91
+ validation_schema = EXCLUDED.validation_schema,
92
+ ownership = EXCLUDED.ownership,
93
+ is_active = EXCLUDED.is_active;
94
+
95
+ INSERT INTO public.types (id, app_id, kind, slug, name, description, icon, color, design_schema, validation_schema, ownership, is_active)
96
+ VALUES (
97
+ gen_random_uuid(),
98
+ v_spine_core_app_id,
99
+ 'item',
100
+ 'cil_chunk_proposal',
101
+ 'CIL Chunk Proposal',
102
+ 'Staged low-confidence chunk boundary proposal awaiting human or Devin review before being written to source file',
103
+ 'git-pull-request',
104
+ '#F59E0B',
105
+ $DESIGN${"scope":"account","fields":{"file_id":{"label":"File ID","data_type":"text","required":false},"project_id":{"label":"Project ID","data_type":"text","required":false},"file_path":{"label":"File Path","data_type":"text","required":false},"proposed_name":{"label":"Proposed Chunk Name","data_type":"text","required":false},"line_start":{"label":"Line Start","data_type":"number","required":false},"line_end":{"label":"Line End","data_type":"number","required":false},"chunk_type":{"label":"Chunk Type","data_type":"text","required":false},"confidence_score":{"label":"Confidence Score","data_type":"number","required":false},"confidence_reasons":{"label":"Confidence Reasons","data_type":"text","required":false},"existing_marker_match":{"label":"Matches Existing Marker","data_type":"boolean","required":false},"existing_marker_name":{"label":"Existing Marker Name","data_type":"text","required":false},"review_status":{"label":"Review Status","data_type":"select","options":[{"label":"Pending Review","value":"pending_review"},{"label":"Approved","value":"approved"},{"label":"Rejected","value":"rejected"},{"label":"Merged","value":"merged"}],"required":false},"reviewed_by":{"label":"Reviewed By","data_type":"text","required":false},"reviewed_at":{"label":"Reviewed At","data_type":"text","required":false},"adjusted_line_start":{"label":"Adjusted Line Start","data_type":"number","required":false},"adjusted_line_end":{"label":"Adjusted Line End","data_type":"number","required":false},"token_count":{"label":"Token Count","data_type":"number","required":false},"code_preview":{"label":"Code Preview","data_type":"text","required":false},"stable_id":{"data_type":"text","label":"Stable ID","required":false},"version_id":{"data_type":"text","label":"Version ID","required":false}},"record_permissions":{"system_admin":["create","read","update","delete"],"engineering_admin":["create","read","update","delete"],"engineering":["create","read","update"],"devops":["create","read","update"],"product":["create","read","update"],"docs":["create","read","update"],"qa":["create","read","update"],"management":["create","read","update"],"support_admin":["create","read","update"],"support":["read"],"csm":["read"],"tam":["read"],"sales":["read"],"member_admin":["read","update"],"member":["read"]},"functionality":null}$DESIGN$::jsonb,
106
+ '{}'::jsonb,
107
+ 'tenant',
108
+ true
109
+ )
110
+ ON CONFLICT (kind, slug) DO UPDATE SET
111
+ app_id = EXCLUDED.app_id,
112
+ name = EXCLUDED.name,
113
+ description = EXCLUDED.description,
114
+ icon = EXCLUDED.icon,
115
+ color = EXCLUDED.color,
116
+ design_schema = EXCLUDED.design_schema,
117
+ validation_schema = EXCLUDED.validation_schema,
118
+ ownership = EXCLUDED.ownership,
119
+ is_active = EXCLUDED.is_active;
120
+
121
+ INSERT INTO public.types (id, app_id, kind, slug, name, description, icon, color, design_schema, validation_schema, ownership, is_active)
122
+ VALUES (
123
+ gen_random_uuid(),
124
+ v_spine_core_app_id,
125
+ 'item',
126
+ 'cil_config',
127
+ 'CIL Config',
128
+ 'Config field contract — what a setting means, what each value drives downstream, and how to query the current value',
129
+ 'settings-2',
130
+ '#EF4444',
131
+ $DESIGN${"scope":"account","fields":{"config_table":{"label":"Config Table","data_type":"text","required":false},"record_slug":{"label":"Record Slug","data_type":"text","required":false},"field_name":{"label":"Field Name","data_type":"text","required":false},"field_type":{"label":"Field Type","data_type":"text","required":false},"allowed_range":{"label":"Allowed Range","data_type":"text","required":false},"default_value":{"label":"Default Value","data_type":"text","required":false},"description":{"label":"Description","data_type":"text","required":false},"settings":{"label":"Settings (JSON)","data_type":"text","required":false},"current_value_query":{"label":"Current Value Query","data_type":"text","required":false},"current_value_query_type":{"label":"Query Type","data_type":"select","options":[{"label":"SQL","value":"sql"},{"label":"JSON Path","value":"json_path"},{"label":"Env Var","value":"env"}],"required":false},"code_edge_chunk_ids":{"label":"Code Edge Chunk IDs","data_type":"text","required":false},"project_id":{"label":"Project ID","data_type":"text","required":false}},"record_permissions":{"system_admin":["create","read","update","delete"],"engineering_admin":["create","read","update","delete"],"engineering":["create","read","update"],"devops":["create","read","update"],"product":["create","read","update"],"docs":["create","read","update"],"qa":["create","read","update"],"management":["create","read","update"],"support_admin":["create","read","update"],"support":["read"],"csm":["read"],"tam":["read"],"sales":["read"],"member_admin":["read","update"],"member":["read"]},"functionality":null,"vector_types":["semantic"]}$DESIGN$::jsonb,
132
+ '{}'::jsonb,
133
+ 'tenant',
134
+ true
135
+ )
136
+ ON CONFLICT (kind, slug) DO UPDATE SET
137
+ app_id = EXCLUDED.app_id,
138
+ name = EXCLUDED.name,
139
+ description = EXCLUDED.description,
140
+ icon = EXCLUDED.icon,
141
+ color = EXCLUDED.color,
142
+ design_schema = EXCLUDED.design_schema,
143
+ validation_schema = EXCLUDED.validation_schema,
144
+ ownership = EXCLUDED.ownership,
145
+ is_active = EXCLUDED.is_active;
146
+
147
+ INSERT INTO public.types (id, app_id, kind, slug, name, description, icon, color, design_schema, validation_schema, ownership, is_active)
148
+ VALUES (
149
+ gen_random_uuid(),
150
+ v_spine_core_app_id,
151
+ 'item',
152
+ 'cil_learning_proposal',
153
+ 'CIL Learning Proposal',
154
+ 'Developer-review queue entry for CIL learning extracted from a support case',
155
+ 'git-pull-request',
156
+ '#10B981',
157
+ $DESIGN${"scope":"account","fields":{"ticket_id":{"label":"Ticket ID","data_type":"text","required":false},"thread_id":{"label":"Thread ID","data_type":"text","required":false},"ai_message_id":{"label":"AI Message ID","data_type":"text","required":false},"proposed_summary":{"label":"Proposed Summary","data_type":"textarea","required":true},"source_message_ids":{"label":"Source Message IDs","data_type":"json","required":false},"source_chunk_ids":{"label":"Source Chunk IDs","data_type":"json","required":false},"proposed_tags":{"label":"Proposed Tags","data_type":"json","required":false},"status":{"label":"Status","data_type":"select","required":true,"options":[{"label":"Draft","value":"draft"},{"label":"Submitted for Developer Review","value":"submitted_for_developer_review"},{"label":"In Review","value":"in_review"},{"label":"Approved","value":"approved"},{"label":"Applied","value":"applied"},{"label":"Rejected","value":"rejected"}]},"submitted_at":{"label":"Submitted At","data_type":"text","required":false},"reviewed_by":{"label":"Reviewed By","data_type":"text","required":false},"review_notes":{"label":"Developer Review Notes","data_type":"textarea","required":false}},"record_permissions":{"system_admin":["create","read","update","delete"],"engineering_admin":["create","read","update","delete"],"engineering":["create","read","update"],"devops":["create","read","update"],"product":["create","read","update"],"docs":["create","read","update"],"qa":["create","read","update"],"management":["create","read","update"],"support_admin":["create","read","update"],"support":["read"],"csm":["read"],"tam":["read"],"sales":["read"],"member_admin":["read","update"],"member":["read"]},"functionality":null}$DESIGN$::jsonb,
158
+ '{}'::jsonb,
159
+ 'system',
160
+ true
161
+ )
162
+ ON CONFLICT (kind, slug) DO UPDATE SET
163
+ app_id = EXCLUDED.app_id,
164
+ name = EXCLUDED.name,
165
+ description = EXCLUDED.description,
166
+ icon = EXCLUDED.icon,
167
+ color = EXCLUDED.color,
168
+ design_schema = EXCLUDED.design_schema,
169
+ validation_schema = EXCLUDED.validation_schema,
170
+ ownership = EXCLUDED.ownership,
171
+ is_active = EXCLUDED.is_active;
172
+
173
+ INSERT INTO public.types (id, app_id, kind, slug, name, description, icon, color, design_schema, validation_schema, ownership, is_active)
174
+ VALUES (
175
+ gen_random_uuid(),
176
+ v_spine_core_app_id,
177
+ 'item',
178
+ 'cil_version',
179
+ 'CIL Version',
180
+ 'A published or iteration version of a CIL project, aligned to npm semver.',
181
+ 'tag',
182
+ '#6366F1',
183
+ $DESIGN${"scope":"account","fields":{"project_id":{"data_type":"text","label":"Project ID","required":true},"version":{"data_type":"text","label":"Version","required":true},"base_version":{"data_type":"text","label":"Base Version","required":false},"status":{"data_type":"select","label":"Status","required":true,"options":[{"label":"Active","value":"active"},{"label":"Inactive","value":"inactive"},{"label":"Archived","value":"archived"}]},"is_iteration":{"data_type":"boolean","label":"Is Iteration","required":true},"published_version_id":{"data_type":"text","label":"Published Version ID","required":false}},"record_permissions":{"system_admin":["create","read","update","delete"],"engineering_admin":["create","read","update","delete"],"engineering":["create","read","update"],"devops":["create","read","update"],"product":["create","read","update"],"docs":["create","read","update"],"qa":["create","read","update"],"management":["create","read","update"],"support_admin":["create","read","update"],"support":["read"],"csm":["read"],"tam":["read"],"sales":["read"],"member_admin":["read","update"],"member":["read"]},"functionality":null}$DESIGN$::jsonb,
184
+ '{}'::jsonb,
185
+ 'tenant',
186
+ true
187
+ )
188
+ ON CONFLICT (kind, slug) DO UPDATE SET
189
+ app_id = EXCLUDED.app_id,
190
+ name = EXCLUDED.name,
191
+ description = EXCLUDED.description,
192
+ icon = EXCLUDED.icon,
193
+ color = EXCLUDED.color,
194
+ design_schema = EXCLUDED.design_schema,
195
+ validation_schema = EXCLUDED.validation_schema,
196
+ ownership = EXCLUDED.ownership,
197
+ is_active = EXCLUDED.is_active;
198
+
199
+ INSERT INTO public.types (id, app_id, kind, slug, name, description, icon, color, design_schema, validation_schema, ownership, is_active)
200
+ VALUES (
201
+ gen_random_uuid(),
202
+ v_spine_core_app_id,
203
+ 'item',
204
+ 'cil_suggestion',
205
+ 'CIL Suggestion',
206
+ 'Pending AI or human suggestion for a CIL learning, note, or KB link awaiting review.',
207
+ 'lightbulb',
208
+ '#F59E0B',
209
+ $DESIGN${"scope":"account","fields":{"project_id":{"data_type":"text","label":"Project ID","required":true},"version_id":{"data_type":"text","label":"Version ID","required":false},"target_stable_id":{"data_type":"text","label":"Target Stable ID","required":false},"suggestion_type":{"data_type":"select","label":"Suggestion Type","required":true,"options":[{"label":"Learning","value":"learning"},{"label":"Note","value":"note"},{"label":"KB Link","value":"kb_link"}]},"content":{"data_type":"textarea","label":"Content","required":true},"source":{"data_type":"text","label":"Source","required":false},"confidence":{"data_type":"number","label":"Confidence","required":false},"status":{"data_type":"select","label":"Status","required":true,"options":[{"label":"Pending","value":"pending"},{"label":"Accepted","value":"accepted"},{"label":"Rejected","value":"rejected"},{"label":"Escalated","value":"escalated"}]},"proposed_by":{"data_type":"select","label":"Proposed By","required":false,"options":[{"label":"AI","value":"ai"},{"label":"Human","value":"human"},{"label":"System","value":"system"}]},"reviewed_by":{"data_type":"text","label":"Reviewed By","required":false},"reviewed_at":{"data_type":"text","label":"Reviewed At","required":false}},"record_permissions":{"system_admin":["create","read","update","delete"],"engineering_admin":["create","read","update","delete"],"engineering":["create","read","update"],"devops":["create","read","update"],"product":["create","read","update"],"docs":["create","read","update"],"qa":["create","read","update"],"management":["create","read","update"],"support_admin":["create","read","update"],"support":["read"],"csm":["read"],"tam":["read"],"sales":["read"],"member_admin":["read","update"],"member":["read"]},"functionality":null}$DESIGN$::jsonb,
210
+ '{}'::jsonb,
211
+ 'tenant',
212
+ true
213
+ )
214
+ ON CONFLICT (kind, slug) DO UPDATE SET
215
+ app_id = EXCLUDED.app_id,
216
+ name = EXCLUDED.name,
217
+ description = EXCLUDED.description,
218
+ icon = EXCLUDED.icon,
219
+ color = EXCLUDED.color,
220
+ design_schema = EXCLUDED.design_schema,
221
+ validation_schema = EXCLUDED.validation_schema,
222
+ ownership = EXCLUDED.ownership,
223
+ is_active = EXCLUDED.is_active;
224
+
225
+ END $$;
226
+
227
+ -- CIL link types
228
+ DO $$
229
+ DECLARE v_spine_core_app_id uuid;
230
+ BEGIN
231
+ SELECT id INTO v_spine_core_app_id FROM public.apps WHERE slug = 'spine-core' LIMIT 1;
232
+ INSERT INTO public.link_types (id, app_id, slug, name, description, is_active)
233
+ VALUES (gen_random_uuid(), v_spine_core_app_id, 'cil_calls', 'CIL Calls', 'Source chunk calls target chunk', true)
234
+ ON CONFLICT (app_id, slug) DO UPDATE SET
235
+ name = EXCLUDED.name,
236
+ description = EXCLUDED.description,
237
+ is_active = EXCLUDED.is_active;
238
+ INSERT INTO public.link_types (id, app_id, slug, name, description, is_active)
239
+ VALUES (gen_random_uuid(), v_spine_core_app_id, 'cil_imports', 'CIL Imports', 'Source file imports target file or chunk', true)
240
+ ON CONFLICT (app_id, slug) DO UPDATE SET
241
+ name = EXCLUDED.name,
242
+ description = EXCLUDED.description,
243
+ is_active = EXCLUDED.is_active;
244
+ INSERT INTO public.link_types (id, app_id, slug, name, description, is_active)
245
+ VALUES (gen_random_uuid(), v_spine_core_app_id, 'cil_parent_child', 'CIL Parent/Child', 'Source chunk contains or defines target child', true)
246
+ ON CONFLICT (app_id, slug) DO UPDATE SET
247
+ name = EXCLUDED.name,
248
+ description = EXCLUDED.description,
249
+ is_active = EXCLUDED.is_active;
250
+ INSERT INTO public.link_types (id, app_id, slug, name, description, is_active)
251
+ VALUES (gen_random_uuid(), v_spine_core_app_id, 'cil_configures', 'CIL Configures', 'Source chunk reads or writes target config', true)
252
+ ON CONFLICT (app_id, slug) DO UPDATE SET
253
+ name = EXCLUDED.name,
254
+ description = EXCLUDED.description,
255
+ is_active = EXCLUDED.is_active;
256
+ INSERT INTO public.link_types (id, app_id, slug, name, description, is_active)
257
+ VALUES (gen_random_uuid(), v_spine_core_app_id, 'cil_tests', 'CIL Tests', 'Source chunk tests target chunk', true)
258
+ ON CONFLICT (app_id, slug) DO UPDATE SET
259
+ name = EXCLUDED.name,
260
+ description = EXCLUDED.description,
261
+ is_active = EXCLUDED.is_active;
262
+ INSERT INTO public.link_types (id, app_id, slug, name, description, is_active)
263
+ VALUES (gen_random_uuid(), v_spine_core_app_id, 'cil_kb_reference', 'CIL KB Reference', 'Source chunk references a KB article', true)
264
+ ON CONFLICT (app_id, slug) DO UPDATE SET
265
+ name = EXCLUDED.name,
266
+ description = EXCLUDED.description,
267
+ is_active = EXCLUDED.is_active;
268
+ INSERT INTO public.link_types (id, app_id, slug, name, description, is_active)
269
+ VALUES (gen_random_uuid(), v_spine_core_app_id, 'cil_suggestion_target', 'CIL Suggestion Target', 'Suggestion targets a specific CIL chunk', true)
270
+ ON CONFLICT (app_id, slug) DO UPDATE SET
271
+ name = EXCLUDED.name,
272
+ description = EXCLUDED.description,
273
+ is_active = EXCLUDED.is_active;
274
+ END $$;
275
+ -- CIL[DOC-VECTOR type="context" content="purpose='Upsert core CIL runtime types and link relation types for spine-core'; No verified external callers; imports: none"]
276
+ -- CIL[DOC-VECTOR type="blast_radius" content="No direct caller data from CIL graph; local impact only"]
277
+ -- CIL[DOC-VECTOR type="configuration" content="No environment or build configuration dependencies identified"]
278
+ -- CIL[DOC-VECTOR type="constraint" content="Standard runtime; no special invariants documented"]
279
+ -- CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
280
+ -- CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
281
+ -- CIL[END stable_id="~/.framework/migrations/016_cil_types.sql:cil_types:file"]