spine-framework 0.4.4 → 0.5.0-rc.4

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 (283) hide show
  1. package/.env.example +13 -3
  2. package/.framework/cli/commands/bootstrap.ts +392 -0
  3. package/.framework/cli/commands/dev.ts +91 -218
  4. package/.framework/cli/commands/doctor.ts +132 -26
  5. package/.framework/cli/commands/generate.ts +38 -298
  6. package/.framework/cli/commands/init.ts +20 -1
  7. package/.framework/cli/commands/migrate.ts +36 -30
  8. package/.framework/cli/commands/migrations.ts +16 -56
  9. package/.framework/cli/commands/upgrade.ts +35 -0
  10. package/.framework/cli/commands/validate-schema.ts +147 -0
  11. package/.framework/cli/context.ts +223 -110
  12. package/.framework/cli/index.ts +6 -0
  13. package/.framework/cli/lib/project-files.ts +241 -1
  14. package/.framework/functions/_shared/hash-api-key.ts +183 -79
  15. package/.framework/functions/_shared/logging.ts +562 -224
  16. package/.framework/functions/_shared/middleware.ts +47 -44
  17. package/.framework/functions/admin-data.ts +39 -28
  18. package/.framework/functions/ai-agents.ts +10 -6
  19. package/.framework/functions/api-keys.ts +301 -122
  20. package/.framework/functions/apps.ts +43 -26
  21. package/.framework/functions/cil-ingest.ts +48 -15
  22. package/.framework/functions/debug-auth.ts +14 -8
  23. package/.framework/functions/deliveries.ts +39 -12
  24. package/.framework/functions/embeddings.ts +145 -76
  25. package/.framework/functions/integration-outbound.ts +67 -27
  26. package/.framework/functions/integrations.ts +254 -127
  27. package/.framework/functions/logs.ts +273 -133
  28. package/.framework/functions/observability.ts +277 -147
  29. package/.framework/functions/pipeline-executions.ts +1 -1
  30. package/.framework/functions/pipelines.ts +14 -9
  31. package/.framework/functions/prompt-configs.ts +7 -4
  32. package/.framework/functions/roles.ts +8 -5
  33. package/.framework/functions/security.ts +30 -17
  34. package/.framework/functions/system-cron.ts +240 -127
  35. package/.framework/functions/tests.ts +7 -6
  36. package/.framework/functions/timers.ts +310 -107
  37. package/.framework/functions/triggers.ts +28 -13
  38. package/.framework/functions/types.ts +13 -10
  39. package/.framework/migrations/069_log_stats_window.sql +54 -0
  40. package/.framework/migrations/070_app_type_schema_rpcs.sql +166 -0
  41. package/.framework/migrations/071_timer_interval_keys.sql +96 -0
  42. package/.framework/migrations/072_slug_autofill.sql +77 -0
  43. package/.framework/migrations/073_seed_member_roles.sql +26 -0
  44. package/.framework/src/apps/admin/index.tsx +1141 -775
  45. package/.framework/src/components/ErrorBoundary.tsx +136 -0
  46. package/.framework/src/components/admin/AdminListPage.tsx +81 -73
  47. package/.framework/src/components/admin/AdminSidebar.tsx +88 -79
  48. package/.framework/src/components/admin/EntitySelect.tsx +181 -0
  49. package/.framework/src/components/admin/PageInstructions.tsx +86 -127
  50. package/.framework/src/components/app-shell/GenericDetailPage.tsx +37 -13
  51. package/.framework/src/components/app-shell/GenericListPage.tsx +28 -32
  52. package/.framework/src/components/layout/Sidebar.tsx +300 -177
  53. package/.framework/src/components/runtime/DataDetailPage.tsx +67 -35
  54. package/.framework/src/components/runtime/DataHeader.tsx +96 -48
  55. package/.framework/src/components/runtime/DataListPage.tsx +3 -26
  56. package/.framework/src/components/runtime/DataStats.tsx +10 -10
  57. package/.framework/src/components/runtime/DataTable.tsx +12 -10
  58. package/.framework/src/components/ui/sheet.tsx +24 -26
  59. package/.framework/src/components/ui/textarea.tsx +74 -48
  60. package/.framework/src/hooks/useEntityList.ts +12 -9
  61. package/.framework/src/hooks/useListSchema.ts +108 -58
  62. package/.framework/src/instructions/README.md +57 -0
  63. package/.framework/src/instructions/ai-agents.md +69 -0
  64. package/.framework/src/instructions/alerts.md +80 -0
  65. package/.framework/src/instructions/api-keys.md +87 -0
  66. package/.framework/src/instructions/apps.md +77 -0
  67. package/.framework/src/instructions/concepts/ai-and-prompts.md +150 -0
  68. package/.framework/src/instructions/concepts/apps-and-renderers.md +162 -0
  69. package/.framework/src/instructions/concepts/auth-and-api-keys.md +133 -0
  70. package/.framework/src/instructions/concepts/automation.md +186 -0
  71. package/.framework/src/instructions/concepts/concurrency-and-idempotency.md +125 -0
  72. package/.framework/src/instructions/concepts/core-vs-custom.md +124 -0
  73. package/.framework/src/instructions/concepts/design-schema.md +152 -0
  74. package/.framework/src/instructions/concepts/integrations-and-webhooks.md +127 -0
  75. package/.framework/src/instructions/concepts/observability.md +116 -0
  76. package/.framework/src/instructions/concepts/permissions.md +150 -0
  77. package/.framework/src/instructions/concepts/runtime-records.md +111 -0
  78. package/.framework/src/instructions/concepts/scope-and-accounts.md +112 -0
  79. package/.framework/src/instructions/concepts/spine-way.md +172 -0
  80. package/.framework/src/instructions/deliveries.md +59 -0
  81. package/.framework/src/instructions/guide/00-orientation.md +106 -0
  82. package/.framework/src/instructions/guide/01-install-and-first-run.md +253 -0
  83. package/.framework/src/instructions/guide/02-project-map.md +147 -0
  84. package/.framework/src/instructions/guide/03-domain-model.md +223 -0
  85. package/.framework/src/instructions/guide/04-first-app.md +227 -0
  86. package/.framework/src/instructions/guide/05-glossary.md +183 -0
  87. package/.framework/src/instructions/integrations.md +96 -0
  88. package/.framework/src/instructions/internal/cil-markers.md +83 -0
  89. package/.framework/src/instructions/invites.md +60 -0
  90. package/.framework/src/instructions/kb.md +80 -0
  91. package/.framework/src/instructions/logs.md +77 -0
  92. package/.framework/src/instructions/observability.md +61 -0
  93. package/.framework/src/instructions/operations/deployment.md +115 -0
  94. package/.framework/src/instructions/operations/migrations.md +125 -0
  95. package/.framework/src/instructions/operations/security-checklist.md +148 -0
  96. package/.framework/src/instructions/operations/troubleshooting.md +170 -0
  97. package/.framework/src/instructions/operations/upgrade.md +116 -0
  98. package/.framework/src/instructions/pipeline-executions.md +62 -0
  99. package/.framework/src/instructions/pipelines.md +78 -0
  100. package/.framework/src/instructions/prompts.md +95 -0
  101. package/.framework/src/instructions/reference/api/admin-data.md +162 -0
  102. package/.framework/src/instructions/reference/api/auth.md +113 -0
  103. package/.framework/src/instructions/reference/api/errors-and-envelopes.md +113 -0
  104. package/.framework/src/instructions/reference/app-manifest.md +150 -0
  105. package/.framework/src/instructions/reference/cli.md +124 -0
  106. package/.framework/src/instructions/reference/database.md +132 -0
  107. package/.framework/src/instructions/reference/design-schema.md +280 -0
  108. package/.framework/src/instructions/reference/env-vars.md +133 -0
  109. package/.framework/src/instructions/reference/functions/account-nodes.md +75 -0
  110. package/.framework/src/instructions/reference/functions/admin-data.md +195 -0
  111. package/.framework/src/instructions/reference/functions/admin-funnel.md +90 -0
  112. package/.framework/src/instructions/reference/functions/admin-install-funnel.md +107 -0
  113. package/.framework/src/instructions/reference/functions/admin-signals.md +102 -0
  114. package/.framework/src/instructions/reference/functions/ai-agents.md +148 -0
  115. package/.framework/src/instructions/reference/functions/ai-interactions.md +156 -0
  116. package/.framework/src/instructions/reference/functions/api-keys.md +130 -0
  117. package/.framework/src/instructions/reference/functions/apps.md +140 -0
  118. package/.framework/src/instructions/reference/functions/auth.md +99 -0
  119. package/.framework/src/instructions/reference/functions/debug-auth.md +91 -0
  120. package/.framework/src/instructions/reference/functions/deliveries.md +110 -0
  121. package/.framework/src/instructions/reference/functions/embeddings.md +166 -0
  122. package/.framework/src/instructions/reference/functions/eval-harness.md +149 -0
  123. package/.framework/src/instructions/reference/functions/index.md +103 -0
  124. package/.framework/src/instructions/reference/functions/integration-outbound.md +200 -0
  125. package/.framework/src/instructions/reference/functions/integration-routes.md +151 -0
  126. package/.framework/src/instructions/reference/functions/integrations.md +130 -0
  127. package/.framework/src/instructions/reference/functions/invites.md +182 -0
  128. package/.framework/src/instructions/reference/functions/item-progress.md +107 -0
  129. package/.framework/src/instructions/reference/functions/kb.md +166 -0
  130. package/.framework/src/instructions/reference/functions/logs.md +141 -0
  131. package/.framework/src/instructions/reference/functions/observability.md +105 -0
  132. package/.framework/src/instructions/reference/functions/pipeline-executions.md +132 -0
  133. package/.framework/src/instructions/reference/functions/pipeline-runner-background.md +121 -0
  134. package/.framework/src/instructions/reference/functions/pipelines.md +136 -0
  135. package/.framework/src/instructions/reference/functions/prompt-configs.md +121 -0
  136. package/.framework/src/instructions/reference/functions/roles.md +121 -0
  137. package/.framework/src/instructions/reference/functions/security.md +140 -0
  138. package/.framework/src/instructions/reference/functions/system-cron.md +136 -0
  139. package/.framework/src/instructions/reference/functions/system.md +106 -0
  140. package/.framework/src/instructions/reference/functions/tests.md +97 -0
  141. package/.framework/src/instructions/reference/functions/timers.md +117 -0
  142. package/.framework/src/instructions/reference/functions/trigger-scheduler.md +102 -0
  143. package/.framework/src/instructions/reference/functions/triggers.md +140 -0
  144. package/.framework/src/instructions/reference/functions/types.md +146 -0
  145. package/.framework/src/instructions/reference/seeds.md +126 -0
  146. package/.framework/src/instructions/reference/shared-modules.md +127 -0
  147. package/.framework/src/instructions/reference/spine-config.md +114 -0
  148. package/.framework/src/instructions/roles.md +80 -0
  149. package/.framework/src/instructions/runtime-detail.md +70 -0
  150. package/.framework/src/instructions/runtime-list.md +77 -0
  151. package/.framework/src/instructions/security.md +67 -0
  152. package/.framework/src/instructions/tasks/add-a-pipeline.md +110 -0
  153. package/.framework/src/instructions/tasks/add-a-role.md +96 -0
  154. package/.framework/src/instructions/tasks/add-a-timer.md +114 -0
  155. package/.framework/src/instructions/tasks/add-a-trigger.md +106 -0
  156. package/.framework/src/instructions/tasks/add-a-type.md +151 -0
  157. package/.framework/src/instructions/tasks/add-a-webhook.md +108 -0
  158. package/.framework/src/instructions/tasks/add-an-ai-agent.md +108 -0
  159. package/.framework/src/instructions/tasks/add-an-integration.md +124 -0
  160. package/.framework/src/instructions/tasks/build-a-custom-page.md +118 -0
  161. package/.framework/src/instructions/tasks/package-and-install-an-app.md +127 -0
  162. package/.framework/src/instructions/tasks/test-your-code.md +108 -0
  163. package/.framework/src/instructions/tasks/write-a-function.md +132 -0
  164. package/.framework/src/instructions/tasks/write-a-migration.md +110 -0
  165. package/.framework/src/instructions/testing.md +59 -0
  166. package/.framework/src/instructions/timers.md +82 -0
  167. package/.framework/src/instructions/triggers.md +69 -0
  168. package/.framework/src/instructions/types.md +93 -0
  169. package/.framework/src/pages/NotFoundPage.tsx +62 -31
  170. package/.framework/src/pages/admin/AIAgentDetailPage.tsx +117 -106
  171. package/.framework/src/pages/admin/AIAgentsPage.tsx +86 -48
  172. package/.framework/src/pages/admin/APIKeyDetailPage.tsx +153 -152
  173. package/.framework/src/pages/admin/APIKeysPage.tsx +91 -90
  174. package/.framework/src/pages/admin/AlertsConfigPage.tsx +29 -18
  175. package/.framework/src/pages/admin/AppDetailPage.tsx +6 -60
  176. package/.framework/src/pages/admin/AppsPage.tsx +104 -66
  177. package/.framework/src/pages/admin/DeliveriesPage.tsx +5 -5
  178. package/.framework/src/pages/admin/EmbeddingDetailPage.tsx +5 -23
  179. package/.framework/src/pages/admin/EmbeddingsPage.tsx +5 -26
  180. package/.framework/src/pages/admin/IntegrationDetailPage.tsx +7 -7
  181. package/.framework/src/pages/admin/IntegrationsPage.tsx +85 -43
  182. package/.framework/src/pages/admin/LogsPage.tsx +144 -76
  183. package/.framework/src/pages/admin/ObservabilityDashboard.tsx +223 -140
  184. package/.framework/src/pages/admin/PipelineDetailPage.tsx +134 -113
  185. package/.framework/src/pages/admin/PipelineExecutionsPage.tsx +108 -45
  186. package/.framework/src/pages/admin/PipelinesPage.tsx +160 -115
  187. package/.framework/src/pages/admin/PromptConfigDetailPage.tsx +96 -98
  188. package/.framework/src/pages/admin/PromptConfigsPage.tsx +101 -59
  189. package/.framework/src/pages/admin/RoleDetailPage.tsx +90 -79
  190. package/.framework/src/pages/admin/RolesPage.tsx +86 -43
  191. package/.framework/src/pages/admin/SecurityPage.tsx +1 -1
  192. package/.framework/src/pages/admin/TestingDashboard.tsx +16 -28
  193. package/.framework/src/pages/admin/TimerDetailPage.tsx +117 -100
  194. package/.framework/src/pages/admin/TimersPage.tsx +90 -62
  195. package/.framework/src/pages/admin/TriggerDetailPage.tsx +90 -83
  196. package/.framework/src/pages/admin/TriggersPage.tsx +124 -99
  197. package/.framework/src/pages/admin/TypeDetailPage.tsx +152 -138
  198. package/.framework/src/pages/admin/TypesPage.tsx +90 -48
  199. package/.framework/src/pages/admin/cil/CILAgentPage.tsx +17 -25
  200. package/.framework/src/pages/admin/cil/CILChunkDetailPage.tsx +17 -27
  201. package/.framework/src/pages/admin/cil/CILDashboardPage.tsx +72 -40
  202. package/.framework/src/pages/admin/cil/CILFileListPage.tsx +321 -129
  203. package/.framework/src/pages/admin/cil/CILFileSelectPage.tsx +18 -29
  204. package/.framework/src/pages/admin/cil/CILGraphPage.tsx +26 -38
  205. package/.framework/src/pages/admin/cil/CILIngestionPage.tsx +34 -46
  206. package/.framework/src/pages/admin/cil/CILProjectsPage.tsx +189 -103
  207. package/.framework/src/pages/admin/cil/CILSearchPage.tsx +246 -136
  208. package/.framework/src/pages/admin/cil/CILSuggestionsPage.tsx +11 -22
  209. package/.framework/src/pages/admin/cil/CILVersionsPage.tsx +9 -20
  210. package/.framework/src/pages/admin/cil/FlexiblePipelinePage.tsx +26 -38
  211. package/.framework/src/pages/admin/kb/KBAdminPage.tsx +7 -26
  212. package/.framework/templates/agent/AGENTS.md +150 -0
  213. package/.framework/templates/agent/skills/spine-add-ai-agent/SKILL.md +58 -0
  214. package/.framework/templates/agent/skills/spine-add-automation/SKILL.md +62 -0
  215. package/.framework/templates/agent/skills/spine-add-integration/SKILL.md +63 -0
  216. package/.framework/templates/agent/skills/spine-architect/SKILL.md +86 -0
  217. package/.framework/templates/agent/skills/spine-install-app/SKILL.md +72 -0
  218. package/.framework/templates/agent/skills/spine-migration/SKILL.md +75 -0
  219. package/.framework/templates/agent/skills/spine-new-app/SKILL.md +67 -0
  220. package/.framework/templates/agent/skills/spine-new-function/SKILL.md +65 -0
  221. package/.framework/templates/agent/skills/spine-new-type/SKILL.md +65 -0
  222. package/.framework/templates/agent/skills/spine-schema/SKILL.md +77 -0
  223. package/.framework/templates/agent/skills/spine-test/SKILL.md +67 -0
  224. package/.framework/templates/agent/skills/spine-troubleshoot/SKILL.md +74 -0
  225. package/.framework/templates/agent/skills/spine-upgrade/SKILL.md +69 -0
  226. package/.framework/templates/project.json +4 -1
  227. package/.framework/tests/unit/account-scoping-gates.test.ts +392 -0
  228. package/.framework/tests/unit/agent-files.test.ts +355 -0
  229. package/.framework/tests/unit/agent-runner.test.ts +479 -44
  230. package/.framework/tests/unit/api-keys-create-scope-gate.test.ts +160 -0
  231. package/.framework/tests/unit/api-keys-omit-secret-fields.test.ts +38 -0
  232. package/.framework/tests/unit/bootstrap.test.ts +242 -0
  233. package/.framework/tests/unit/cli-context-api-key.test.ts +114 -0
  234. package/.framework/tests/unit/debug-auth.test.ts +38 -0
  235. package/.framework/tests/unit/deliveries-account-scoping.test.ts +185 -0
  236. package/.framework/tests/unit/integration-outbound-credentials.test.ts +167 -0
  237. package/.framework/tests/unit/integrations-audit-redaction.test.ts +130 -0
  238. package/.framework/tests/unit/logging-app-id.test.ts +75 -0
  239. package/.framework/tests/unit/system-context-denial.test.ts +145 -0
  240. package/.framework/tests/unit/system-cron.test.ts +240 -0
  241. package/.framework/tests/unit/timers.test.ts +159 -0
  242. package/README.md +125 -166
  243. package/config/tsconfig.cli.json +2 -2
  244. package/package.json +15 -4
  245. package/templates/project/package-lock.json +2 -2
  246. package/.framework/docs/admin-routes.md +0 -76
  247. package/.framework/docs/api-docs-progress.md +0 -38
  248. package/.framework/docs/api-governance.md +0 -146
  249. package/.framework/docs/api-testing-results.md +0 -212
  250. package/.framework/docs/assembly-launch-guide.md +0 -138
  251. package/.framework/docs/audit-results.md +0 -590
  252. package/.framework/docs/db-api-inventory.md +0 -95
  253. package/.framework/docs/gap-remediation-backlog.md +0 -103
  254. package/.framework/docs/ui-adoption-verification.md +0 -111
  255. package/.framework/docs/ui-api-coverage.md +0 -84
  256. package/.framework/docs/v2-compatibility-audit.md +0 -228
  257. package/.framework/mcp/index.ts +0 -133
  258. package/.framework/mcp/load-env.ts +0 -60
  259. package/.framework/mcp/shared/app-manifest.ts +0 -275
  260. package/.framework/mcp/shared/db.ts +0 -477
  261. package/.framework/mcp/shared/kb.ts +0 -118
  262. package/.framework/mcp/tools/architect.ts +0 -431
  263. package/.framework/mcp/tools/cil/context.ts +0 -345
  264. package/.framework/mcp/tools/cil/graph.ts +0 -242
  265. package/.framework/mcp/tools/cil/ingest.ts +0 -1217
  266. package/.framework/mcp/tools/cil/pipeline-orchestrator.ts +0 -693
  267. package/.framework/mcp/tools/cil/pipeline.ts +0 -767
  268. package/.framework/mcp/tools/cil/project.ts +0 -791
  269. package/.framework/mcp/tools/cil/retrieval.ts +0 -336
  270. package/.framework/mcp/tools/cil/search-core.ts +0 -454
  271. package/.framework/mcp/tools/cil/search.ts +0 -97
  272. package/.framework/mcp/tools/cil/suggest.ts +0 -186
  273. package/.framework/mcp/tools/cil/validate.ts +0 -1369
  274. package/.framework/mcp/tools/kb/delete.ts +0 -139
  275. package/.framework/mcp/tools/kb/index.ts +0 -52
  276. package/.framework/mcp/tools/kb/ingest.ts +0 -84
  277. package/.framework/mcp/tools/kb/list-types.ts +0 -102
  278. package/.framework/mcp/tools/kb/publish.ts +0 -100
  279. package/.framework/mcp/tools/kb/reindex.ts +0 -86
  280. package/.framework/mcp/tools/kb/revoke.ts +0 -85
  281. package/.framework/mcp/tools/kb/search.ts +0 -101
  282. package/.framework/mcp/tools/kb/upsert.ts +0 -125
  283. package/.framework/mcp/tools/observability.ts +0 -510
@@ -1,590 +0,0 @@
1
- # Spine v2 — Two-Pass Codebase Audit Results
2
-
3
- Generated: 2026-04-26
4
- Auditor: Cascade (automated trace + sweep)
5
-
6
- ---
7
-
8
- ## Summary
9
-
10
- - **Live frontend files:** 78 (all files in `v2-core/src/`)
11
- - **Live function files:** 18 handlers + 6 shared files
12
- - **Orphaned / dead files:** 11 identified
13
- - **Legacy candidates:** 8 identified
14
- - **Tables required by live code:** 21 distinct tables
15
- - **RPC functions required:** 8 distinct RPCs
16
- - **Hardcoded values found:** 0 in source (schema targets `v2` — see note)
17
- - **Duplicate migration prefix:** 1 (`047`)
18
- - **Critical note:** ALL code targets the `v2` schema, NOT `public`. Day-zero migrations must use `v2` schema OR code must be updated to use `public`.
19
-
20
- ---
21
-
22
- ## Live Set
23
-
24
- ### Frontend Entry Chain (`v2-core/src/`)
25
-
26
- **Entry:** `main.tsx` → `App.tsx`
27
-
28
- #### Core files (always live)
29
- - `main.tsx`
30
- - `App.tsx`
31
- - `index.css`
32
- - `contexts/AuthContext.tsx`
33
- - `types/types.ts`
34
- - `types/auth.ts`
35
- - `lib/` (all files)
36
-
37
- #### Layout
38
- - `components/layout/Layout.tsx`
39
- - `components/layout/Header.tsx`
40
- - `components/layout/Sidebar.tsx`
41
-
42
- #### Auth
43
- - `components/auth/ProtectedRoute.tsx`
44
- - `pages/auth/LoginPage.tsx`
45
-
46
- #### Pages
47
- - `pages/DashboardPage.tsx`
48
- - `pages/NotFoundPage.tsx`
49
- - `pages/admin/TypesPage.tsx`
50
- - `pages/admin/TypeDetailPage.tsx`
51
- - `pages/admin/AppsPage.tsx`
52
- - `pages/admin/AppDetailPage.tsx`
53
- - `pages/admin/PipelinesPage.tsx`
54
- - `pages/admin/PipelineDetailPage.tsx`
55
- - `pages/admin/TriggersPage.tsx`
56
- - `pages/admin/TriggerDetailPage.tsx`
57
- - `pages/admin/AIAgentsPage.tsx`
58
- - `pages/admin/AIAgentDetailPage.tsx`
59
- - `pages/admin/EmbeddingsPage.tsx`
60
- - `pages/admin/EmbeddingDetailPage.tsx`
61
- - `pages/admin/TimersPage.tsx`
62
- - `pages/admin/TimerDetailPage.tsx`
63
- - `pages/admin/IntegrationsPage.tsx`
64
- - `pages/admin/IntegrationDetailPage.tsx`
65
- - `pages/admin/AccountTypesPage.tsx`
66
- - `pages/admin/AccountTypeDetailPage.tsx`
67
- - `pages/admin/PersonTypesPage.tsx`
68
- - `pages/admin/PersonTypeDetailPage.tsx`
69
- - `pages/admin/RolesPage.tsx`
70
- - `pages/admin/RoleDetailPage.tsx`
71
- - `pages/admin/ThreadTypesPage.tsx`
72
- - `pages/admin/MessageTypesPage.tsx`
73
- - `pages/admin/AttachmentTypesPage.tsx`
74
- - `pages/admin/PromptConfigsPage.tsx`
75
- - `pages/admin/PromptConfigDetailPage.tsx`
76
- - `pages/admin/APIKeysPage.tsx`
77
- - `pages/admin/APIKeyDetailPage.tsx`
78
- - `pages/admin/PipelineExecutionsPage.tsx`
79
- - `pages/admin/LogsPage.tsx`
80
-
81
- #### Runtime components (live — routed via `DataListPage` / `DataDetailPage`)
82
- - `components/runtime/DataListPage.tsx`
83
- - `components/runtime/DataDetailPage.tsx`
84
- - `components/runtime/DataTable.tsx`
85
- - `components/runtime/DataStats.tsx`
86
- - `components/runtime/DataFilters.tsx`
87
- - `components/runtime/DataHeader.tsx`
88
- - `components/runtime/DataDetailHeader.tsx`
89
- - `components/runtime/SchemaDetailForm.tsx`
90
- - `components/runtime/index.ts`
91
-
92
- #### Shared components
93
- - `components/shared/FieldRenderer.tsx`
94
- - `components/shared/SchemaFields.tsx`
95
-
96
- #### Admin components
97
- - `components/admin/AdminListPage.tsx`
98
- - `components/admin/AdminStatsCard.tsx`
99
- - `components/admin/SortableTableHeader.tsx`
100
-
101
- #### Hooks
102
- - `hooks/useApi.ts`
103
- - `hooks/useEntityList.ts`
104
- - `hooks/useEntityRecord.ts`
105
- - `hooks/useForm.ts`
106
- - `hooks/useListSchema.ts`
107
- - `hooks/useSchemaRecord.ts`
108
-
109
- ### Live Functions (`v2-core/functions/`)
110
-
111
- All 18 handlers are reachable from `netlify.toml [functions] directory = "v2-core/functions"`:
112
-
113
- | Handler | Tables accessed |
114
- |---|---|
115
- | `admin-data.ts` | accounts, people, items, threads, messages, links, attachments, watchers, types |
116
- | `types.ts` | types, accounts, apps |
117
- | `roles.ts` | roles, apps |
118
- | `apps.ts` | apps, accounts |
119
- | `auth.ts` | people, accounts, roles |
120
- | `pipelines.ts` | pipelines, pipeline_executions, apps, people |
121
- | `pipeline-executions.ts` | pipeline_executions, pipelines, people |
122
- | `triggers.ts` | triggers, trigger_executions, apps, people |
123
- | `timers.ts` | timers, apps, people |
124
- | `ai-agents.ts` | ai_agents, apps, people |
125
- | `embeddings.ts` | embeddings |
126
- | `integrations.ts` | integrations, apps, people |
127
- | `logs.ts` | logs |
128
- | `prompt-configs.ts` | prompt_configs, apps, people |
129
- | `api-keys.ts` | api_keys, api_key_usage_logs, integrations, people |
130
- | `account-nodes.ts` | accounts, types |
131
- | `debug-auth.ts` | (no DB — JWT debug only) |
132
- | `system-cron.ts` | actions, api_keys, schedule_executions (via `adminDb.rpc`) |
133
-
134
- ### Live `_shared/` Files
135
-
136
- All 6 are imported by live handlers:
137
- - `_shared/db.ts` — Supabase clients, `joins` constants
138
- - `_shared/middleware.ts` — `createHandler`, `RequestContext`
139
- - `_shared/permissions.ts` — `PermissionEngine`, `sanitizeRecordData`
140
- - `_shared/principal.ts` — `resolvePrincipal`, `getPrincipalDb`
141
- - `_shared/audit.ts` — `emitLog`, `emitAudit`
142
- - `_shared/schema-utils.ts` — `generateValidationSchema` (used by `types.ts`)
143
-
144
- ### Live Scripts
145
-
146
- | Script | Status | Called by |
147
- |---|---|---|
148
- | `scripts/netlify-dev-wrapper.sh` | ✅ Live | `netlify.toml [dev].command` |
149
- | `scripts/assemble-v2.sh` | ✅ Live | `package.json` prebuild |
150
- | `scripts/assemble-v2-functions.sh` | ✅ Live | `assemble-v2.sh` |
151
- | `scripts/assemble-v2-frontend.sh` | ✅ Live | `assemble-v2.sh` |
152
- | `scripts/assemble-v2-custom.sh` | ✅ Live | `assemble-v2.sh` |
153
- | `scripts/build-manifest.sh` | ✅ Live | `package.json` prebuild |
154
- | `scripts/verify-integrity.sh` | ✅ Live | `package.json` prebuild |
155
-
156
- ---
157
-
158
- ## Orphaned Files
159
-
160
- These files exist but nothing in the live code path imports or routes to them:
161
-
162
- | File | Reason |
163
- |---|---|
164
- | `v2-core/src/pages/admin/AccountDetailPage.tsx.new` | Zero-byte file with `.new` extension — artifact |
165
- | `v2-core/x-netlify-functions/` (entire dir, 40 files) | Legacy function snapshot — no live code imports from here; superseded by `v2-core/functions/` |
166
- | `v2-core/functions/schema-utils.ts` *(if exists at root)* | Confirm — `schema-utils` lives in `_shared/`; any root-level copy is orphaned |
167
- | `scripts/assemble-apps.sh` | Not called by any live script |
168
- | `scripts/assemble-apps-simple.sh` | Not called by any live script |
169
- | `scripts/assemble-frontend.sh` | v1-era script, superseded by `assemble-v2-frontend.sh` |
170
- | `scripts/assemble-functions.sh` | v1-era script, superseded by `assemble-v2-functions.sh` |
171
- | `scripts/quarantine-legacy.sh` | One-time-use script, no longer needed |
172
- | `scripts/app-install-cli.ts` | Not called by any live script or route |
173
- | `scripts/load-test-app-install.ts` | Test/dev script, not part of any build chain |
174
- | `_quarantine/` (entire dir) | All contents are retired artifacts — no imports anywhere |
175
-
176
- ---
177
-
178
- ## Legacy Candidates
179
-
180
- Files that contain references to old patterns, deleted tables, or v1-era architecture:
181
-
182
- | File | Issue |
183
- |---|---|
184
- | `v2-core/migrations/047_provisioning.sql` | Duplicate `047_` prefix — conflicts with `047_simplify_auth_model.sql`; migration order is ambiguous on fresh install |
185
- | `v2-core/migrations/047_simplify_auth_model.sql` | Same duplicate prefix issue |
186
- | `v2-core/src/App.tsx` lines 376–390 | Legacy redirect routes (`/admin/data/:entity` → `/admin/runtime/:entity`) — safe to keep short-term but dead routes |
187
- | `v2-core/docs/` (various .md files) | Contains stale audit reports, gap-remediation notes referencing old state — not harmful, but stale |
188
- | `v2-core/fix-functions.sh` | One-off fix script at `v2-core/` root — purpose served, should be deleted |
189
- | `v2-core/.windsurf/` | Unknown contents — confirm empty or remove |
190
- | `v2-core/.vscode/` | Editor config — OK to keep, but confirm not containing hardcoded values |
191
- | `v2-core/README.md` | May reference old architecture — needs refresh for clean install |
192
-
193
- ---
194
-
195
- ## DB: Code→Table Map
196
-
197
- > **CRITICAL:** `db.ts` connects to schema `v2` (not `public`). Day-zero migrations must either:
198
- > (a) Create tables in the `v2` schema, OR
199
- > (b) Update `db.ts` to use `schema: 'public'`
200
- > This decision must be made before writing migration files.
201
-
202
- ---
203
-
204
- ### Table: `accounts`
205
- ```
206
- columns used: id, slug, display_name, is_active, parent_id, type_id, owner_account_id
207
- FKs: parent_id → accounts.id
208
- type_id → types.id
209
- owner_account_id → accounts.id
210
- joins: type:types!type_id, parent:accounts!parent_id, owner_account:accounts!owner_account_id
211
- accessed by: admin-data.ts (ctx.db + adminDb), auth.ts (ctx.db), types.ts (adminDb), account-nodes.ts (ctx.db)
212
- RLS required: yes (account hierarchy filtering)
213
- RPCs: get_account_hierarchy(parent_account_id), get_account_ancestors(account_id),
214
- get_account_descendants(account_id), get_account_apps(account_id, include_system, include_inactive)
215
- ```
216
-
217
- ### Table: `people`
218
- ```
219
- columns used: id, email, full_name, avatar_url, account_id, role_id, is_active
220
- FKs: account_id → accounts.id
221
- role_id → roles.id
222
- joins: account:accounts!people_account_id_fkey, role:roles
223
- accessed by: auth.ts (ctx.db), admin-data.ts (ctx.db), pipeline-executions.ts (join),
224
- prompt-configs.ts (join), api-keys.ts (join), ai-agents.ts (join),
225
- triggers.ts (join), timers.ts (join), pipelines.ts (join), integrations.ts (join)
226
- RLS required: yes
227
- ```
228
-
229
- ### Table: `types`
230
- ```
231
- columns used: id, slug, name, kind, description, icon, color, app_id, is_active,
232
- design_schema, validation_schema, ownership
233
- FKs: app_id → apps.id
234
- joins: app:apps!app_id
235
- accessed by: types.ts (ctx.db + adminDb), admin-data.ts (adminDb — type lookup for items),
236
- account-nodes.ts (join on accounts)
237
- RLS required: yes
238
- RPCs: get_type_schema(kind, slug, app_id)
239
- ```
240
-
241
- ### Table: `apps`
242
- ```
243
- columns used: id, slug, name, description, icon, color, version, app_type, source,
244
- owner_account_id, config, nav_items, min_role, integration_deps, metadata,
245
- is_active, is_system
246
- FKs: owner_account_id → accounts.id
247
- joins: owner_account:accounts!owner_account_id
248
- accessed by: apps.ts (ctx.db), types.ts (adminDb), roles.ts (ctx.db),
249
- pipelines.ts (join), triggers.ts (join), timers.ts (join),
250
- ai-agents.ts (join), integrations.ts (join), prompt-configs.ts (join)
251
- RLS required: yes
252
- RPCs: get_account_apps(account_id, include_system, include_inactive),
253
- get_app_schema(app_slug),
254
- is_app_available(app_slug, account_id),
255
- update_app_version(app_id, new_version)
256
- ```
257
-
258
- ### Table: `roles`
259
- ```
260
- columns used: id, slug, name, description, permissions, is_system, is_active, app_id
261
- FKs: app_id → apps.id
262
- joins: app:apps!app_id
263
- accessed by: roles.ts (ctx.db + adminDb), auth.ts (join on people)
264
- RLS required: yes
265
- ```
266
-
267
- ### Table: `items`
268
- ```
269
- columns used: id, item_type_id, title, is_active, design_schema, validation_schema,
270
- account_id, type_id, created_by, created_at, updated_at, updated_by
271
- FKs: item_type_id → types.id
272
- account_id → accounts.id
273
- created_by → people.id
274
- accessed by: admin-data.ts (ctx.db — full CRUD via VALID_ENTITIES)
275
- search field: title
276
- soft delete: yes (is_active)
277
- RLS required: yes
278
- ```
279
-
280
- ### Table: `threads`
281
- ```
282
- columns used: id, title, is_active, design_schema, validation_schema,
283
- account_id, type_id, created_by, created_at, updated_at, updated_by
284
- FKs: account_id → accounts.id
285
- accessed by: admin-data.ts (ctx.db — VALID_ENTITIES)
286
- search field: title
287
- soft delete: yes (is_active)
288
- RLS required: yes
289
- ```
290
-
291
- ### Table: `messages`
292
- ```
293
- columns used: id, content, is_active, design_schema, validation_schema,
294
- account_id, type_id, created_by, created_at, updated_at, updated_by
295
- FKs: account_id → accounts.id
296
- accessed by: admin-data.ts (ctx.db — VALID_ENTITIES)
297
- search field: content
298
- soft delete: yes (is_active)
299
- RLS required: yes
300
- ```
301
-
302
- ### Table: `links`
303
- ```
304
- columns used: id, link_type, design_schema, validation_schema,
305
- account_id, type_id, created_by, created_at, updated_at, updated_by
306
- FKs: account_id → accounts.id
307
- accessed by: admin-data.ts (ctx.db — VALID_ENTITIES)
308
- search field: link_type
309
- soft delete: no (hard delete)
310
- RLS required: yes
311
- ```
312
-
313
- ### Table: `attachments`
314
- ```
315
- columns used: id, filename, design_schema, validation_schema,
316
- account_id, type_id, created_by, created_at, updated_at, updated_by
317
- FKs: account_id → accounts.id
318
- accessed by: admin-data.ts (ctx.db — VALID_ENTITIES)
319
- search field: filename
320
- soft delete: no
321
- RLS required: yes
322
- ```
323
-
324
- ### Table: `watchers`
325
- ```
326
- columns used: id, watch_type, is_active, design_schema, validation_schema,
327
- account_id, type_id, created_by, created_at, updated_at, updated_by
328
- FKs: account_id → accounts.id
329
- accessed by: admin-data.ts (ctx.db — VALID_ENTITIES)
330
- search field: watch_type
331
- soft delete: yes (is_active)
332
- RLS required: yes
333
- ```
334
-
335
- ### Table: `pipelines`
336
- ```
337
- columns used: id, name, description, trigger_type, config, stages, metadata, is_active,
338
- app_id, account_id, created_by, created_at, updated_at
339
- FKs: app_id → apps.id
340
- account_id → accounts.id
341
- created_by → people.id
342
- joins: app:apps!app_id, created_by_person:people!created_by
343
- accessed by: pipelines.ts (ctx.db), pipeline-executions.ts (join)
344
- RLS required: yes
345
- ```
346
-
347
- ### Table: `pipeline_executions`
348
- ```
349
- columns used: id, pipeline_id, status, trigger_data, result, error_message,
350
- started_at, completed_at, duration_ms, created_by, account_id, created_at
351
- FKs: pipeline_id → pipelines.id
352
- created_by → people.id
353
- account_id → accounts.id
354
- joins: pipeline:pipelines!pipeline_id, triggered_by_person:people!pipeline_executions_created_by_fkey
355
- accessed by: pipeline-executions.ts (ctx.db), pipelines.ts (ctx.db — getExecutions)
356
- RLS required: yes
357
- ```
358
-
359
- ### Table: `triggers`
360
- ```
361
- columns used: id, name, description, trigger_type, event_type, config, pipeline_id,
362
- metadata, is_active, app_id, account_id, created_by, created_at, updated_at
363
- FKs: app_id → apps.id
364
- account_id → accounts.id
365
- created_by → people.id
366
- pipeline_id → pipelines.id
367
- joins: app:apps!app_id, created_by_person:people!created_by
368
- accessed by: triggers.ts (ctx.db)
369
- RLS required: yes
370
- ```
371
-
372
- ### Table: `trigger_executions`
373
- ```
374
- columns used: id, trigger_id, triggered_at, status (implicit via ordering)
375
- FKs: trigger_id → triggers.id
376
- accessed by: triggers.ts (ctx.db — getExecutions)
377
- RLS required: yes
378
- ```
379
-
380
- ### Table: `timers`
381
- ```
382
- columns used: id, name, description, timer_type, config, pipeline_id, metadata, is_active,
383
- app_id, account_id, created_by, created_at, updated_at
384
- FKs: app_id → apps.id
385
- account_id → accounts.id
386
- created_by → people.id
387
- pipeline_id → pipelines.id
388
- joins: app:apps!app_id, created_by_person:people!created_by
389
- accessed by: timers.ts (ctx.db)
390
- RLS required: yes
391
- ```
392
-
393
- ### Table: `ai_agents`
394
- ```
395
- columns used: id, name, description, agent_type, model_config, system_prompt, tools,
396
- capabilities, constraints, metadata, is_active, app_id, account_id,
397
- created_by, created_at, updated_at
398
- FKs: app_id → apps.id
399
- account_id → accounts.id
400
- created_by → people.id
401
- joins: app:apps!app_id, created_by_person:people!created_by
402
- accessed by: ai-agents.ts (ctx.db)
403
- RLS required: yes
404
- ```
405
-
406
- ### Table: `embeddings`
407
- ```
408
- columns used: id, model_id, document_id, chunk_index, content, metadata,
409
- account_id, created_at
410
- FKs: account_id → accounts.id
411
- accessed by: embeddings.ts (ctx.db)
412
- RLS required: yes
413
- ```
414
-
415
- ### Table: `integrations`
416
- ```
417
- columns used: id, name, description, integration_type, provider, version, config,
418
- credentials, metadata, is_active, is_configured, app_id, account_id,
419
- created_by, created_at, updated_at
420
- FKs: app_id → apps.id
421
- account_id → accounts.id
422
- created_by → people.id
423
- joins: app:apps!app_id, created_by_person:people!created_by
424
- accessed by: integrations.ts (ctx.db), api-keys.ts (join)
425
- RLS required: yes
426
- ```
427
-
428
- ### Table: `logs`
429
- ```
430
- columns used: id, level, message, context, source, source_type, source_id,
431
- person_id, account_id, metadata, created_at
432
- FKs: account_id → accounts.id
433
- person_id → people.id (nullable)
434
- accessed by: logs.ts (ctx.db), audit.ts (ctx.db or adminDb — all functions via emitLog/emitAudit)
435
- RLS required: yes (scoped to account_id)
436
- ```
437
-
438
- ### Table: `prompt_configs`
439
- ```
440
- columns used: id, name, slug, system_prompt, context_template, model, temperature,
441
- max_tokens, is_multi_turn, max_history_messages, confidence_threshold,
442
- escalation_action, escalation_target, output_mode, output_field,
443
- requires_review, knowledge_sources, available_tools, tool_constraints,
444
- metadata, is_active, app_id, account_id, created_by, created_at, updated_at
445
- FKs: app_id → apps.id
446
- account_id → accounts.id
447
- created_by → people.id
448
- joins: app:apps!app_id, created_by_person:people!prompt_configs_created_by_fkey
449
- accessed by: prompt-configs.ts (ctx.db)
450
- RLS required: yes
451
- ```
452
-
453
- ### Table: `api_keys`
454
- ```
455
- columns used: id, integration_id, name, key_type, key_prefix, permissions, rate_limit,
456
- expires_at, metadata, is_active, account_id, created_by, created_at, updated_at
457
- machine_type, is_internal, scopes (read by system-cron.ts)
458
- FKs: integration_id → integrations.id (nullable)
459
- account_id → accounts.id
460
- created_by → people.id
461
- joins: integration:integrations, created_by_person:people
462
- accessed by: api-keys.ts (ctx.db), system-cron.ts (adminDb — machine principal lookup)
463
- RLS required: yes
464
- RPCs: create_api_key(...), validate_api_key(key_value, required_permissions)
465
- ```
466
-
467
- ### Table: `api_key_usage_logs`
468
- ```
469
- columns used: id, api_key_id, response_status, success, created_at
470
- FKs: api_key_id → api_keys.id
471
- joins: api_key:api_keys
472
- accessed by: api-keys.ts (ctx.db — listUsageLogs)
473
- RLS required: yes
474
- ```
475
-
476
- ### Table: `actions` *(system-cron only)*
477
- ```
478
- columns used: id, handler, handler_module, config, required_scopes
479
- FKs: (none explicit in code)
480
- accessed by: system-cron.ts (adminDb)
481
- RLS required: no (adminDb only)
482
- ```
483
-
484
- ### Table: `schedule_executions` *(system-cron only)*
485
- ```
486
- columns used: schedule_id, account_id, machine_principal_id, status,
487
- input_params, output_result, error_message, duration_ms
488
- FKs: schedule_id → schedules (implied), account_id → accounts.id
489
- accessed by: system-cron.ts (adminDb)
490
- RLS required: no (adminDb only)
491
- ```
492
-
493
- ---
494
-
495
- ## Tables: `select *` (columns not fully enumerated in code)
496
-
497
- These tables are queried with `select('*')` — full column set must be verified against DB schema:
498
-
499
- | Table | Location |
500
- |---|---|
501
- | `accounts` | `admin-data.ts`, `types.ts`, `account-nodes.ts` |
502
- | `people` | `admin-data.ts` |
503
- | `items` | `admin-data.ts` |
504
- | `threads` | `admin-data.ts` |
505
- | `messages` | `admin-data.ts` |
506
- | `links` | `admin-data.ts` |
507
- | `attachments` | `admin-data.ts` |
508
- | `watchers` | `admin-data.ts` |
509
- | `types` | `types.ts` (full record), `admin-data.ts` (type lookup) |
510
- | `roles` | `roles.ts` |
511
- | `pipelines` | `pipelines.ts` |
512
- | `triggers` | `triggers.ts` |
513
- | `timers` | `timers.ts` |
514
- | `ai_agents` | `ai-agents.ts` |
515
- | `integrations` | `integrations.ts` |
516
- | `prompt_configs` | `prompt-configs.ts` |
517
- | `api_keys` | `api-keys.ts` |
518
-
519
- ---
520
-
521
- ## RPC Functions Required
522
-
523
- | RPC name | Called by | Purpose |
524
- |---|---|---|
525
- | `get_account_hierarchy(parent_account_id)` | `auth.ts` | Get all accessible child accounts |
526
- | `get_account_ancestors(account_id)` | `account-nodes.ts` | Ancestor chain for breadcrumb |
527
- | `get_account_descendants(account_id)` | `account-nodes.ts` | Subtree for tree view |
528
- | `get_account_apps(account_id, include_system, include_inactive)` | `apps.ts` | Apps visible to account |
529
- | `get_type_schema(kind, slug, app_id)` | `types.ts` | Resolve design_schema for a type |
530
- | `get_app_schema(app_slug)` | `apps.ts` | App schema lookup |
531
- | `is_app_available(app_slug, account_id)` | `apps.ts` | Marketplace availability check |
532
- | `update_app_version(app_id, new_version)` | `apps.ts` | Version bump |
533
- | `create_api_key(...)` | `api-keys.ts` | Secure key generation |
534
- | `validate_api_key(key_value, required_permissions)` | `api-keys.ts` | Key validation |
535
- | `get_due_schedules(p_now)` | `system-cron.ts` | Cron schedule polling |
536
- | `validate_schedule_creator(p_schedule_id)` | `system-cron.ts` | Cron safety check |
537
- | `update_schedule_after_run(p_schedule_id, p_success, p_error_message)` | `system-cron.ts` | Cron state update |
538
-
539
- ---
540
-
541
- ## Hardcoded Values Found
542
-
543
- | File | Type | Value |
544
- |---|---|---|
545
- | `functions/_shared/db.ts` | Schema target | `schema: 'v2'` — hardcoded in both `adminDb` and `getUserDb`. **Must change to `'public'` for day-zero migration** |
546
- | `vite.config.ts` | (check) | Confirm `VITE_DB_SCHEMA` env var path |
547
-
548
- No hardcoded tenant IDs, account UUIDs, or emails found in `v2-core/functions/` or `v2-core/src/`.
549
-
550
- ---
551
-
552
- ## Migration Chain Issues
553
-
554
- | Issue | Detail |
555
- |---|---|
556
- | **Duplicate prefix `047`** | `047_provisioning.sql` AND `047_simplify_auth_model.sql` both exist — ambiguous execution order on fresh install |
557
- | **65 migrations total** | Chain is long; many migrations are incremental patches to the current hodgepodge schema — NOT suitable as a clean day-zero chain |
558
- | **Schema target mismatch** | All migrations use `v2` schema; day-zero plan must decide: keep `v2` schema or migrate to `public` and update `db.ts` |
559
- | **`x-netlify-functions/`** | Contains `_shared/` with `db.ts` likely targeting a different/older schema — confirm and delete |
560
-
561
- ---
562
-
563
- ## Recommended Deletion List (Pending Your Sign-off)
564
-
565
- | Path | Action | Risk |
566
- |---|---|---|
567
- | `v2-core/x-netlify-functions/` | Delete entire directory | Low — nothing imports from here |
568
- | `v2-core/src/pages/admin/AccountDetailPage.tsx.new` | Delete | None — zero bytes |
569
- | `scripts/assemble-apps.sh` | Delete | Low — not in any build chain |
570
- | `scripts/assemble-apps-simple.sh` | Delete | Low — not in any build chain |
571
- | `scripts/assemble-frontend.sh` | Delete | Low — v1-era, superseded |
572
- | `scripts/assemble-functions.sh` | Delete | Low — v1-era, superseded |
573
- | `scripts/quarantine-legacy.sh` | Delete | Low — one-time use done |
574
- | `scripts/app-install-cli.ts` | Delete | Medium — confirm no external tooling depends on it |
575
- | `scripts/load-test-app-install.ts` | Delete | Medium — confirm not used in CI |
576
- | `_quarantine/` | Delete entire directory | Low — all contents are retired artifacts |
577
- | `v2-core/fix-functions.sh` | Delete | Low — one-off fix script |
578
- | `v2-core/migrations/` | Do NOT delete yet — keep as reference for day-zero spec | — |
579
-
580
- ---
581
-
582
- ## Key Decisions Required Before Day-Zero Migration
583
-
584
- 1. **Schema: `v2` or `public`?** — `db.ts` hardcodes `schema: 'v2'`. Day-zero plan must pick one. Changing to `public` requires a one-line edit in `db.ts`; keeping `v2` requires `CREATE SCHEMA v2` in migration 001.
585
-
586
- 2. **RPC functions** — 13 RPCs are called by live code. Each needs a `CREATE FUNCTION` in the day-zero migrations. These are currently buried across the 65-migration chain.
587
-
588
- 3. **`system-cron` tables** — `actions`, `schedule_executions`, `schedules` are only accessed by `system-cron.ts` via `adminDb` with no RLS. These need their own migration section.
589
-
590
- 4. **`api_key_usage_logs`** — Small table, only read by `api-keys.ts`. Needs creation in day-zero chain.
@@ -1,95 +0,0 @@
1
- # DB-First API Inventory (v2 Schema)
2
-
3
- ## Core Entity Tables
4
-
5
- | Table | Endpoint | Domain | Status | Notes |
6
- |-------|----------|--------|--------|-------|
7
- | `accounts` | accounts.ts | admin-data | complete | Full CRUD with account scoping |
8
- | `people` | people.ts | admin-data | complete | Full CRUD with account scoping |
9
- | `items` | items.ts | admin-data | complete | Full CRUD with type validation |
10
- | `types` | types.ts | admin-configs | complete | Unified for item/account/person types |
11
- | `apps` | apps.ts | admin-configs | complete | App definitions with nav items |
12
- | `roles` | roles.ts | admin-configs | complete | Role definitions and permissions |
13
- | `links` | links.ts | runtime | complete | Polymorphic entity relationships |
14
- | `link_types` | link_types.ts | admin-configs | complete | Link type definitions |
15
-
16
- ## Workflow & Automation Tables
17
-
18
- | Table | Endpoint | Domain | Status | Notes |
19
- |-------|----------|--------|--------|-------|
20
- | `pipelines` | pipelines.ts | admin-configs | complete | Workflow automation pipelines |
21
- | `pipeline_executions` | pipeline-executions.ts | runtime | complete | Pipeline execution history |
22
- | `triggers` | triggers.ts | admin-configs | complete | Trigger definitions |
23
- | `trigger_executions` | trigger_executions | runtime | RPC-only | Accessed via triggers.ts |
24
- | `timers` | timers.ts | admin-configs | complete | Scheduled/delayed timers |
25
-
26
- ## Collaboration & Communication Tables
27
-
28
- | Table | Endpoint | Domain | Status | Notes |
29
- |-------|----------|--------|--------|-------|
30
- | `threads` | threads.ts | runtime | complete | Conversation threads |
31
- | `messages` | messages.ts | runtime | complete | Thread messages |
32
- | `attachments` | attachments.ts | runtime | complete | File attachments |
33
- | `watchers` | watchers.ts | runtime | complete | Entity watching/subscriptions |
34
-
35
- ## Integration & AI Tables
36
-
37
- | Table | Endpoint | Domain | Status | Notes |
38
- |-------|----------|--------|--------|-------|
39
- | `integrations` | integrations.ts | admin-configs | complete | Integration instances |
40
- | `embeddings` | embeddings.ts | admin-configs | complete | Embedding vectors |
41
- | `ai_agents` | ai-agents.ts | admin-configs | complete | AI agent definitions |
42
- | `prompt_configs` | prompt-configs.ts | admin-configs | complete | AI prompt configurations |
43
-
44
- ## Access Control Tables
45
-
46
- | Table | Endpoint | Domain | Status | Notes |
47
- |-------|----------|--------|--------|-------|
48
- | `people_accounts` | people-accounts.ts | runtime | complete | People-Accounts junction |
49
- | `people_roles` | people-roles.ts | runtime | complete | People-Roles junction |
50
- | `account_paths` | account-nodes.ts | internal | RPC-only | Account hierarchy traversal |
51
-
52
- ## System & Logging Tables
53
-
54
- | Table | Endpoint | Domain | Status | Notes |
55
- |-------|----------|--------|--------|-------|
56
- | `logs` | logs.ts | internal | complete | System and application logs |
57
-
58
- ## v2-Incompatible Endpoints (Require Remediation)
59
-
60
- | Endpoint | Referenced Tables | Domain | Status | Action Required |
61
- |----------|------------------|--------|--------|-----------------|
62
- | ai-orchestrator.ts | `ai_orchestrator` | internal | v2-incompatible | Table does not exist in v2 schema |
63
- | pending-actions.ts | `pending_actions` | internal | v2-incompatible | Table does not exist in v2 schema |
64
- | apps-accounts.ts | `apps_accounts` | internal | v2-incompatible | Table does not exist in v2 schema |
65
- | apps-integrations.ts | `apps_integrations` | internal | v2-incompatible | Table does not exist in v2 schema |
66
- | impersonation.ts | `impersonation_sessions`, `impersonation_policies`, `impersonation_logs` | internal | v2-incompatible | Tables do not exist in v2 schema |
67
- | integration-health.ts | `integration_sync_logs`, `oauth_connections`, `api_keys`, `api_key_usage_logs` | internal | v2-incompatible | Tables do not exist in v2 schema |
68
- | thread-participants.ts | `thread_participants` | runtime | v2-incompatible | Table does not exist in v2 schema |
69
- | outbox.ts | `outbox` | internal | v2-incompatible | Table does not exist in v2 schema |
70
- | webhooks.ts | `webhooks` | internal | v2-incompatible | Table does not exist in v2 schema |
71
-
72
- ## Summary
73
-
74
- ### Complete Coverage: 18 tables
75
- - All core entity tables have proper endpoints
76
- - All workflow/automation tables are covered
77
- - All collaboration tables are covered
78
- - All integration/AI tables are covered
79
- - Access control tables are covered
80
- - System logging is covered
81
-
82
- ### v2-Incompatible: 9 endpoints
83
- - These endpoints reference tables that don't exist in v2 schema
84
- - Must be either rewritten to use existing v2 tables or quarantined
85
- - Priority: High - these will cause runtime errors if called
86
-
87
- ### Missing Endpoints: 0 tables
88
- - All v2 schema tables have corresponding endpoints
89
- - Some tables are accessed via RPC rather than direct queries (trigger_executions, account_paths)
90
-
91
- ### Recommendations
92
- 1. Quarantine v2-incompatible endpoints immediately
93
- 2. Rewrite or remove incompatible endpoints
94
- 3. Consider if missing functionality should be implemented with existing v2 tables
95
- 4. Update any UI that might be calling incompatible endpoints