oneie 3.7.0 → 3.8.1

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 (1156) hide show
  1. package/README.md +9 -9
  2. package/dist/commands/agent.d.ts +2 -0
  3. package/dist/commands/agent.d.ts.map +1 -1
  4. package/dist/commands/agent.js +44 -0
  5. package/dist/commands/agent.js.map +1 -1
  6. package/dist/commands/bounty.d.ts +4 -0
  7. package/dist/commands/bounty.d.ts.map +1 -0
  8. package/dist/commands/bounty.js +24 -0
  9. package/dist/commands/bounty.js.map +1 -0
  10. package/dist/commands/buy.d.ts +19 -0
  11. package/dist/commands/buy.d.ts.map +1 -0
  12. package/dist/commands/buy.js +63 -0
  13. package/dist/commands/buy.js.map +1 -0
  14. package/dist/commands/capabilities.d.ts +4 -0
  15. package/dist/commands/capabilities.d.ts.map +1 -0
  16. package/dist/commands/capabilities.js +18 -0
  17. package/dist/commands/capabilities.js.map +1 -0
  18. package/dist/commands/commend.d.ts +4 -0
  19. package/dist/commands/commend.d.ts.map +1 -0
  20. package/dist/commands/commend.js +13 -0
  21. package/dist/commands/commend.js.map +1 -0
  22. package/dist/commands/completion.d.ts +4 -0
  23. package/dist/commands/completion.d.ts.map +1 -0
  24. package/dist/commands/completion.js +49 -0
  25. package/dist/commands/completion.js.map +1 -0
  26. package/dist/commands/config.d.ts +4 -0
  27. package/dist/commands/config.d.ts.map +1 -0
  28. package/dist/commands/config.js +78 -0
  29. package/dist/commands/config.js.map +1 -0
  30. package/dist/commands/deploy.d.ts +1 -1
  31. package/dist/commands/deploy.d.ts.map +1 -1
  32. package/dist/commands/deploy.js +39 -4
  33. package/dist/commands/deploy.js.map +1 -1
  34. package/dist/commands/doctor.d.ts +4 -0
  35. package/dist/commands/doctor.d.ts.map +1 -0
  36. package/dist/commands/doctor.js +72 -0
  37. package/dist/commands/doctor.js.map +1 -0
  38. package/dist/commands/domain.d.ts +4 -0
  39. package/dist/commands/domain.d.ts.map +1 -0
  40. package/dist/commands/domain.js +19 -0
  41. package/dist/commands/domain.js.map +1 -0
  42. package/dist/commands/export.d.ts +4 -0
  43. package/dist/commands/export.d.ts.map +1 -0
  44. package/dist/commands/export.js +15 -0
  45. package/dist/commands/export.js.map +1 -0
  46. package/dist/commands/fade.d.ts.map +1 -1
  47. package/dist/commands/fade.js +8 -4
  48. package/dist/commands/fade.js.map +1 -1
  49. package/dist/commands/flag.d.ts +4 -0
  50. package/dist/commands/flag.d.ts.map +1 -0
  51. package/dist/commands/flag.js +13 -0
  52. package/dist/commands/flag.js.map +1 -0
  53. package/dist/commands/health.d.ts +4 -0
  54. package/dist/commands/health.d.ts.map +1 -0
  55. package/dist/commands/health.js +11 -0
  56. package/dist/commands/health.js.map +1 -0
  57. package/dist/commands/highways.d.ts.map +1 -1
  58. package/dist/commands/highways.js +7 -4
  59. package/dist/commands/highways.js.map +1 -1
  60. package/dist/commands/hire.d.ts +4 -0
  61. package/dist/commands/hire.d.ts.map +1 -0
  62. package/dist/commands/hire.js +16 -0
  63. package/dist/commands/hire.js.map +1 -0
  64. package/dist/commands/init.d.ts.map +1 -1
  65. package/dist/commands/init.js +85 -48
  66. package/dist/commands/init.js.map +1 -1
  67. package/dist/commands/invite.d.ts +4 -0
  68. package/dist/commands/invite.d.ts.map +1 -0
  69. package/dist/commands/invite.js +37 -0
  70. package/dist/commands/invite.js.map +1 -0
  71. package/dist/commands/mark.d.ts.map +1 -1
  72. package/dist/commands/mark.js +7 -7
  73. package/dist/commands/mark.js.map +1 -1
  74. package/dist/commands/pay.d.ts +4 -0
  75. package/dist/commands/pay.d.ts.map +1 -0
  76. package/dist/commands/pay.js +21 -0
  77. package/dist/commands/pay.js.map +1 -0
  78. package/dist/commands/pipe.d.ts +4 -0
  79. package/dist/commands/pipe.d.ts.map +1 -0
  80. package/dist/commands/pipe.js +35 -0
  81. package/dist/commands/pipe.js.map +1 -0
  82. package/dist/commands/publish.d.ts +4 -0
  83. package/dist/commands/publish.d.ts.map +1 -0
  84. package/dist/commands/publish.js +23 -0
  85. package/dist/commands/publish.js.map +1 -0
  86. package/dist/commands/repl.d.ts +4 -0
  87. package/dist/commands/repl.d.ts.map +1 -0
  88. package/dist/commands/repl.js +56 -0
  89. package/dist/commands/repl.js.map +1 -0
  90. package/dist/commands/revenue.d.ts +4 -0
  91. package/dist/commands/revenue.d.ts.map +1 -0
  92. package/dist/commands/revenue.js +11 -0
  93. package/dist/commands/revenue.js.map +1 -0
  94. package/dist/commands/sell.d.ts +15 -0
  95. package/dist/commands/sell.d.ts.map +1 -0
  96. package/dist/commands/sell.js +49 -0
  97. package/dist/commands/sell.js.map +1 -0
  98. package/dist/commands/stats.d.ts +4 -0
  99. package/dist/commands/stats.d.ts.map +1 -0
  100. package/dist/commands/stats.js +11 -0
  101. package/dist/commands/stats.js.map +1 -0
  102. package/dist/commands/status.d.ts +4 -0
  103. package/dist/commands/status.d.ts.map +1 -0
  104. package/dist/commands/status.js +18 -0
  105. package/dist/commands/status.js.map +1 -0
  106. package/dist/commands/subscribe.d.ts +14 -0
  107. package/dist/commands/subscribe.d.ts.map +1 -0
  108. package/dist/commands/subscribe.js +33 -0
  109. package/dist/commands/subscribe.js.map +1 -0
  110. package/dist/commands/tail.d.ts +4 -0
  111. package/dist/commands/tail.d.ts.map +1 -0
  112. package/dist/commands/tail.js +51 -0
  113. package/dist/commands/tail.js.map +1 -0
  114. package/dist/commands/warn.d.ts.map +1 -1
  115. package/dist/commands/warn.js +6 -6
  116. package/dist/commands/warn.js.map +1 -1
  117. package/dist/index.js +70 -1
  118. package/dist/index.js.map +1 -1
  119. package/dist/lib/args.d.ts +1 -0
  120. package/dist/lib/args.d.ts.map +1 -1
  121. package/dist/lib/args.js +3 -0
  122. package/dist/lib/args.js.map +1 -1
  123. package/dist/lib/output.d.ts +5 -0
  124. package/dist/lib/output.d.ts.map +1 -0
  125. package/dist/lib/output.js +32 -0
  126. package/dist/lib/output.js.map +1 -0
  127. package/dist/lib/sdk.d.ts +10 -0
  128. package/dist/lib/sdk.d.ts.map +1 -0
  129. package/dist/lib/sdk.js +22 -0
  130. package/dist/lib/sdk.js.map +1 -0
  131. package/dist/utils/installation-setup.d.ts +15 -0
  132. package/dist/utils/installation-setup.d.ts.map +1 -1
  133. package/dist/utils/installation-setup.js +63 -0
  134. package/dist/utils/installation-setup.js.map +1 -1
  135. package/package.json +3 -18
  136. package/.claude/agents/TROUBLESHOOTING.md +0 -530
  137. package/.claude/agents/agent-backend.md +0 -574
  138. package/.claude/agents/agent-builder.md +0 -911
  139. package/.claude/agents/agent-claude.md +0 -645
  140. package/.claude/agents/agent-clean.md +0 -477
  141. package/.claude/agents/agent-clone.md +0 -554
  142. package/.claude/agents/agent-designer.md +0 -1080
  143. package/.claude/agents/agent-director.md +0 -2254
  144. package/.claude/agents/agent-documenter.md +0 -688
  145. package/.claude/agents/agent-frontend.md +0 -1199
  146. package/.claude/agents/agent-integrator.md +0 -670
  147. package/.claude/agents/agent-lawyer.md +0 -1320
  148. package/.claude/agents/agent-news.md +0 -363
  149. package/.claude/agents/agent-onboard.md +0 -613
  150. package/.claude/agents/agent-ontology.md +0 -585
  151. package/.claude/agents/agent-ops.md +0 -1275
  152. package/.claude/agents/agent-problem-solver.md +0 -669
  153. package/.claude/agents/agent-quality.md +0 -1042
  154. package/.claude/agents/agent-sales.md +0 -507
  155. package/.claude/agents/agent-writer.md +0 -1068
  156. package/.claude/commands/cascade.md +0 -742
  157. package/.claude/commands/chat.md +0 -728
  158. package/.claude/commands/commit.md +0 -95
  159. package/.claude/commands/create.md +0 -544
  160. package/.claude/commands/deploy.md +0 -309
  161. package/.claude/commands/fast.md +0 -636
  162. package/.claude/commands/mcp-on.md +0 -191
  163. package/.claude/commands/media-upload.md +0 -186
  164. package/.claude/commands/news.md +0 -274
  165. package/.claude/commands/onboard.md +0 -440
  166. package/.claude/commands/one.md +0 -398
  167. package/.claude/commands/optimize.md +0 -74
  168. package/.claude/commands/plan.md +0 -719
  169. package/.claude/commands/push.md +0 -214
  170. package/.claude/commands/release.md +0 -105
  171. package/.claude/commands/review.md +0 -99
  172. package/.claude/commands/server.md +0 -487
  173. package/.claude/commands/start.md +0 -227
  174. package/.claude/commands/test.md +0 -197
  175. package/.claude/commands/validate.md +0 -140
  176. package/.claude/hooks/.last-news-context +0 -1
  177. package/.claude/hooks/PULL-BEFORE-PUSH-GUIDE.md +0 -473
  178. package/.claude/hooks/README-knowledge-hooks.md +0 -451
  179. package/.claude/hooks/README-news-generation.md +0 -364
  180. package/.claude/hooks/README-root-cleanup.md +0 -200
  181. package/.claude/hooks/README.md +0 -284
  182. package/.claude/hooks/__pycache__/todo.cpython-312.pyc +0 -0
  183. package/.claude/hooks/__pycache__/todo.cpython-313.pyc +0 -0
  184. package/.claude/hooks/auto-format.sh +0 -106
  185. package/.claude/hooks/check-filenames.py +0 -177
  186. package/.claude/hooks/clean-post.py +0 -468
  187. package/.claude/hooks/clean-pre.py +0 -393
  188. package/.claude/hooks/clean-root-markdown.sh +0 -73
  189. package/.claude/hooks/commit-push.sh +0 -95
  190. package/.claude/hooks/done.py +0 -236
  191. package/.claude/hooks/format-hook.sh +0 -163
  192. package/.claude/hooks/formatting.py +0 -187
  193. package/.claude/hooks/hook-logger.sh +0 -173
  194. package/.claude/hooks/knowledge-post.py +0 -355
  195. package/.claude/hooks/knowledge-pre.py +0 -245
  196. package/.claude/hooks/mcp-on.sh +0 -134
  197. package/.claude/hooks/notification-hook.sh +0 -279
  198. package/.claude/hooks/ontology-validation.py +0 -255
  199. package/.claude/hooks/push.sh +0 -153
  200. package/.claude/hooks/release-cli.sh +0 -205
  201. package/.claude/hooks/root-cleanup.py +0 -217
  202. package/.claude/hooks/security-hook.sh +0 -397
  203. package/.claude/hooks/tag-all-docs.py +0 -464
  204. package/.claude/hooks/test-validate-ontology.sh +0 -170
  205. package/.claude/hooks/todo.py +0 -368
  206. package/.claude/hooks/track-changes.sh +0 -101
  207. package/.claude/hooks/validate-imports.py +0 -182
  208. package/.claude/hooks/validate-ontology-structure-summary.md +0 -243
  209. package/.claude/hooks/validate-ontology-structure.py +0 -558
  210. package/.claude/hooks/validate-ontology-structure.py.backup +0 -518
  211. package/.claude/hooks/validate-ontology.py +0 -140
  212. package/.claude/hooks/write-news.sh +0 -194
  213. package/.claude/skills/INDEX.md +0 -523
  214. package/.claude/skills/REGISTRY.md +0 -529
  215. package/.claude/skills/agent-backend-create-mutation.md +0 -319
  216. package/.claude/skills/agent-designer-create-wireframe.md +0 -341
  217. package/.claude/skills/agent-frontend-create-page.md +0 -413
  218. package/.claude/skills/agents/README.md +0 -238
  219. package/.claude/skills/astro/add-content-collection.md +0 -30
  220. package/.claude/skills/astro/check-build.md +0 -29
  221. package/.claude/skills/astro/create-component.md +0 -29
  222. package/.claude/skills/astro/create-page.md +0 -30
  223. package/.claude/skills/astro/optimize-performance.md +0 -21
  224. package/.claude/skills/convex/check-deployment.md +0 -46
  225. package/.claude/skills/convex/create-mutation.md +0 -405
  226. package/.claude/skills/convex/create-query.md +0 -52
  227. package/.claude/skills/convex/read-schema.md +0 -373
  228. package/.claude/skills/convex/test-function.md +0 -50
  229. package/.claude/skills/deployment/check-deployment-health.md +0 -20
  230. package/.claude/skills/deployment/create-release.md +0 -21
  231. package/.claude/skills/deployment/deploy-cloudflare.md +0 -31
  232. package/.claude/skills/deployment/deploy-convex.md +0 -30
  233. package/.claude/skills/deployment/sync-repositories.md +0 -19
  234. package/.claude/skills/design/check-accessibility.md +0 -21
  235. package/.claude/skills/design/create-component-spec.md +0 -27
  236. package/.claude/skills/design/generate-design-tokens.md +0 -24
  237. package/.claude/skills/design/generate-wireframe.md +0 -30
  238. package/.claude/skills/documentation/create-migration-guide.md +0 -20
  239. package/.claude/skills/documentation/generate-api-docs.md +0 -27
  240. package/.claude/skills/documentation/generate-readme.md +0 -22
  241. package/.claude/skills/documentation/update-knowledge.md +0 -20
  242. package/.claude/skills/integration/connect-external-system.md +0 -21
  243. package/.claude/skills/integration/implement-a2a.md +0 -20
  244. package/.claude/skills/integration/implement-acp.md +0 -20
  245. package/.claude/skills/integration/verify-integration.md +0 -20
  246. package/.claude/skills/ontology/README.md +0 -255
  247. package/.claude/skills/ontology/check-dimension.md +0 -307
  248. package/.claude/skills/ontology/generate-entity-type.md +0 -339
  249. package/.claude/skills/ontology/validate-schema.md +0 -229
  250. package/.claude/skills/ontology/verify-relationships.md +0 -310
  251. package/.claude/skills/problem-solving/analyze-test-failure.md +0 -21
  252. package/.claude/skills/problem-solving/identify-root-cause.md +0 -20
  253. package/.claude/skills/problem-solving/propose-solution.md +0 -29
  254. package/.claude/skills/problem-solving/verify-fix.md +0 -21
  255. package/.claude/skills/sales/generate-demo-script.md +0 -21
  256. package/.claude/skills/sales/qualify-lead.md +0 -30
  257. package/.claude/skills/sales/track-trial.md +0 -20
  258. package/.claude/skills/sales/verify-kyc.md +0 -20
  259. package/.claude/skills/testing/analyze-coverage.md +0 -24
  260. package/.claude/skills/testing/generate-tests.md +0 -24
  261. package/.claude/skills/testing/run-tests.md +0 -27
  262. package/.claude/skills/testing/validate-e2e.md +0 -25
  263. package/AGENTS.md +0 -60
  264. package/CLAUDE.md +0 -130
  265. package/CREATE-WEBSITE.md +0 -458
  266. package/SECURITY.md +0 -31
  267. package/folders.yaml +0 -92
  268. package/one/README.md +0 -760
  269. package/one/actors/anthony-o-connell.md +0 -469
  270. package/one/actors/people.md +0 -590
  271. package/one/events/0-changes.md +0 -2764
  272. package/one/events/1-PROJECTS-START-HERE.md +0 -384
  273. package/one/events/1-projects-developer-quickstart.md +0 -620
  274. package/one/events/1-projects-feature.md +0 -2047
  275. package/one/events/1-projects-team-briefing.md +0 -583
  276. package/one/events/2024-10-14-deployment-plan.md +0 -330
  277. package/one/events/2024-10-14-deployment-success.md +0 -447
  278. package/one/events/2024-10-14-final-sync-complete.md +0 -250
  279. package/one/events/2024-10-14-release-v2.0.6.md +0 -414
  280. package/one/events/2024-10-15-agent-clean-v2-summary.md +0 -495
  281. package/one/events/2024-10-15-handoff-to-clean.md +0 -347
  282. package/one/events/2024-10-15-package-manager-tests.md +0 -442
  283. package/one/events/2024-10-15-release-command-complete.md +0 -416
  284. package/one/events/2025-10-15-private-files-secured.md +0 -359
  285. package/one/events/2025-10-15-unignore-public-group-docs.md +0 -298
  286. package/one/events/2025-11-08-backend-claude-refactor.md +0 -242
  287. package/one/events/2025-11-08-parallel-agent-implementation.md +0 -620
  288. package/one/events/2025-11-10-ai-integration-status-report.md +0 -241
  289. package/one/events/ACCESSIBILITY_CHECKLIST.md +0 -275
  290. package/one/events/ACCESSIBILITY_FIXES_SUMMARY.md +0 -293
  291. package/one/events/ALIGNMENT_REPORT_PROBLEM_SOLVER.md +0 -335
  292. package/one/events/ALIGNMENT_SUMMARY.md +0 -280
  293. package/one/events/API_ROUTES_FIXES_SUMMARY.md +0 -280
  294. package/one/events/ASTRO-INTEGRATION-EXAMPLES.md +0 -654
  295. package/one/events/AUDIT-ONTOLOGY-ALIGNMENT.md +0 -598
  296. package/one/events/AUDIT_PLAN_COMPLETION-20251108-125555.md +0 -262
  297. package/one/events/BEFORE_AFTER_COMPARISON.md +0 -978
  298. package/one/events/CART-DRAWER-INTEGRATION-GUIDE.md +0 -372
  299. package/one/events/CASCADE-2-BACKEND-AGNOSTIC.md +0 -430
  300. package/one/events/CHARTS-READY-TO-USE-20251106-080939.md +0 -184
  301. package/one/events/CHARTS-SUMMARY-20251106-080938.md +0 -196
  302. package/one/events/CLAUDE copy.md +0 -897
  303. package/one/events/CLEANUP-RELEASE-V2.0.8.md +0 -308
  304. package/one/events/CLOUDFLARE-FS-FIX-20251106-100516.md +0 -75
  305. package/one/events/COMPONENT_SHOWCASE-20251106-080938.md +0 -629
  306. package/one/events/CONNECTIONS_DEMO.md +0 -519
  307. package/one/events/CREATE-WEBSITE.md +0 -460
  308. package/one/events/CRITICAL-FIXES-COMPLETE.md +0 -571
  309. package/one/events/CUSTOM-DOMAIN.md +0 -375
  310. package/one/events/DELIVERABLES.md +0 -450
  311. package/one/events/DELIVERABLES.txt +0 -273
  312. package/one/events/DEMO-GROUPS-PAGE.md +0 -410
  313. package/one/events/DEMO-TESTING-SUMMARY.md +0 -536
  314. package/one/events/DEMO_COMPONENTS.md +0 -505
  315. package/one/events/DEMO_HOOKS_INDEX.md +0 -352
  316. package/one/events/DEMO_INFRASTRUCTURE.md +0 -923
  317. package/one/events/DEMO_INFRASTRUCTURE_SUMMARY.md +0 -588
  318. package/one/events/DEMO_INTEGRATION_CHECKLIST.md +0 -449
  319. package/one/events/DEMO_QUICK_REFERENCE.md +0 -459
  320. package/one/events/DEMO_SETUP.md +0 -494
  321. package/one/events/DEPLOYMENT copy.md +0 -444
  322. package/one/events/DEPLOYMENT.md +0 -196
  323. package/one/events/DESIGN-DELIVERABLES-20251106-080938.md +0 -557
  324. package/one/events/DESIGN-EXECUTIVE-SUMMARY-20251106-080938.md +0 -484
  325. package/one/events/DOCS-SYSTEM-GUIDE-20251105-142103.md +0 -458
  326. package/one/events/DOCUMENTER-DELIVERY-SUMMARY.md +0 -481
  327. package/one/events/DOCUMENTER-EXECUTION-GUIDE.md +0 -394
  328. package/one/events/DOCUMENTER-TASK-BREAKDOWN.md +0 -783
  329. package/one/events/ECOMMERCE-BEFORE-AFTER.md +0 -267
  330. package/one/events/ECOMMERCE-DEMO-PLAN.md +0 -243
  331. package/one/events/ECOMMERCE-ENHANCEMENTS.md +0 -594
  332. package/one/events/ECOMMERCE-HIGH-CONVERTING-ELEMENTS.md +0 -439
  333. package/one/events/ECOMMERCE-LIVE-DEMO.md +0 -381
  334. package/one/events/ECOMMERCE-QUICKSTART.md +0 -376
  335. package/one/events/ECOMMERCE-README.md +0 -354
  336. package/one/events/ECOMMERCE-REFACTOR-SUMMARY.md +0 -214
  337. package/one/events/ECOMMERCE-SETUP-SUMMARY.md +0 -414
  338. package/one/events/ECOMMERCE-TEMPLATE-COMPLETE.md +0 -753
  339. package/one/events/ECOMMERCE-TEMPLATES-SUMMARY.md +0 -941
  340. package/one/events/EFFECT_TS_API_PATTERN.md +0 -496
  341. package/one/events/EXECUTION-READY.md +0 -359
  342. package/one/events/EXECUTION-SUMMARY.md +0 -478
  343. package/one/events/FEATURE-2-4-COMPLETE.md +0 -320
  344. package/one/events/FEATURE_2_3_COMPLETE.md +0 -593
  345. package/one/events/FILE-REFERENCE-20251105-142103.md +0 -325
  346. package/one/events/GRADIENT-TEXT-PERMANENT-FIX.md +0 -241
  347. package/one/events/GROUPS-MIGRATION.md +0 -643
  348. package/one/events/GROUPS_DEMO_IMPLEMENTATION.md +0 -432
  349. package/one/events/HANDOFF.md +0 -331
  350. package/one/events/HOOKS-DEMO.md +0 -459
  351. package/one/events/IMPLEMENTATION-CHECKLIST-20251105-142103.md +0 -274
  352. package/one/events/IMPLEMENTATION-REPORT-DOCS-20251105-142102.md +0 -394
  353. package/one/events/IMPLEMENTATION-SUMMARY-FINAL.md +0 -568
  354. package/one/events/IMPLEMENTATION_SUMMARY-20251106-080938.md +0 -571
  355. package/one/events/IMPLEMENTATION_SUMMARY.md +0 -547
  356. package/one/events/INDEX-ALL-AGENTS.md +0 -190
  357. package/one/events/INDEX-FRONTEND-TESTING.md +0 -524
  358. package/one/events/INDEX-PROBLEM-SOLVER.md +0 -488
  359. package/one/events/INDEX-QUALITY-AGENT-INFER65.md +0 -455
  360. package/one/events/INDEX.md +0 -295
  361. package/one/events/INDEX_QUICK_START_REDESIGN-20251106-080939.md +0 -342
  362. package/one/events/INSTALL-TESTS.md +0 -311
  363. package/one/events/INSTALLATION_FOLDERS.md +0 -534
  364. package/one/events/INSTALLATION_FOLDERS_FILES.md +0 -223
  365. package/one/events/INSTALLATION_FOLDERS_SUMMARY.md +0 -437
  366. package/one/events/INTEGRATION-ARCHITECTURE.md +0 -579
  367. package/one/events/INTEGRATION-CHECKLIST.md +0 -1252
  368. package/one/events/INTEGRATION-ORCHESTRATION.md +0 -2641
  369. package/one/events/INTEGRATION-SUMMARY.md +0 -671
  370. package/one/events/LANDING-PAGE-EXAMPLE-OUTPUT.md +0 -684
  371. package/one/events/LANDING-PAGE-IMPLEMENTATION.md +0 -660
  372. package/one/events/LANDING-PAGE-QUICKSTART.md +0 -425
  373. package/one/events/LICENSE.md +0 -107
  374. package/one/events/MASTER-COORDINATION-PLAN.md +0 -613
  375. package/one/events/MASTER-ORCHESTRATION-INFER65.md +0 -441
  376. package/one/events/MASTER-PLAN-SUMMARY.md +0 -309
  377. package/one/events/MCP-CONFIGURATION.md +0 -354
  378. package/one/events/MCP-SETUP-COMPLETE.md +0 -223
  379. package/one/events/MIGRATION-REPORT.md +0 -453
  380. package/one/events/MIGRATION.md +0 -87
  381. package/one/events/MULTI-ONTOLOGY-COMPLETE-GUIDE.md +0 -1663
  382. package/one/events/MULTI-ONTOLOGY-IMPLEMENTATION-COMPLETE.md +0 -643
  383. package/one/events/NEWS-COMMANDS.md +0 -506
  384. package/one/events/NEWS-SYSTEM-SUMMARY.md +0 -480
  385. package/one/events/NODE-UPGRADE.md +0 -129
  386. package/one/events/ONBOARDING-IMPLEMENTATION-COMPLETE copy.md +0 -416
  387. package/one/events/ONTOLOGY-HOOKS-README.md +0 -718
  388. package/one/events/ONTOLOGY-INTEGRATION-MANIFEST.md +0 -383
  389. package/one/events/ONTOLOGY-TUTORIALS-SUMMARY.md +0 -569
  390. package/one/events/ONTOLOGY-TYPE-GENERATOR-SUMMARY.md +0 -491
  391. package/one/events/ONTOLOGY_DISCOVERY_IMPLEMENTATION.md +0 -504
  392. package/one/events/ONTOLOGY_DISCOVERY_QUICKSTART.md +0 -221
  393. package/one/events/PACKAGE-STRUCTURE.md +0 -328
  394. package/one/events/PLAN-COMPLETE.md +0 -429
  395. package/one/events/PLAYBOOK-SETUP-SUMMARY.md +0 -349
  396. package/one/events/PROBLEM-SOLVER-EXECUTIVE-SUMMARY.md +0 -484
  397. package/one/events/PROBLEM-SOLVER-QUICKSTART.md +0 -420
  398. package/one/events/PROJECTS-PLAN-SUMMARY.md +0 -480
  399. package/one/events/PROMPT_FIX_FRONTEND_ONLY.md +0 -585
  400. package/one/events/QA-CHECKLIST.md +0 -692
  401. package/one/events/QUALITY-AGENT-SUMMARY.md +0 -334
  402. package/one/events/QUALITY-EXECUTION-CHECKLIST.md +0 -593
  403. package/one/events/QUICK-REFERENCE-FRONTEND-TESTING.md +0 -475
  404. package/one/events/QUICK-START-ONTOLOGY.md +0 -426
  405. package/one/events/QUICK_START_REDESIGN-20251106-080938.md +0 -400
  406. package/one/events/README-PROBLEM-SOLVER.md +0 -394
  407. package/one/events/README-archived.md +0 -537
  408. package/one/events/README_QUICK_START_REDESIGN-20251106-080938.md +0 -484
  409. package/one/events/SEARCH_DEMO_CODE_REFERENCE.md +0 -657
  410. package/one/events/SEARCH_DEMO_DELIVERY.md +0 -433
  411. package/one/events/SEARCH_DEMO_SUMMARY.md +0 -321
  412. package/one/events/SEARCH_DEMO_VISUAL_GUIDE.md +0 -399
  413. package/one/events/SECURITY-AUDIT-FIXES.md +0 -394
  414. package/one/events/SECURITY-SCAN-COMPLETE.md +0 -299
  415. package/one/events/SHOP-BUILD-STATUS.md +0 -132
  416. package/one/events/SHOP-PREMIUM-UPDATE.md +0 -165
  417. package/one/events/SIMPLE_FIX_FRONTEND_ONLY.md +0 -280
  418. package/one/events/SITE-WIDE-GRADIENT-FIX.md +0 -317
  419. package/one/events/SPECIALIST-QUICK-REFERENCE.md +0 -678
  420. package/one/events/STORE-PRODUCTION-READY-STATUS.md +0 -377
  421. package/one/events/STRIPE-INTEGRATION.md +0 -432
  422. package/one/events/STRIPE-PAYMENT-METHODS-GUIDE.md +0 -447
  423. package/one/events/STRIPE-SETUP-GUIDE.md +0 -480
  424. package/one/events/TEST-PLAN-INDEX.md +0 -364
  425. package/one/events/TEST-PLAN.md +0 -1435
  426. package/one/events/TEST-SUMMARY.md +0 -411
  427. package/one/events/TESTING-DELIVERY.txt +0 -372
  428. package/one/events/TESTS-QUICK-REF.md +0 -280
  429. package/one/events/TRANSITIONS-QUICK-START.md +0 -159
  430. package/one/events/TRANSPARENCY-FIXES.md +0 -293
  431. package/one/events/TYPESCRIPT_FIXES.md +0 -170
  432. package/one/events/TYPESCRIPT_FIXES_COMPLETE.txt +0 -412
  433. package/one/events/TYPESCRIPT_FIXES_INDEX.md +0 -359
  434. package/one/events/VERIFICATION_CHECKLIST-20251106-080938.md +0 -326
  435. package/one/events/VIEW-TRANSITIONS.md +0 -446
  436. package/one/events/agent-command-implementation.md +0 -305
  437. package/one/events/agent-director-enhancement-summary.md +0 -404
  438. package/one/events/agent-director-routing-update.md +0 -214
  439. package/one/events/agent-onboard-implementation-summary.md +0 -475
  440. package/one/events/agent-ontology-alignment-completion.md +0 -263
  441. package/one/events/ai-integration-complete.md +0 -294
  442. package/one/events/ai-integration-lessons-learned.md +0 -511
  443. package/one/events/backend-integration-tests.md +0 -624
  444. package/one/events/backend-structure-diagram.txt +0 -393
  445. package/one/events/backend-structure-summary.txt +0 -269
  446. package/one/events/bullfm-video-podcast-analysis.md +0 -319
  447. package/one/events/clean-agent-ontology-cleanup-report.md +0 -371
  448. package/one/events/clean-agent-todo-analysis-summary.md +0 -336
  449. package/one/events/cloudflare-automation-complete.md +0 -350
  450. package/one/events/cloudflare-pages-infrastructure-setup.md +0 -282
  451. package/one/events/contact-page-complete.md +0 -316
  452. package/one/events/convex-analysis-index.md +0 -322
  453. package/one/events/convex-structure-analysis.md +0 -718
  454. package/one/events/creation-instructions-9-todos.md +0 -906
  455. package/one/events/cycle-3-video-player-port-20251108.md +0 -368
  456. package/one/events/cycle-3-video-player-port-complete-20251108.md +0 -334
  457. package/one/events/deployment-installation-folders.md +0 -178
  458. package/one/events/deployment-ops-summary.md +0 -386
  459. package/one/events/deployment-verification.md +0 -366
  460. package/one/events/design-spec-complete.md +0 -226
  461. package/one/events/documentation-audit-index.md +0 -473
  462. package/one/events/documentation-audit-summary.md +0 -417
  463. package/one/events/documentation-improvement-roadmap.md +0 -906
  464. package/one/events/documentation-standards-compliance-report.md +0 -538
  465. package/one/events/documentation-updates.md +0 -370
  466. package/one/events/events.md +0 -563
  467. package/one/events/fix-product-hydration-20251106.md +0 -211
  468. package/one/events/frontend-effects-complete.md +0 -584
  469. package/one/events/frontend-effects-orchestration.md +0 -1356
  470. package/one/events/frontend-effects-risk-register.md +0 -1055
  471. package/one/events/frontend-effects-week1-assignments.md +0 -1594
  472. package/one/events/hook-ontology-alignment-summary.md +0 -528
  473. package/one/events/installation-folders-workflow-integration.md +0 -458
  474. package/one/events/landing-page-generator.md +0 -476
  475. package/one/events/legal-assessment-2025-10-16.md +0 -1917
  476. package/one/events/master-coordination-plan.json +0 -1078
  477. package/one/events/master-plan-9-todos.md +0 -900
  478. package/one/events/mobile-performance-optimization.md +0 -179
  479. package/one/events/onboarding-implementation-complete.md +0 -523
  480. package/one/events/ontology-audit-agent-clone.md +0 -323
  481. package/one/events/ontology-test-examples.md +0 -580
  482. package/one/events/phase1-backend-implementation-complete.md +0 -536
  483. package/one/events/plan-completion-audit.md +0 -707
  484. package/one/events/plan-files-updated.md +0 -273
  485. package/one/events/production-readiness-plan.md +0 -389
  486. package/one/events/readme.md +0 -100
  487. package/one/events/release.md +0 -272
  488. package/one/events/root-cleanup-alignment-report.md +0 -265
  489. package/one/events/security-fixes-2025-01-15.md +0 -226
  490. package/one/events/separate-implementation-status.md +0 -555
  491. package/one/events/server-command-optimization-20251108.md +0 -150
  492. package/one/events/session-summary-2025-10-18.md +0 -366
  493. package/one/events/skills-complete.md +0 -351
  494. package/one/events/skills-infer-6-10-summary.md +0 -70
  495. package/one/events/skills-phase1-complete.md +0 -281
  496. package/one/events/specialist-assignments.md +0 -766
  497. package/one/events/structural-analysis-architecture-vs-plans.md +0 -600
  498. package/one/events/test-dashboard.md +0 -363
  499. package/one/events/test-index.md +0 -421
  500. package/one/events/test-report-ontology.md +0 -611
  501. package/one/events/testing-summary.md +0 -388
  502. package/one/events/todo-agent-builder.md +0 -1180
  503. package/one/events/todo-agent-director.md +0 -164
  504. package/one/events/todo-agent-documenter.md +0 -1815
  505. package/one/events/todo-agent-frontend.md +0 -1542
  506. package/one/events/todo-agent-problem-solver.md +0 -1682
  507. package/one/events/todo-agent-quality.md +0 -1647
  508. package/one/events/todo-refactoring-complete.md +0 -408
  509. package/one/events/wave1-backend-implementation-complete.md +0 -698
  510. package/one/events/web-AI_INTEGRATION_PHASE2_SUMMARY-20251111-152540.md +0 -529
  511. package/one/events/web-BUY-IN-CHATGPT-README-20251116-235241.md +0 -491
  512. package/one/events/web-CHARTS-IMPLEMENTATION-20251106-080939.md +0 -576
  513. package/one/events/web-CHARTS-QUICKSTART-20251106-080939.md +0 -416
  514. package/one/events/web-CODE-HIGHLIGHTING-SUMMARY-20251111-152540.md +0 -442
  515. package/one/events/web-DEPLOYMENT_SUMMARY-20251116-005428.md +0 -290
  516. package/one/events/web-DESIGN-SUMMARY-20251106-080939.md +0 -514
  517. package/one/events/web-README-AI-INTEGRATION-20251111-152540.md +0 -196
  518. package/one/events/web-RECHARTS-INTEGRATION-20251111-152540.md +0 -265
  519. package/one/events/web-RELEASE_OPTIMIZATION_PLAN-20251116-005428.md +0 -447
  520. package/one/events/web-TEST-CLEANUP-20251105-143205.md +0 -3
  521. package/one/events/web-USING-ANY-COMPONENT-IN-CHAT-20251111-152540.md +0 -561
  522. package/one/events/web-test-code-highlighting-20251111-152540.md +0 -231
  523. package/one/groups/features.md +0 -2904
  524. package/one/groups/groups.md +0 -587
  525. package/one/groups/one.md +0 -619
  526. package/one/groups/strategy-copy.md +0 -887
  527. package/one/learning/.obsidian/app.json +0 -1
  528. package/one/learning/.obsidian/appearance.json +0 -1
  529. package/one/learning/.obsidian/core-plugins.json +0 -33
  530. package/one/learning/.obsidian/ecommerce-ontology.md +0 -210
  531. package/one/learning/.obsidian/workspace.json +0 -211
  532. package/one/learning/100-inference-quick-reference.md +0 -449
  533. package/one/learning/ag-ui-protocol.md +0 -613
  534. package/one/learning/agent-onboard-usage.md +0 -630
  535. package/one/learning/agentic-commerce.md +0 -146
  536. package/one/learning/ai-agents-vs-memecoins-thesis.md +0 -683
  537. package/one/learning/ai-api-reference.md +0 -715
  538. package/one/learning/ai-platform.md +0 -323
  539. package/one/learning/ai-quickstart.md +0 -355
  540. package/one/learning/ai-sdk-implementation.md +0 -436
  541. package/one/learning/ai-token-crypto-analysis-framework.md +0 -1191
  542. package/one/learning/ai-token-paradigm-shift-2025.md +0 -732
  543. package/one/learning/altcoin-cycle-prediction-ontology.md +0 -884
  544. package/one/learning/altcoin-cycle-trading-strategy.md +0 -642
  545. package/one/learning/architecture-any-backend.md +0 -1589
  546. package/one/learning/architecture-diagram.md +0 -404
  547. package/one/learning/architecture-frontend.md +0 -1014
  548. package/one/learning/architecture.md +0 -1742
  549. package/one/learning/archived/ontology.old.md +0 -2840
  550. package/one/learning/astro-effect-complete-vision.md +0 -2148
  551. package/one/learning/astro-effect-simple-architecture.md +0 -750
  552. package/one/learning/audit-agent-onboard-alignment.md +0 -481
  553. package/one/learning/audit-agent-sales-alignment.md +0 -444
  554. package/one/learning/backend-api-reference.md +0 -728
  555. package/one/learning/cascading-context-specification.md +0 -1617
  556. package/one/learning/claude-code-integration.md +0 -1293
  557. package/one/learning/cli-claude-handoff.md +0 -736
  558. package/one/learning/context-engineering.md +0 -610
  559. package/one/learning/crypto-analysis-strategy.md +0 -1276
  560. package/one/learning/crypto-cycle-2024-2025-analysis.md +0 -44
  561. package/one/learning/crypto.md +0 -978
  562. package/one/learning/develop/design.md +0 -364
  563. package/one/learning/develop/index.md +0 -145
  564. package/one/learning/development-commands.md +0 -251
  565. package/one/learning/docs.md +0 -627
  566. package/one/learning/dsl.md +0 -1678
  567. package/one/learning/event-driven-documentation.md +0 -270
  568. package/one/learning/files.md +0 -2489
  569. package/one/learning/frontend.md +0 -1056
  570. package/one/learning/games-english.md +0 -691
  571. package/one/learning/games.md +0 -1082
  572. package/one/learning/generative-ui-patterns.md +0 -559
  573. package/one/learning/guidelines.md +0 -314
  574. package/one/learning/hono.md +0 -2127
  575. package/one/learning/implementation-examples.md +0 -2554
  576. package/one/learning/installation-folders.md +0 -366
  577. package/one/learning/institutional-cycle-paradigm-2025.md +0 -555
  578. package/one/learning/knowledge.md +0 -660
  579. package/one/learning/language.md +0 -998
  580. package/one/learning/lessons-learned.md +0 -378
  581. package/one/learning/lessons-website-building-focus.md +0 -382
  582. package/one/learning/merge-report.md +0 -254
  583. package/one/learning/metadata-system.md +0 -504
  584. package/one/learning/nine-padel-playbook.md +0 -229
  585. package/one/learning/one-protocol-ai-agents.md +0 -892
  586. package/one/learning/one-protocol-executive-report.md +0 -617
  587. package/one/learning/one-protocol-standard.md +0 -869
  588. package/one/learning/one-protocol-whitepaper.md +0 -756
  589. package/one/learning/ontology-blog.yaml +0 -47
  590. package/one/learning/ontology-cheatsheet.md +0 -617
  591. package/one/learning/ontology-community.yaml +0 -65
  592. package/one/learning/ontology-core-universal.md +0 -740
  593. package/one/learning/ontology-core.yaml +0 -63
  594. package/one/learning/ontology-courses.yaml +0 -76
  595. package/one/learning/ontology-creator.md +0 -402
  596. package/one/learning/ontology-crypto.md +0 -1603
  597. package/one/learning/ontology-developer-guide.md +0 -814
  598. package/one/learning/ontology-documentation.md +0 -377
  599. package/one/learning/ontology-ecommerce.md +0 -269
  600. package/one/learning/ontology-education-game.md +0 -1654
  601. package/one/learning/ontology-education.md +0 -938
  602. package/one/learning/ontology-engineering-specification.md +0 -1310
  603. package/one/learning/ontology-engineering.md +0 -1676
  604. package/one/learning/ontology-files.yaml +0 -525
  605. package/one/learning/ontology-frontend-master.md +0 -2898
  606. package/one/learning/ontology-frontend-specifications.md +0 -2196
  607. package/one/learning/ontology-frontend.md +0 -2475
  608. package/one/learning/ontology-index.md +0 -397
  609. package/one/learning/ontology-minimal.yaml +0 -301
  610. package/one/learning/ontology-portfolio.yaml +0 -45
  611. package/one/learning/ontology-quickstart.md +0 -602
  612. package/one/learning/ontology-release.md +0 -317
  613. package/one/learning/ontology-shop.yaml +0 -148
  614. package/one/learning/ontology-tokens.yaml +0 -51
  615. package/one/learning/ontology-tutorial.md +0 -455
  616. package/one/learning/ontology-v2.md +0 -4449
  617. package/one/learning/ontology-video-script.md +0 -939
  618. package/one/learning/ontology-visual-guide.md +0 -378
  619. package/one/learning/ontology.md +0 -3847
  620. package/one/learning/ontology.yaml +0 -1653
  621. package/one/learning/parallel-agents.md +0 -932
  622. package/one/learning/patterns/backend/convex-mutation-pattern.md +0 -130
  623. package/one/learning/patterns/backend/convex-query-pattern.md +0 -143
  624. package/one/learning/patterns/backend/mutation-template.md +0 -249
  625. package/one/learning/patterns/backend/query-template.md +0 -286
  626. package/one/learning/patterns/backend/service-template.md +0 -258
  627. package/one/learning/patterns/design/component-architecture.md +0 -435
  628. package/one/learning/patterns/design/index.md +0 -160
  629. package/one/learning/patterns/design/test-driven-design-pattern.md +0 -196
  630. package/one/learning/patterns/design/wireframe-template.md +0 -250
  631. package/one/learning/patterns/frontend/component-template.md +0 -246
  632. package/one/learning/patterns/frontend/form-template.md +0 -348
  633. package/one/learning/patterns/frontend/page-template.md +0 -209
  634. package/one/learning/patterns/frontend/react-component-pattern.md +0 -188
  635. package/one/learning/patterns/test/acceptance-criteria-template.md +0 -396
  636. package/one/learning/patterns/test/technical-test-template.md +0 -566
  637. package/one/learning/patterns/test/test-driven-pattern.md +0 -160
  638. package/one/learning/patterns/test/user-flow-template.md +0 -272
  639. package/one/learning/performance.md +0 -459
  640. package/one/learning/provider-agnostic-content.md +0 -995
  641. package/one/learning/provider-creation-guide.md +0 -1082
  642. package/one/learning/quality-loop.md +0 -419
  643. package/one/learning/quick-start-ontology-mapping.md +0 -773
  644. package/one/learning/readme-architecture.md +0 -158
  645. package/one/learning/readme.md +0 -149
  646. package/one/learning/rules.md +0 -644
  647. package/one/learning/score.md +0 -85
  648. package/one/learning/specifications.md +0 -873
  649. package/one/learning/tags.md +0 -148
  650. package/one/learning/todo-template.md +0 -269
  651. package/one/learning/todo.md +0 -269
  652. package/one/learning/troubleshooting.md +0 -434
  653. package/one/learning/typescript-patterns.md +0 -321
  654. package/one/learning/universal-generation-language.md +0 -827
  655. package/one/learning/x402-research.md +0 -104
  656. package/one/license.md +0 -107
  657. package/one/paths/a2a.md +0 -600
  658. package/one/paths/acp.md +0 -808
  659. package/one/paths/acps.md +0 -749
  660. package/one/paths/agentkit.md +0 -367
  661. package/one/paths/agui.md +0 -785
  662. package/one/paths/any-backend.md +0 -1720
  663. package/one/paths/ap2.md +0 -1072
  664. package/one/paths/api/queries-reference.md +0 -860
  665. package/one/paths/api-docs.md +0 -1909
  666. package/one/paths/api-reference.md +0 -1029
  667. package/one/paths/api.md +0 -2208
  668. package/one/paths/architecture-diagram.md +0 -112
  669. package/one/paths/communications.md +0 -467
  670. package/one/paths/connections.md +0 -357
  671. package/one/paths/copilotkit.md +0 -1577
  672. package/one/paths/cryptonetworks.md +0 -799
  673. package/one/paths/documentation.md +0 -1138
  674. package/one/paths/effect.md +0 -297
  675. package/one/paths/elizaos.md +0 -1308
  676. package/one/paths/groups.md +0 -814
  677. package/one/paths/inference.md +0 -76
  678. package/one/paths/integration-examples.md +0 -893
  679. package/one/paths/integration-guide.md +0 -887
  680. package/one/paths/integration-phase2.md +0 -754
  681. package/one/paths/kyc.md +0 -650
  682. package/one/paths/mcp.md +0 -860
  683. package/one/paths/membership.md +0 -1170
  684. package/one/paths/middleware.md +0 -1085
  685. package/one/paths/multitenant.md +0 -1359
  686. package/one/paths/n8n.md +0 -1033
  687. package/one/paths/patterns.md +0 -107
  688. package/one/paths/protocols.md +0 -297
  689. package/one/paths/relationships.md +0 -125
  690. package/one/paths/schema.md +0 -605
  691. package/one/paths/service-layer.md +0 -568
  692. package/one/paths/vectors.md +0 -225
  693. package/one/paths/wordpress.md +0 -1320
  694. package/one/paths/workflow-copy.md +0 -923
  695. package/one/paths/workflow-examples.md +0 -759
  696. package/one/paths/workflow-onboarding.md +0 -701
  697. package/one/paths/workflow.md +0 -923
  698. package/one/paths/workflows/delegation.md +0 -903
  699. package/one/paths/workflows/frontend.md +0 -1055
  700. package/one/paths/workflows/strategy.md +0 -921
  701. package/one/paths/workflows/tasks.md +0 -716
  702. package/one/paths/x402-baazar.md +0 -131
  703. package/one/paths/x402.md +0 -1353
  704. package/one/things/ALIGNMENT_AUDIT_QUALITY_AGENT.md +0 -401
  705. package/one/things/AUDIT_AGENT_INTEGRATOR_ALIGNMENT.md +0 -588
  706. package/one/things/AUDIT_REPORT_AGENT_CLEAN.md +0 -461
  707. package/one/things/CHECKLIST.md +0 -407
  708. package/one/things/IMPLEMENTATION_STATUS.md +0 -379
  709. package/one/things/ONE.md +0 -529
  710. package/one/things/agents/agent-backend.md +0 -1501
  711. package/one/things/agents/agent-builder.md +0 -1064
  712. package/one/things/agents/agent-clean.md +0 -1112
  713. package/one/things/agents/agent-clone.md +0 -1324
  714. package/one/things/agents/agent-deploy.md +0 -986
  715. package/one/things/agents/agent-designer.md +0 -2305
  716. package/one/things/agents/agent-director.md +0 -1526
  717. package/one/things/agents/agent-documenter.md +0 -1129
  718. package/one/things/agents/agent-frontend.md +0 -1201
  719. package/one/things/agents/agent-integrator.md +0 -1269
  720. package/one/things/agents/agent-lawyer.md +0 -1371
  721. package/one/things/agents/agent-problem-solver.md +0 -1457
  722. package/one/things/agents/agent-quality.md +0 -1483
  723. package/one/things/agents/agent-sales.md +0 -1074
  724. package/one/things/cascade/cascade.yaml +0 -481
  725. package/one/things/cascade/docs/examples/1-1-agent-prompts/design.md +0 -523
  726. package/one/things/cascade/docs/examples/1-1-agent-prompts/tests.md +0 -314
  727. package/one/things/cascade/docs/examples/1-1-agent-prompts.md +0 -562
  728. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/design.md +0 -543
  729. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/tests.md +0 -272
  730. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator.md +0 -548
  731. package/one/things/cascade/docs/examples/1-3-event-coordination/design.md +0 -586
  732. package/one/things/cascade/docs/examples/1-3-event-coordination/tests.md +0 -267
  733. package/one/things/cascade/docs/examples/1-3-event-coordination.md +0 -547
  734. package/one/things/cascade/docs/examples/1-4-knowledge-management/design.md +0 -665
  735. package/one/things/cascade/docs/examples/1-4-knowledge-management/tests.md +0 -236
  736. package/one/things/cascade/docs/examples/1-4-knowledge-management.md +0 -652
  737. package/one/things/cascade/docs/examples/1-5-quality-loops/design.md +0 -860
  738. package/one/things/cascade/docs/examples/1-5-quality-loops/tests.md +0 -255
  739. package/one/things/cascade/docs/examples/1-5-quality-loops.md +0 -725
  740. package/one/things/cascade/docs/examples/1-6-numbering-structure/design.md +0 -659
  741. package/one/things/cascade/docs/examples/1-6-numbering-structure/tests.md +0 -256
  742. package/one/things/cascade/docs/examples/1-6-numbering-structure.md +0 -639
  743. package/one/things/cascade/docs/examples/readme.md +0 -259
  744. package/one/things/cascade/docs/getting-started.md +0 -533
  745. package/one/things/cascade/docs/workflow.md +0 -1378
  746. package/one/things/cascade/readme.md +0 -379
  747. package/one/things/cascade/templates/feature-template.md +0 -289
  748. package/one/things/claude/agents/advocacy-activation-manager.md +0 -710
  749. package/one/things/claude/agents/advocacy-campaign-designer.md +0 -688
  750. package/one/things/claude/agents/analyst.md +0 -508
  751. package/one/things/claude/agents/architect.md +0 -505
  752. package/one/things/claude/agents/brand-identity-specialist.md +0 -538
  753. package/one/things/claude/agents/bstp-token-strategist.md +0 -690
  754. package/one/things/claude/agents/builder-repo.md +0 -532
  755. package/one/things/claude/agents/bullstamp-community-builder.md +0 -597
  756. package/one/things/claude/agents/bullstamp-marketing-orchestrator.md +0 -529
  757. package/one/things/claude/agents/bulltilt-platform-growth.md +0 -590
  758. package/one/things/claude/agents/company-bullstamp-character.md +0 -602
  759. package/one/things/claude/agents/company-bullstamp-community.md +0 -307
  760. package/one/things/claude/agents/company-bullstamp-marketing.md +0 -307
  761. package/one/things/claude/agents/company-bullstamp-token.md +0 -307
  762. package/one/things/claude/agents/company-bulltilt-growth.md +0 -307
  763. package/one/things/claude/agents/content-bibliography-formatter.md +0 -404
  764. package/one/things/claude/agents/content-calendar-planner.md +0 -473
  765. package/one/things/claude/agents/content-chapter-formatter.md +0 -513
  766. package/one/things/claude/agents/content-formatter.md +0 -571
  767. package/one/things/claude/agents/content-hook-specialist.md +0 -485
  768. package/one/things/claude/agents/content-image-formatter.md +0 -560
  769. package/one/things/claude/agents/content-introduction-formatter.md +0 -510
  770. package/one/things/claude/agents/content-multiplication-engine.md +0 -579
  771. package/one/things/claude/agents/content-playbook-writer.md +0 -473
  772. package/one/things/claude/agents/content-team-manager.md +0 -647
  773. package/one/things/claude/agents/content-toc-formatter.md +0 -547
  774. package/one/things/claude/agents/convex-backend-specialist.md +0 -2725
  775. package/one/things/claude/agents/core-manager.md +0 -607
  776. package/one/things/claude/agents/core-master.md +0 -426
  777. package/one/things/claude/agents/cross-functional-manager.md +0 -476
  778. package/one/things/claude/agents/crypto-airdrop-strategist.md +0 -622
  779. package/one/things/claude/agents/crypto-analytics-educator.md +0 -596
  780. package/one/things/claude/agents/crypto-architecture-specialist.md +0 -497
  781. package/one/things/claude/agents/crypto-community-analyst.md +0 -314
  782. package/one/things/claude/agents/crypto-community-psychologist.md +0 -546
  783. package/one/things/claude/agents/crypto-dex-optimization-expert.md +0 -579
  784. package/one/things/claude/agents/crypto-dex-optimizer.md +0 -307
  785. package/one/things/claude/agents/crypto-diamond-formation-specialist.md +0 -552
  786. package/one/things/claude/agents/crypto-diamond-hands.md +0 -307
  787. package/one/things/claude/agents/crypto-ecosystem-expansion-manager.md +0 -597
  788. package/one/things/claude/agents/crypto-engagement-specialist.md +0 -581
  789. package/one/things/claude/agents/crypto-market-researcher.md +0 -307
  790. package/one/things/claude/agents/crypto-marketing-orchestrator.md +0 -563
  791. package/one/things/claude/agents/crypto-network-effect-amplifier.md +0 -614
  792. package/one/things/claude/agents/crypto-optimization-analyst.md +0 -597
  793. package/one/things/claude/agents/crypto-strategic-synthesizer.md +0 -556
  794. package/one/things/claude/agents/crypto-team-manager.md +0 -392
  795. package/one/things/claude/agents/crypto-token-analyst.md +0 -319
  796. package/one/things/claude/agents/crypto-viral-content-creator.md +0 -549
  797. package/one/things/claude/agents/crypto-wallet-identification-expert.md +0 -527
  798. package/one/things/claude/agents/crypto-wallet-identifier.md +0 -307
  799. package/one/things/claude/agents/customer-journey-designer.md +0 -474
  800. package/one/things/claude/agents/customer-success-manager.md +0 -574
  801. package/one/things/claude/agents/dev.md +0 -406
  802. package/one/things/claude/agents/documenter.md +0 -548
  803. package/one/things/claude/agents/elevate-marketing-orchestrator.md +0 -403
  804. package/one/things/claude/agents/engagement-specialist.md +0 -502
  805. package/one/things/claude/agents/engineering-architect.md +0 -387
  806. package/one/things/claude/agents/engineering-business-analyst.md +0 -527
  807. package/one/things/claude/agents/engineering-developer.md +0 -386
  808. package/one/things/claude/agents/engineering-director.md +0 -322
  809. package/one/things/claude/agents/engineering-ingestor.md +0 -659
  810. package/one/things/claude/agents/engineering-product-manager.md +0 -525
  811. package/one/things/claude/agents/engineering-product-owner.md +0 -527
  812. package/one/things/claude/agents/engineering-project-coordinator.md +0 -525
  813. package/one/things/claude/agents/engineering-quality-assurance.md +0 -392
  814. package/one/things/claude/agents/engineering-team-manager.md +0 -515
  815. package/one/things/claude/agents/engineering-user-experience.md +0 -386
  816. package/one/things/claude/agents/framework-elevate-manager.md +0 -309
  817. package/one/things/claude/agents/improver.md +0 -805
  818. package/one/things/claude/agents/intelligence-team-manager.md +0 -390
  819. package/one/things/claude/agents/lead-capture-expert.md +0 -459
  820. package/one/things/claude/agents/lead-magnet-creator.md +0 -446
  821. package/one/things/claude/agents/market-research-analyst.md +0 -435
  822. package/one/things/claude/agents/marketing-brand-identity.md +0 -344
  823. package/one/things/claude/agents/marketing-content-hooks.md +0 -455
  824. package/one/things/claude/agents/marketing-content-multiplier.md +0 -331
  825. package/one/things/claude/agents/marketing-content-poster.md +0 -372
  826. package/one/things/claude/agents/marketing-customer-journey.md +0 -331
  827. package/one/things/claude/agents/marketing-director.md +0 -402
  828. package/one/things/claude/agents/marketing-engagement.md +0 -331
  829. package/one/things/claude/agents/marketing-lead-capture.md +0 -331
  830. package/one/things/claude/agents/marketing-lead-magnet.md +0 -331
  831. package/one/things/claude/agents/marketing-network-effects.md +0 -331
  832. package/one/things/claude/agents/marketing-nurture-campaigns.md +0 -331
  833. package/one/things/claude/agents/marketing-share-optimizer.md +0 -331
  834. package/one/things/claude/agents/marketing-team-manager.md +0 -451
  835. package/one/things/claude/agents/marketing-viral-growth.md +0 -232
  836. package/one/things/claude/agents/mission-commander.md +0 -378
  837. package/one/things/claude/agents/network-effect-analyst.md +0 -604
  838. package/one/things/claude/agents/nextjs-15-specialist.md +0 -1634
  839. package/one/things/claude/agents/npx.md +0 -946
  840. package/one/things/claude/agents/nurture-campaign-manager.md +0 -554
  841. package/one/things/claude/agents/one-master.md +0 -378
  842. package/one/things/claude/agents/one-orchestrator.md +0 -345
  843. package/one/things/claude/agents/one.md +0 -658
  844. package/one/things/claude/agents/playbook-generator.md +0 -526
  845. package/one/things/claude/agents/pm.md +0 -349
  846. package/one/things/claude/agents/po.md +0 -370
  847. package/one/things/claude/agents/qa.md +0 -361
  848. package/one/things/claude/agents/research-foundation-analyst.md +0 -324
  849. package/one/things/claude/agents/research-intelligence-gatherer.md +0 -435
  850. package/one/things/claude/agents/research-market-analyst.md +0 -324
  851. package/one/things/claude/agents/research-team-manager.md +0 -489
  852. package/one/things/claude/agents/sales-environment-optimizer.md +0 -519
  853. package/one/things/claude/agents/sales-team-manager.md +0 -407
  854. package/one/things/claude/agents/sales-upsell-strategist.md +0 -324
  855. package/one/things/claude/agents/service-advocacy-campaigns.md +0 -324
  856. package/one/things/claude/agents/service-advocacy-manager.md +0 -324
  857. package/one/things/claude/agents/service-success-manager.md +0 -324
  858. package/one/things/claude/agents/service-team-manager.md +0 -405
  859. package/one/things/claude/agents/shadcn-ui-design-system-specialist.md +0 -2357
  860. package/one/things/claude/agents/share-optimization-specialist.md +0 -576
  861. package/one/things/claude/agents/sm.md +0 -352
  862. package/one/things/claude/agents/story-teller.md +0 -498
  863. package/one/things/claude/agents/task-master.md +0 -621
  864. package/one/things/claude/agents/tauri-cross-platform-specialist.md +0 -1912
  865. package/one/things/claude/agents/tester.md +0 -595
  866. package/one/things/claude/agents/the-bull-character-manager.md +0 -603
  867. package/one/things/claude/agents/tools-playbook-generator.md +0 -492
  868. package/one/things/claude/agents/turbo-repo-builder.md +0 -346
  869. package/one/things/claude/agents/upsell-strategist.md +0 -503
  870. package/one/things/claude/agents/ux-expert.md +0 -360
  871. package/one/things/claude/agents/viral-growth-orchestrator.md +0 -520
  872. package/one/things/claude/claude-code-hooks-development.json +0 -21
  873. package/one/things/claude/claude-code-hooks-production.json +0 -21
  874. package/one/things/claude/claude-code-hooks.json +0 -25
  875. package/one/things/claude/commands/agent.md +0 -124
  876. package/one/things/claude/commands/cascade-status.md +0 -153
  877. package/one/things/claude/commands/ingest.md +0 -343
  878. package/one/things/claude/commands/ingestor.md +0 -158
  879. package/one/things/claude/commands/mission.md +0 -103
  880. package/one/things/claude/commands/npx.md +0 -156
  881. package/one/things/claude/commands/one.md +0 -486
  882. package/one/things/claude/commands/quality-check.md +0 -252
  883. package/one/things/claude/commands/smart-route.md +0 -261
  884. package/one/things/claude/commands/start.md +0 -139
  885. package/one/things/claude/commands/story.md +0 -103
  886. package/one/things/claude/commands/task.md +0 -193
  887. package/one/things/claude/hook-bypass.json +0 -32
  888. package/one/things/claude/hooks/agent-hook-config.json +0 -427
  889. package/one/things/claude/hooks/build-hook.sh +0 -156
  890. package/one/things/claude/hooks/cleanup-hook.sh +0 -201
  891. package/one/things/claude/hooks/file-organization-hook.sh +0 -80
  892. package/one/things/claude/hooks/format-hook.sh +0 -43
  893. package/one/things/claude/hooks/hook-bypass.sh +0 -293
  894. package/one/things/claude/hooks/hook-debouncer.sh +0 -62
  895. package/one/things/claude/hooks/hook-logger.sh +0 -89
  896. package/one/things/claude/hooks/lint-hook.sh +0 -140
  897. package/one/things/claude/hooks/notification-hook.sh +0 -204
  898. package/one/things/claude/hooks/ontology-validation-hook.sh +0 -86
  899. package/one/things/claude/hooks/performance-metrics.json +0 -25
  900. package/one/things/claude/hooks/security-hook.sh +0 -256
  901. package/one/things/claude/hooks/story-validation-hook-enhanced.sh +0 -210
  902. package/one/things/claude/hooks/story-validation-hook.sh +0 -145
  903. package/one/things/claude/hooks/test-hook.sh +0 -145
  904. package/one/things/claude/hooks/test-story-validation.sh +0 -170
  905. package/one/things/claude/settings-local.json +0 -86
  906. package/one/things/cli/cli-code.md +0 -677
  907. package/one/things/cli/cli-compiler-code.md +0 -677
  908. package/one/things/cli/cli.md +0 -871
  909. package/one/things/components/card-shadcn.md +0 -953
  910. package/one/things/components/card.md +0 -1041
  911. package/one/things/components.md +0 -1743
  912. package/one/things/componets.md +0 -19
  913. package/one/things/contracts/Move.toml +0 -12
  914. package/one/things/contracts/README.md +0 -288
  915. package/one/things/contracts/one.move +0 -762
  916. package/one/things/contracts/sdk.ts +0 -579
  917. package/one/things/creator-diagram.md +0 -184
  918. package/one/things/crypto/FEATURES.md +0 -78
  919. package/one/things/crypto/ONECORE.md +0 -62
  920. package/one/things/crypto/ONECOREFAQ.md +0 -22
  921. package/one/things/crypto/ONECOREHOW.md +0 -46
  922. package/one/things/crypto/ONEENTERPRISE.md +0 -64
  923. package/one/things/crypto/ONEENTERPRISEFAQ.md +0 -64
  924. package/one/things/crypto/ONEENTERPRISEHOW.md +0 -53
  925. package/one/things/crypto/ONEPRO.md +0 -60
  926. package/one/things/crypto/ONEPROFAQ.md +0 -22
  927. package/one/things/crypto/ONEPROHOW.md +0 -53
  928. package/one/things/crypto/READMEAGENCY.md +0 -64
  929. package/one/things/crypto/VSL.md +0 -45
  930. package/one/things/crypto/WebsiteCopy.md +0 -176
  931. package/one/things/demo-accessibility-animations.md +0 -1025
  932. package/one/things/demo-components.md +0 -1310
  933. package/one/things/demo-design-summary.md +0 -692
  934. package/one/things/demo-design-system.md +0 -973
  935. package/one/things/demo-page-layouts.md +0 -1016
  936. package/one/things/design-system.md +0 -832
  937. package/one/things/designs/accessibility-audit.md +0 -877
  938. package/one/things/designs/component-specifications.md +0 -855
  939. package/one/things/designs/design-overview.md +0 -377
  940. package/one/things/designs/design-tokens.md +0 -448
  941. package/one/things/designs/wireframes-dashboard.md +0 -710
  942. package/one/things/docs/api-requests.md +0 -987
  943. package/one/things/docs/ecommerce/ARCHITECTURE-DIAGRAM.md +0 -485
  944. package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-IMPLEMENTATION.md +0 -465
  945. package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-SUMMARY.md +0 -425
  946. package/one/things/docs/ecommerce/CONVERSION-UX-IMPLEMENTATION-SUMMARY.md +0 -451
  947. package/one/things/docs/ecommerce/FEATURE-SUMMARY.md +0 -536
  948. package/one/things/docs/ecommerce/IMPLEMENTATION-NOTES.md +0 -650
  949. package/one/things/docs/ecommerce/INTEGRATION-EXAMPLE.md +0 -473
  950. package/one/things/docs/ecommerce/QUICK-START.md +0 -405
  951. package/one/things/docs/ecommerce/URGENCY-IMPLEMENTATION-SUMMARY.md +0 -567
  952. package/one/things/docs/ecommerce/URGENCY-QUICK-REFERENCE.md +0 -271
  953. package/one/things/docs/ecommerce/USAGE-EXAMPLE.astro +0 -171
  954. package/one/things/docs/ecommerce/demo.astro +0 -309
  955. package/one/things/examples/children/lemonade-stand.md +0 -404
  956. package/one/things/examples/enterprise/crm-saas.md +0 -1444
  957. package/one/things/features/1-1-agent-prompts.md +0 -562
  958. package/one/things/features/1-2-yaml-orchestrator.md +0 -548
  959. package/one/things/features/1-3-event-coordination.md +0 -547
  960. package/one/things/features/1-4-knowledge-management.md +0 -652
  961. package/one/things/features/1-5-quality-loops.md +0 -725
  962. package/one/things/features/1-6-numbering-structure.md +0 -639
  963. package/one/things/features/2-1-dataprovider-interface.md +0 -2583
  964. package/one/things/features/2-2-config-system.md +0 -3242
  965. package/one/things/features/2-3-effectts-services.md +0 -1645
  966. package/one/things/features/2-4-react-hooks.md +0 -2136
  967. package/one/things/features/2-5-auth-migration.md +0 -2144
  968. package/one/things/features/2-6-dashboard-migration.md +0 -2084
  969. package/one/things/features/2-7-alternative-providers.md +0 -2578
  970. package/one/things/features/2-7-implementation-report.md +0 -724
  971. package/one/things/features/2-cli.md +0 -1720
  972. package/one/things/features/2-design.md +0 -1770
  973. package/one/things/features/2-tests.md +0 -576
  974. package/one/things/features/AUTH_HOOKS_IMPLEMENTATION.md +0 -576
  975. package/one/things/features/DECOUPLING.md +0 -290
  976. package/one/things/features/DEPLOYMENT.md +0 -470
  977. package/one/things/features/IMPLEMENTATION_SUMMARY.md +0 -362
  978. package/one/things/features/improve.md +0 -861
  979. package/one/things/features/remove-convex-deps.md +0 -63
  980. package/one/things/features/top-features.md +0 -87
  981. package/one/things/features/use-one-backend.md +0 -1217
  982. package/one/things/features-in-english.md +0 -200
  983. package/one/things/files.yaml +0 -721
  984. package/one/things/ideas/1-create-workflow.md +0 -207
  985. package/one/things/ideas/2-backend-agnostic-frontend.md +0 -439
  986. package/one/things/implementation/backend-guide.md +0 -457
  987. package/one/things/interface.md +0 -257
  988. package/one/things/landing-page-implementation.md +0 -455
  989. package/one/things/legal/README.md +0 -234
  990. package/one/things/legal/privacy-policy.md +0 -1227
  991. package/one/things/legal/terms-of-service.md +0 -1432
  992. package/one/things/master-workflow-plan.md +0 -806
  993. package/one/things/pay.one.ie.md +0 -53
  994. package/one/things/plans/0-in-sync.md +0 -136
  995. package/one/things/plans/0-timeline.md +0 -36
  996. package/one/things/plans/1-create-workflow.md +0 -732
  997. package/one/things/plans/QUICK-START-SIMPLIFICATION.md +0 -333
  998. package/one/things/plans/README-SIMPLIFICATION.md +0 -349
  999. package/one/things/plans/SIMPLIFICATION-EXAMPLES.md +0 -16
  1000. package/one/things/plans/SIMPLIFICATION-SUMMARY.md +0 -455
  1001. package/one/things/plans/ai-elements-integration.md +0 -483
  1002. package/one/things/plans/ai-elements.md +0 -1278
  1003. package/one/things/plans/ai-integration-plan.md +0 -263
  1004. package/one/things/plans/ai-integration.md +0 -996
  1005. package/one/things/plans/ai-sdk.md +0 -798
  1006. package/one/things/plans/ai-tools.md +0 -621
  1007. package/one/things/plans/app.md +0 -832
  1008. package/one/things/plans/architecture-summary.md +0 -312
  1009. package/one/things/plans/async-ai-agents.md +0 -233
  1010. package/one/things/plans/backend-agnostic-frontend.md +0 -390
  1011. package/one/things/plans/backend-cleanup-quickstart.md +0 -380
  1012. package/one/things/plans/backend-ontology-conformance.md +0 -475
  1013. package/one/things/plans/backend-status.md +0 -599
  1014. package/one/things/plans/backend-structure.md +0 -847
  1015. package/one/things/plans/backend-target-structure.md +0 -482
  1016. package/one/things/plans/backend.md +0 -1175
  1017. package/one/things/plans/better-auth-any-backend-revised.md +0 -1103
  1018. package/one/things/plans/better-auth-any-backend.md +0 -1896
  1019. package/one/things/plans/better-auth-available-features.md +0 -273
  1020. package/one/things/plans/big-plan.md +0 -52
  1021. package/one/things/plans/cli-updates-required.md +0 -320
  1022. package/one/things/plans/complete-step-by-step.md +0 -1409
  1023. package/one/things/plans/components.md +0 -709
  1024. package/one/things/plans/convex-agents.md +0 -1034
  1025. package/one/things/plans/convex-better-auth.md +0 -1141
  1026. package/one/things/plans/convex-on-off.md +0 -407
  1027. package/one/things/plans/crypto-token-researcher.md +0 -629
  1028. package/one/things/plans/data-quality-metrics.md +0 -745
  1029. package/one/things/plans/deep-researcher-agent.md +0 -466
  1030. package/one/things/plans/deploy-to-cloudflare.md +0 -623
  1031. package/one/things/plans/deployment-architecture.md +0 -469
  1032. package/one/things/plans/desktop.md +0 -1139
  1033. package/one/things/plans/development-plan.md +0 -1283
  1034. package/one/things/plans/development-workflow-tldr.md +0 -207
  1035. package/one/things/plans/development-workflow.md +0 -959
  1036. package/one/things/plans/dsl-claude-code.md +0 -1011
  1037. package/one/things/plans/effect-components.md +0 -1743
  1038. package/one/things/plans/effect-patterns-reference.md +0 -2235
  1039. package/one/things/plans/effect.md +0 -1806
  1040. package/one/things/plans/email.md +0 -966
  1041. package/one/things/plans/enhance-auth.md +0 -1692
  1042. package/one/things/plans/execution-strategy.md +0 -1291
  1043. package/one/things/plans/existing-infrastructure.md +0 -712
  1044. package/one/things/plans/feature-based-sites.md +0 -894
  1045. package/one/things/plans/frontend-effects.md +0 -1276
  1046. package/one/things/plans/group-folder-multi-tenancy.md +0 -893
  1047. package/one/things/plans/improve-codebase.md +0 -1811
  1048. package/one/things/plans/install-components.md +0 -215
  1049. package/one/things/plans/integrate-frontend-and-backend.md +0 -603
  1050. package/one/things/plans/landing.md +0 -820
  1051. package/one/things/plans/layout.md +0 -249
  1052. package/one/things/plans/mail-backend.md +0 -1361
  1053. package/one/things/plans/mail.md +0 -2677
  1054. package/one/things/plans/mcp-clear-context-prompt.md +0 -81
  1055. package/one/things/plans/mcp-simple.md +0 -248
  1056. package/one/things/plans/multi-ontology-architecture.md +0 -885
  1057. package/one/things/plans/next-features.md +0 -114
  1058. package/one/things/plans/npx-agent-safety.md +0 -785
  1059. package/one/things/plans/npx-agent.md +0 -1089
  1060. package/one/things/plans/onboarding.md +0 -51
  1061. package/one/things/plans/one-protocol-and-payone-usage.md +0 -82
  1062. package/one/things/plans/one.md +0 -677
  1063. package/one/things/plans/ontology-6-dimensions.md +0 -2201
  1064. package/one/things/plans/ontology-compliance-audit.md +0 -342
  1065. package/one/things/plans/ontology-driven-strategy.md +0 -882
  1066. package/one/things/plans/ontology-refine.md +0 -586
  1067. package/one/things/plans/ontology-ui-approach.md +0 -375
  1068. package/one/things/plans/open-agent.md +0 -840
  1069. package/one/things/plans/performace.md +0 -122
  1070. package/one/things/plans/phase-1-foundation.md +0 -620
  1071. package/one/things/plans/phase-3-implementation.md +0 -1037
  1072. package/one/things/plans/plan-connect-to-api.md +0 -146
  1073. package/one/things/plans/quick-wins.md +0 -1428
  1074. package/one/things/plans/r2.md +0 -777
  1075. package/one/things/plans/readme-backend-cleanup.md +0 -402
  1076. package/one/things/plans/release.md +0 -507
  1077. package/one/things/plans/remove-backend-development-from-agents.md +0 -1331
  1078. package/one/things/plans/repos.md +0 -98
  1079. package/one/things/plans/separate-copy-2.md +0 -1349
  1080. package/one/things/plans/separate-copy-3.md +0 -2479
  1081. package/one/things/plans/separate-copy.md +0 -1349
  1082. package/one/things/plans/separate-demo.md +0 -864
  1083. package/one/things/plans/separate.md +0 -1999
  1084. package/one/things/plans/sequence.md +0 -2040
  1085. package/one/things/plans/shadcn-integration-summary.md +0 -510
  1086. package/one/things/plans/sidebar.md +0 -206
  1087. package/one/things/plans/skills.md +0 -709
  1088. package/one/things/plans/small-fixes.md +0 -23
  1089. package/one/things/plans/start-new.md +0 -764
  1090. package/one/things/plans/switch-off-auth.md +0 -42
  1091. package/one/things/plans/sync-checklist.md +0 -351
  1092. package/one/things/plans/test-backend-connection.md +0 -514
  1093. package/one/things/plans/unified-implementation-plan.md +0 -934
  1094. package/one/things/plans/update-demos.md +0 -581
  1095. package/one/things/plans/use-our-backend.md +0 -572
  1096. package/one/things/plans/video-backend.md +0 -638
  1097. package/one/things/plans/video-frontend.md +0 -490
  1098. package/one/things/plans/video-old-archived.md +0 -656
  1099. package/one/things/plans/wave1-onboarding-100-inferences.md +0 -1686
  1100. package/one/things/plans/wave1-onboarding-vision.md +0 -744
  1101. package/one/things/plans/wave1-orchestration-summary.md +0 -604
  1102. package/one/things/plans/wave1-specialist-assignments.md +0 -1413
  1103. package/one/things/plans/workflow-files.md +0 -1210
  1104. package/one/things/plans/workflow.md +0 -1378
  1105. package/one/things/plans-u.md +0 -905
  1106. package/one/things/products/Blockchain Products.md +0 -6278
  1107. package/one/things/products/cascade-landing-page.md +0 -841
  1108. package/one/things/products/cascade.md +0 -1568
  1109. package/one/things/products/context-engineering.md +0 -1488
  1110. package/one/things/products/onthology.md +0 -15
  1111. package/one/things/products/ontology-ui-shadcn.md +0 -1302
  1112. package/one/things/products/ontology-ui.md +0 -1429
  1113. package/one/things/products/ontology.md +0 -789
  1114. package/one/things/products/sdk.md +0 -573
  1115. package/one/things/promptkit.md +0 -930
  1116. package/one/things/repos/all-repos.md +0 -0
  1117. package/one/things/scripts-clean-mac.sh +0 -409
  1118. package/one/things/service-providers-new.md +0 -1052
  1119. package/one/things/service-providers.md +0 -1121
  1120. package/one/things/structure.md +0 -532
  1121. package/one/things/system.md +0 -618
  1122. package/one/things/templates.md +0 -294
  1123. package/one/things/tests/2-1-dataprovider-interface.md +0 -1216
  1124. package/one/things/tests/2-1-test-analysis.md +0 -544
  1125. package/one/things/things.md +0 -384
  1126. package/one/things/todo-acp-integration.md +0 -744
  1127. package/one/things/todo-ai.md +0 -933
  1128. package/one/things/todo-api.md +0 -1078
  1129. package/one/things/todo-assignment.md +0 -580
  1130. package/one/things/todo-buy-chatgpt.md +0 -1450
  1131. package/one/things/todo-components.md +0 -1683
  1132. package/one/things/todo-connections.md +0 -278
  1133. package/one/things/todo-ecommerce-frontend.md +0 -1313
  1134. package/one/things/todo-ecommerce.md +0 -569
  1135. package/one/things/todo-effects.md +0 -1075
  1136. package/one/things/todo-frontend-effects.md +0 -977
  1137. package/one/things/todo-landing-page.md +0 -1091
  1138. package/one/things/todo-mail.md +0 -1160
  1139. package/one/things/todo-master-plan.md +0 -490
  1140. package/one/things/todo-onboard.md +0 -666
  1141. package/one/things/todo-one-ie.md +0 -538
  1142. package/one/things/todo-page.md +0 -606
  1143. package/one/things/todo-plans.md +0 -282
  1144. package/one/things/todo-projects.md +0 -241
  1145. package/one/things/todo-refactoring-plan.md +0 -366
  1146. package/one/things/todo-release.md +0 -654
  1147. package/one/things/todo-sequence.md +0 -1621
  1148. package/one/things/todo-use-our-backend.md +0 -1908
  1149. package/one/things/todo-workflow.md +0 -626
  1150. package/one/things/todo-x402.md +0 -2047
  1151. package/one/things/todo.md +0 -21
  1152. package/one/things/video/scripts-crypto.md +0 -835
  1153. package/one/things/video-script-backup.md +0 -318
  1154. package/one/things/video-script-demo.md +0 -382
  1155. package/one/things/video-script-ontology.md +0 -333
  1156. package/one/things/video-script.md +0 -361
@@ -1,3242 +0,0 @@
1
- ---
2
- title: 2 2 Config System
3
- dimension: things
4
- category: features
5
- tags: backend, frontend
6
- related_dimensions: connections, events, groups, knowledge, people
7
- scope: global
8
- created: 2025-11-03
9
- updated: 2025-11-03
10
- version: 1.0.0
11
- ai_context: |
12
- This document is part of the things dimension in the features category.
13
- Location: one/things/features/2-2-config-system.md
14
- Purpose: Documents feature 2-2: configuration system
15
- Related dimensions: connections, events, groups, knowledge, people
16
- For AI agents: Read this to understand 2 2 config system.
17
- ---
18
-
19
- # Feature 2-2: Configuration System
20
-
21
- **Feature ID:** `feature_2_2_config_system`
22
- **Plan:** `plan_2_backend_agnostic_frontend`
23
- **Owner:** Backend Specialist
24
- **Status:** Complete Specification
25
- **Priority:** P0 (Critical - Required for Provider Switching)
26
- **Effort:** 3 days
27
- **Dependencies:** Feature 2-1 (DataProvider Interface)
28
-
29
- ---
30
-
31
- ## Executive Summary
32
-
33
- The Configuration System enables ONE Platform to support multiple backend providers (Convex, WordPress, Notion, Supabase) with runtime provider switching, multi-tenant isolation, encrypted credential storage, and <30-second switchover times. Organizations configure their backend provider via environment variables or runtime API, with all credentials encrypted at rest and provider factories instantiating the correct implementation on demand.
34
-
35
- **Key Features:**
36
-
37
- - Environment-based configuration with Zod validation
38
- - Runtime provider switching per organization
39
- - Encrypted API key storage using AES-256-GCM
40
- - Provider factory pattern with lazy initialization
41
- - Multi-tenant isolation (each org has independent provider)
42
- - Provider registration system for extensibility
43
- - Event logging for all configuration changes
44
- - Fast switchover (<30 seconds)
45
-
46
- ---
47
-
48
- ## 1. Ontology Mapping (6 Dimensions)
49
-
50
- ### 1.1 Organizations
51
-
52
- **Purpose:** Each organization has independent backend provider configuration.
53
-
54
- **Schema Addition:**
55
-
56
- ```typescript
57
- // entities table (type: "organization")
58
- properties: {
59
- // ... existing org properties
60
- backendProvider?: {
61
- type: "convex" | "wordpress" | "notion" | "supabase",
62
- configId?: Id<"entities">, // Reference to external_connection
63
- switchedAt?: number, // Last provider switch timestamp
64
- previousProvider?: string, // For rollback
65
- }
66
- }
67
- ```
68
-
69
- **Usage:**
70
-
71
- - `org.properties.backendProvider.type` determines which provider to use
72
- - `org.properties.backendProvider.configId` links to encrypted credentials
73
- - Platform owner can switch providers for testing
74
- - Org owners can switch their own provider (with proper permissions)
75
-
76
- ### 1.2 People
77
-
78
- **Purpose:** Only org_owner and platform_owner can change backend providers.
79
-
80
- **Roles with Config Access:**
81
-
82
- - `platform_owner`: Can configure ANY organization's provider (for support/migration)
83
- - `org_owner`: Can configure THEIR organization's provider
84
- - `org_user`: Read-only access to provider type (not credentials)
85
- - `customer`: No access to provider configuration
86
-
87
- **Permission Check Pattern:**
88
-
89
- ```typescript
90
- // Before allowing provider switch
91
- const person = await getPerson(userId);
92
- const org = await getOrganization(orgId);
93
-
94
- // Check authorization
95
- if (person.role !== "platform_owner") {
96
- // Must be org_owner of THIS org
97
- const membership = await getMembership(userId, orgId);
98
- if (!membership || membership.metadata.role !== "org_owner") {
99
- throw new Error("Forbidden: Only org owners can change providers");
100
- }
101
- }
102
- ```
103
-
104
- ### 1.3 Things (Entities)
105
-
106
- **New Entity Type: `external_connection`**
107
-
108
- ```typescript
109
- type: "external_connection"
110
- name: "Convex Production Backend" | "WordPress Staging" | etc.
111
- properties: {
112
- platform: "convex" | "wordpress" | "notion" | "supabase" | "custom",
113
- connectionType: "backend_provider", // Distinguishes from other external connections
114
-
115
- // Connection details (NOT encrypted here - see encryption section)
116
- baseUrl?: string, // API base URL
117
- apiKey?: string, // Encrypted API key (AES-256-GCM)
118
- apiKeyIv?: string, // Initialization vector for encryption
119
- apiKeyAuthTag?: string, // Auth tag for GCM mode
120
-
121
- // Additional provider-specific config
122
- config: {
123
- // Convex
124
- deploymentUrl?: string,
125
- deploymentName?: string,
126
-
127
- // WordPress
128
- wpJsonEndpoint?: string,
129
- username?: string,
130
- applicationPassword?: string, // Encrypted
131
-
132
- // Notion
133
- notionToken?: string, // Encrypted
134
- databaseId?: string,
135
-
136
- // Supabase
137
- supabaseUrl?: string,
138
- supabaseAnonKey?: string, // Encrypted
139
- supabaseServiceKey?: string, // Encrypted (admin operations)
140
- },
141
-
142
- // Metadata
143
- status: "active" | "inactive" | "error",
144
- lastConnectedAt?: number,
145
- lastError?: string,
146
- healthCheckUrl?: string,
147
- rateLimits?: {
148
- requestsPerMinute: number,
149
- requestsPerDay: number,
150
- },
151
- }
152
- status: "active" | "inactive"
153
- createdAt: number
154
- updatedAt: number
155
- ```
156
-
157
- **Why This Design:**
158
-
159
- - Reuses existing `external_connection` entity type (no new type needed)
160
- - Encrypted credentials stored in properties (never in plaintext)
161
- - Supports multiple configs per organization (dev, staging, prod)
162
- - Can health-check provider availability
163
- - Rate limits prevent quota exhaustion
164
-
165
- ### 1.4 Connections
166
-
167
- **Organization → Backend Config:**
168
-
169
- ```typescript
170
- {
171
- fromEntityId: organizationId,
172
- toEntityId: externalConnectionId,
173
- relationshipType: "configured_by",
174
- metadata: {
175
- configType: "backend_provider",
176
- activeProvider: true, // Only one can be active per org
177
- switchedAt: Date.now(),
178
- switchedBy: personId,
179
- },
180
- validFrom: Date.now(),
181
- validTo?: undefined, // Current active config has no end date
182
- createdAt: Date.now(),
183
- }
184
- ```
185
-
186
- **Person → Backend Config (Who Created):**
187
-
188
- ```typescript
189
- {
190
- fromEntityId: personId,
191
- toEntityId: externalConnectionId,
192
- relationshipType: "created_by",
193
- metadata: {
194
- role: "platform_owner" | "org_owner",
195
- },
196
- createdAt: Date.now(),
197
- }
198
- ```
199
-
200
- ### 1.5 Events
201
-
202
- **Configuration Events:**
203
-
204
- ```typescript
205
- // settings_updated (existing consolidated event)
206
- {
207
- type: "settings_updated",
208
- actorId: personId,
209
- targetId: organizationId,
210
- timestamp: Date.now(),
211
- metadata: {
212
- settingType: "backend_provider",
213
- fromProvider: "convex",
214
- toProvider: "wordpress",
215
- configId: externalConnectionId,
216
- switchDuration: 28500, // milliseconds (<30 seconds target)
217
- }
218
- }
219
-
220
- // communication_event (for provider health checks)
221
- {
222
- type: "communication_event",
223
- actorId: systemAgentId,
224
- targetId: externalConnectionId,
225
- timestamp: Date.now(),
226
- metadata: {
227
- protocol: "http",
228
- messageType: "health_check",
229
- endpoint: "https://shocking-falcon-870.convex.cloud/_system/health",
230
- status: 200,
231
- responseTime: 142, // ms
232
- }
233
- }
234
-
235
- // entity_created (when new config added)
236
- {
237
- type: "entity_created",
238
- actorId: personId,
239
- targetId: externalConnectionId,
240
- timestamp: Date.now(),
241
- metadata: {
242
- entityType: "external_connection",
243
- platform: "wordpress",
244
- organizationId: orgId,
245
- }
246
- }
247
-
248
- // entity_archived (when config deactivated)
249
- {
250
- type: "entity_archived",
251
- actorId: personId,
252
- targetId: externalConnectionId,
253
- timestamp: Date.now(),
254
- metadata: {
255
- reason: "provider_switch",
256
- newConfigId: newExternalConnectionId,
257
- }
258
- }
259
- ```
260
-
261
- ### 1.6 Knowledge
262
-
263
- **Configuration Labels:**
264
-
265
- ```typescript
266
- // Label knowledge items for provider configs
267
- {
268
- knowledgeType: "label",
269
- text: "backend:convex",
270
- labels: ["capability:realtime", "capability:auth", "capability:storage"],
271
- createdAt: Date.now(),
272
- }
273
-
274
- {
275
- knowledgeType: "label",
276
- text: "backend:wordpress",
277
- labels: ["capability:cms", "capability:rest_api", "capability:plugins"],
278
- createdAt: Date.now(),
279
- }
280
-
281
- // Link labels to external_connection entities via thingKnowledge
282
- {
283
- thingId: externalConnectionId,
284
- knowledgeId: labelId,
285
- role: "label",
286
- createdAt: Date.now(),
287
- }
288
- ```
289
-
290
- **Why Labels:**
291
-
292
- - Enables capability-based provider discovery
293
- - Supports queries like "find backends with realtime capability"
294
- - Allows filtering in UI (show only providers with auth support)
295
- - Future-proof for new provider types
296
-
297
- ---
298
-
299
- ## 2. User Stories with Acceptance Criteria
300
-
301
- ### Story 2.1: Platform Owner Configures Default Provider
302
-
303
- **As a** platform owner (Anthony)
304
- **I want to** set the default backend provider via environment variables
305
- **So that** new organizations automatically use the configured backend
306
-
307
- **Acceptance Criteria:**
308
-
309
- - [ ] `.env.local` contains `BACKEND_PROVIDER=convex` variable
310
- - [ ] `.env.local` contains provider-specific credentials (e.g., `CONVEX_DEPLOYMENT_URL`)
311
- - [ ] Zod schema validates all required environment variables on startup
312
- - [ ] Missing or invalid config throws error with helpful message
313
- - [ ] Default provider is used when org has no custom config
314
- - [ ] Provider switch creates `settings_updated` event with platform_owner actorId
315
-
316
- **Example Config:**
317
-
318
- ```bash
319
- # .env.local
320
- BACKEND_PROVIDER=convex
321
- CONVEX_DEPLOYMENT_URL=https://shocking-falcon-870.convex.cloud
322
- CONVEX_DEPLOYMENT_NAME=prod:shocking-falcon-870
323
-
324
- # Alternative for WordPress
325
- # BACKEND_PROVIDER=wordpress
326
- # WORDPRESS_URL=https://example.com/wp-json
327
- # WORDPRESS_USERNAME=admin
328
- # WORDPRESS_APP_PASSWORD=xxxx-xxxx-xxxx-xxxx
329
- ```
330
-
331
- ### Story 2.2: Org Owner Switches Backend Provider
332
-
333
- **As an** org owner
334
- **I want to** switch my organization's backend from Convex to WordPress
335
- **So that** I can use my existing WordPress infrastructure
336
-
337
- **Acceptance Criteria:**
338
-
339
- - [ ] Org owner can access "Backend Settings" page
340
- - [ ] Page lists available provider types (Convex, WordPress, Notion, Supabase)
341
- - [ ] Org owner enters WordPress credentials in form
342
- - [ ] System validates credentials by testing connection
343
- - [ ] On success, system creates `external_connection` entity with encrypted credentials
344
- - [ ] System updates organization's `backendProvider` property
345
- - [ ] System creates `settings_updated` event
346
- - [ ] Switch completes in <30 seconds
347
- - [ ] Next API call uses new provider automatically
348
-
349
- **Security Requirements:**
350
-
351
- - [ ] API keys encrypted at rest using AES-256-GCM
352
- - [ ] Credentials never logged or exposed in events
353
- - [ ] Only org_owner and platform_owner can see credentials
354
- - [ ] Failed credential validation does not save config
355
-
356
- ### Story 2.3: Multi-Tenant Isolation
357
-
358
- **As the** platform
359
- **I want to** ensure each organization uses its own provider independently
360
- **So that** Org A using WordPress doesn't affect Org B using Convex
361
-
362
- **Acceptance Criteria:**
363
-
364
- - [ ] Each organization has independent `backendProvider` config
365
- - [ ] Provider registry maintains per-org provider instances
366
- - [ ] Queries automatically route to correct provider based on org context
367
- - [ ] Provider failure in Org A does not affect Org B
368
- - [ ] Event logs clearly show which org triggered which provider operation
369
- - [ ] Health checks run per organization, not globally
370
-
371
- **Example:**
372
-
373
- ```typescript
374
- // Org A uses Convex
375
- const orgAProvider = await getProviderForOrg("org_a");
376
- await orgAProvider.query("entities", { type: "creator" }); // Convex
377
-
378
- // Org B uses WordPress
379
- const orgBProvider = await getProviderForOrg("org_b");
380
- await orgBProvider.query("entities", { type: "creator" }); // WordPress REST API
381
- ```
382
-
383
- ### Story 2.4: Provider Health Monitoring
384
-
385
- **As a** platform owner
386
- **I want to** monitor health of all configured providers
387
- **So that** I can detect and fix provider issues before users are affected
388
-
389
- **Acceptance Criteria:**
390
-
391
- - [ ] Health check runs every 5 minutes per active provider
392
- - [ ] Health check creates `communication_event` with status
393
- - [ ] Dashboard shows provider health status (online, degraded, offline)
394
- - [ ] Failed health checks trigger alerts
395
- - [ ] Health metrics include response time and error rate
396
- - [ ] Admins can manually trigger health check
397
-
398
- **Health Check Endpoint Examples:**
399
-
400
- - Convex: `/_system/health`
401
- - WordPress: `/wp-json/`
402
- - Notion: `/v1/users/me`
403
- - Supabase: `/rest/v1/`
404
-
405
- ### Story 2.5: Provider Factory Registration
406
-
407
- **As a** developer
408
- **I want to** register a new backend provider (e.g., Supabase)
409
- **So that** users can choose from more backend options
410
-
411
- **Acceptance Criteria:**
412
-
413
- - [ ] Provider implements `DataProvider` interface
414
- - [ ] Provider registered via `registerProvider()` function
415
- - [ ] Factory creates provider instance with validated config
416
- - [ ] New provider appears in UI dropdown automatically
417
- - [ ] Provider-specific Zod schema validates config
418
- - [ ] Provider factory lazy-initializes (only creates instance when needed)
419
-
420
- **Registration Pattern:**
421
-
422
- ```typescript
423
- // backend/convex/providers/supabase.ts
424
- export const SupabaseProviderFactory: ProviderFactory = {
425
- type: "supabase",
426
- create: (config: ProviderConfig) => new SupabaseProvider(config),
427
- validate: SupabaseConfigSchema,
428
- capabilities: ["auth", "storage", "realtime", "edge_functions"],
429
- };
430
-
431
- // Register in registry
432
- registerProvider(SupabaseProviderFactory);
433
- ```
434
-
435
- ### Story 2.6: Configuration Rollback
436
-
437
- **As an** org owner
438
- **I want to** rollback to previous provider if new one fails
439
- **So that** my organization isn't stuck with a broken backend
440
-
441
- **Acceptance Criteria:**
442
-
443
- - [ ] Organization properties store `previousProvider` reference
444
- - [ ] UI shows "Rollback to Convex" button when provider changed recently
445
- - [ ] Rollback creates new connection with `validFrom` = now
446
- - [ ] Old provider marked `inactive` but not deleted
447
- - [ ] Rollback completes in <10 seconds
448
- - [ ] Rollback creates `settings_updated` event with rollback metadata
449
-
450
- **Example Rollback:**
451
-
452
- ```typescript
453
- await rollbackProvider({
454
- orgId: "org_123",
455
- targetConfigId: previousConfigId, // Points to old external_connection
456
- });
457
-
458
- // Event logged:
459
- {
460
- type: "settings_updated",
461
- actorId: orgOwnerId,
462
- targetId: orgId,
463
- metadata: {
464
- settingType: "backend_provider_rollback",
465
- fromProvider: "wordpress",
466
- toProvider: "convex",
467
- reason: "connection_failure",
468
- }
469
- }
470
- ```
471
-
472
- ### Story 2.7: Encrypted Credential Management
473
-
474
- **As a** security engineer
475
- **I want to** ensure API keys are never stored in plaintext
476
- **So that** compromised database doesn't expose credentials
477
-
478
- **Acceptance Criteria:**
479
-
480
- - [ ] Encryption key stored in environment variable `ENCRYPTION_KEY`
481
- - [ ] AES-256-GCM used for encryption (authenticated encryption)
482
- - [ ] Each credential has unique IV (initialization vector)
483
- - [ ] Auth tag validates integrity on decryption
484
- - [ ] Failed decryption throws error and logs security event
485
- - [ ] Credentials never appear in logs, events, or error messages
486
- - [ ] Encryption key rotation supported (future feature)
487
-
488
- **Encryption Flow:**
489
-
490
- ```typescript
491
- // On save
492
- const encrypted = await encrypt(apiKey, process.env.ENCRYPTION_KEY);
493
- await db.patch(externalConnectionId, {
494
- properties: {
495
- ...properties,
496
- apiKey: encrypted.ciphertext,
497
- apiKeyIv: encrypted.iv,
498
- apiKeyAuthTag: encrypted.authTag,
499
- },
500
- });
501
-
502
- // On load
503
- const decrypted = await decrypt({
504
- ciphertext: properties.apiKey,
505
- iv: properties.apiKeyIv,
506
- authTag: properties.apiKeyAuthTag,
507
- key: process.env.ENCRYPTION_KEY,
508
- });
509
- ```
510
-
511
- ### Story 2.8: Configuration Validation
512
-
513
- **As a** developer
514
- **I want to** validate provider configs with Zod schemas
515
- **So that** invalid configs are caught early with helpful errors
516
-
517
- **Acceptance Criteria:**
518
-
519
- - [ ] Each provider type has dedicated Zod schema
520
- - [ ] Schema validates required fields (e.g., `CONVEX_DEPLOYMENT_URL`)
521
- - [ ] Schema validates field formats (URLs, API key patterns)
522
- - [ ] Validation errors show field name and expected format
523
- - [ ] Runtime config override validates before applying
524
- - [ ] Invalid config prevents provider initialization
525
-
526
- **Schema Examples:**
527
-
528
- ```typescript
529
- // Convex config schema
530
- export const ConvexConfigSchema = z.object({
531
- type: z.literal("convex"),
532
- deploymentUrl: z.string().url(),
533
- deploymentName: z.string().regex(/^(dev|prod):.+$/),
534
- });
535
-
536
- // WordPress config schema
537
- export const WordPressConfigSchema = z.object({
538
- type: z.literal("wordpress"),
539
- baseUrl: z.string().url(),
540
- username: z.string().min(1),
541
- applicationPassword: z.string().regex(/^[a-zA-Z0-9 ]{24}$/),
542
- });
543
- ```
544
-
545
- ### Story 2.9: Provider Switching Performance
546
-
547
- **As an** org owner
548
- **I want** provider switches to complete quickly
549
- **So that** my team isn't waiting for backend changes
550
-
551
- **Acceptance Criteria:**
552
-
553
- - [ ] Provider switch completes in <30 seconds (99th percentile)
554
- - [ ] Switch includes: validate → encrypt → save → initialize → health check
555
- - [ ] Progress indicator shows switch steps in UI
556
- - [ ] Failed switch rolls back automatically
557
- - [ ] Switch duration logged in `settings_updated` event
558
- - [ ] Performance metrics tracked (P50, P95, P99)
559
-
560
- **Target Timings:**
561
-
562
- - Validate credentials: <2s
563
- - Encrypt and save: <1s
564
- - Initialize provider: <5s
565
- - Health check: <3s
566
- - Total: <15s (average), <30s (P99)
567
-
568
- ### Story 2.10: Configuration UI
569
-
570
- **As an** org owner
571
- **I want** a simple UI to manage backend configuration
572
- **So that** I don't need technical knowledge to switch providers
573
-
574
- **Acceptance Criteria:**
575
-
576
- - [ ] Settings page at `/org/[orgId]/settings/backend`
577
- - [ ] Current provider shown with status badge (online/offline)
578
- - [ ] Dropdown to select new provider type
579
- - [ ] Dynamic form based on selected provider (WordPress shows username field, Convex doesn't)
580
- - [ ] "Test Connection" button validates credentials before saving
581
- - [ ] Success notification shows "Provider switched to WordPress"
582
- - [ ] Error messages are user-friendly (not raw error logs)
583
- - [ ] Credentials masked in UI (show **\*\*\*** for API keys)
584
-
585
- **UI Flow:**
586
-
587
- 1. Org owner visits `/org/acme/settings/backend`
588
- 2. Sees "Current Provider: Convex (Online)"
589
- 3. Clicks "Change Provider"
590
- 4. Selects "WordPress" from dropdown
591
- 5. Form shows: Base URL, Username, Application Password fields
592
- 6. Fills in credentials
593
- 7. Clicks "Test Connection" → success notification
594
- 8. Clicks "Save and Switch" → progress indicator
595
- 9. After 15 seconds → "Successfully switched to WordPress"
596
- 10. Page shows "Current Provider: WordPress (Online)"
597
-
598
- ---
599
-
600
- ## 3. Implementation Steps (50 Steps)
601
-
602
- ### Phase 1: Schema and Types (Steps 1-10)
603
-
604
- **Step 1:** Define `ProviderConfig` type
605
-
606
- ```typescript
607
- // backend/convex/providers/types.ts
608
- export type ProviderType = "convex" | "wordpress" | "notion" | "supabase";
609
-
610
- export interface ProviderConfig {
611
- type: ProviderType;
612
- url: string;
613
- credentials: Record<string, string>;
614
- options?: Record<string, any>;
615
- }
616
-
617
- export interface EncryptedCredentials {
618
- ciphertext: string;
619
- iv: string;
620
- authTag: string;
621
- }
622
- ```
623
-
624
- **Step 2:** Add Zod schemas for each provider
625
-
626
- ```typescript
627
- // backend/convex/providers/schemas.ts
628
- import { z } from "zod";
629
-
630
- export const ConvexConfigSchema = z.object({
631
- type: z.literal("convex"),
632
- deploymentUrl: z.string().url(),
633
- deploymentName: z.string(),
634
- });
635
-
636
- export const WordPressConfigSchema = z.object({
637
- type: z.literal("wordpress"),
638
- baseUrl: z.string().url().endsWith("/wp-json"),
639
- username: z.string().min(1),
640
- applicationPassword: z.string().length(27), // WordPress app password format
641
- });
642
-
643
- export const NotionConfigSchema = z.object({
644
- type: z.literal("notion"),
645
- token: z.string().startsWith("secret_"),
646
- databaseId: z.string(),
647
- });
648
-
649
- export const SupabaseConfigSchema = z.object({
650
- type: z.literal("supabase"),
651
- url: z.string().url(),
652
- anonKey: z.string(),
653
- serviceKey: z.string().optional(),
654
- });
655
-
656
- export const ProviderConfigSchema = z.discriminatedUnion("type", [
657
- ConvexConfigSchema,
658
- WordPressConfigSchema,
659
- NotionConfigSchema,
660
- SupabaseConfigSchema,
661
- ]);
662
- ```
663
-
664
- **Step 3:** Update organization schema
665
-
666
- ```typescript
667
- // backend/convex/schema.ts
668
- entities: defineTable({
669
- type: v.string(),
670
- name: v.string(),
671
- properties: v.any(), // Includes backendProvider: { type, configId, switchedAt }
672
- status: v.optional(v.union(/* ... */)),
673
- createdAt: v.number(),
674
- updatedAt: v.number(),
675
- });
676
- ```
677
-
678
- **Step 4:** Add indexes for external_connection queries
679
-
680
- ```typescript
681
- // backend/convex/schema.ts
682
- entities: defineTable({
683
- /* ... */
684
- })
685
- .index("by_type", ["type"])
686
- .index("by_type_status", ["type", "status"]); // NEW: Fast external_connection queries
687
- ```
688
-
689
- **Step 5:** Define `ProviderFactory` interface
690
-
691
- ```typescript
692
- // backend/convex/providers/factory.ts
693
- import { z } from "zod";
694
- import type { DataProvider } from "./interface";
695
-
696
- export interface ProviderFactory {
697
- type: ProviderType;
698
- create: (config: ProviderConfig) => Promise<DataProvider>;
699
- validate: z.ZodSchema;
700
- capabilities: string[];
701
- healthCheckUrl?: (config: ProviderConfig) => string;
702
- }
703
- ```
704
-
705
- **Step 6:** Create encryption utility
706
-
707
- ```typescript
708
- // backend/convex/lib/encryption.ts
709
- import { createCipheriv, createDecipheriv, randomBytes } from "crypto";
710
-
711
- const ALGORITHM = "aes-256-gcm";
712
- const KEY_LENGTH = 32; // 256 bits
713
- const IV_LENGTH = 16; // 128 bits
714
- const AUTH_TAG_LENGTH = 16;
715
-
716
- export async function encrypt(
717
- plaintext: string,
718
- key: string,
719
- ): Promise<EncryptedCredentials> {
720
- const keyBuffer = Buffer.from(key, "hex");
721
- if (keyBuffer.length !== KEY_LENGTH) {
722
- throw new Error("Encryption key must be 32 bytes (64 hex chars)");
723
- }
724
-
725
- const iv = randomBytes(IV_LENGTH);
726
- const cipher = createCipheriv(ALGORITHM, keyBuffer, iv);
727
-
728
- let ciphertext = cipher.update(plaintext, "utf8", "hex");
729
- ciphertext += cipher.final("hex");
730
- const authTag = cipher.getAuthTag();
731
-
732
- return {
733
- ciphertext,
734
- iv: iv.toString("hex"),
735
- authTag: authTag.toString("hex"),
736
- };
737
- }
738
-
739
- export async function decrypt(
740
- encrypted: EncryptedCredentials,
741
- key: string,
742
- ): Promise<string> {
743
- const keyBuffer = Buffer.from(key, "hex");
744
- const ivBuffer = Buffer.from(encrypted.iv, "hex");
745
- const authTagBuffer = Buffer.from(encrypted.authTag, "hex");
746
-
747
- const decipher = createDecipheriv(ALGORITHM, keyBuffer, ivBuffer);
748
- decipher.setAuthTag(authTagBuffer);
749
-
750
- let plaintext = decipher.update(encrypted.ciphertext, "hex", "utf8");
751
- plaintext += decipher.final("utf8");
752
-
753
- return plaintext;
754
- }
755
- ```
756
-
757
- **Step 7:** Create environment variable loader
758
-
759
- ```typescript
760
- // backend/convex/config/loader.ts
761
- import { ProviderConfigSchema } from "../providers/schemas";
762
-
763
- export function loadProviderConfig(): ProviderConfig {
764
- const type = process.env.BACKEND_PROVIDER as ProviderType;
765
-
766
- if (!type) {
767
- throw new Error("BACKEND_PROVIDER environment variable required");
768
- }
769
-
770
- const rawConfig = {
771
- type,
772
- ...(type === "convex" && {
773
- deploymentUrl: process.env.CONVEX_DEPLOYMENT_URL,
774
- deploymentName: process.env.CONVEX_DEPLOYMENT_NAME,
775
- }),
776
- ...(type === "wordpress" && {
777
- baseUrl: process.env.WORDPRESS_URL,
778
- username: process.env.WORDPRESS_USERNAME,
779
- applicationPassword: process.env.WORDPRESS_APP_PASSWORD,
780
- }),
781
- ...(type === "notion" && {
782
- token: process.env.NOTION_TOKEN,
783
- databaseId: process.env.NOTION_DATABASE_ID,
784
- }),
785
- ...(type === "supabase" && {
786
- url: process.env.SUPABASE_URL,
787
- anonKey: process.env.SUPABASE_ANON_KEY,
788
- serviceKey: process.env.SUPABASE_SERVICE_KEY,
789
- }),
790
- };
791
-
792
- // Validate with Zod
793
- return ProviderConfigSchema.parse(rawConfig);
794
- }
795
- ```
796
-
797
- **Step 8:** Add encryption key validation
798
-
799
- ```typescript
800
- // backend/convex/config/loader.ts (continued)
801
- export function validateEncryptionKey(): void {
802
- const key = process.env.ENCRYPTION_KEY;
803
-
804
- if (!key) {
805
- throw new Error("ENCRYPTION_KEY environment variable required");
806
- }
807
-
808
- const keyBuffer = Buffer.from(key, "hex");
809
- if (keyBuffer.length !== 32) {
810
- throw new Error("ENCRYPTION_KEY must be 32 bytes (64 hex characters)");
811
- }
812
- }
813
-
814
- // Generate key helper (for docs)
815
- export function generateEncryptionKey(): string {
816
- return randomBytes(32).toString("hex");
817
- }
818
- ```
819
-
820
- **Step 9:** Create provider configuration service
821
-
822
- ```typescript
823
- // backend/convex/services/config/provider.ts
824
- import { Effect, Context } from "effect";
825
- import type { Id } from "../../_generated/dataModel";
826
-
827
- export class ProviderConfigService extends Context.Tag("ProviderConfigService")<
828
- ProviderConfigService,
829
- {
830
- getForOrganization: (
831
- orgId: Id<"entities">,
832
- ) => Effect.Effect<
833
- ProviderConfig | null,
834
- ConfigNotFoundError | DecryptionError
835
- >;
836
-
837
- saveForOrganization: (
838
- orgId: Id<"entities">,
839
- config: ProviderConfig,
840
- actorId: Id<"entities">,
841
- ) => Effect.Effect<
842
- Id<"entities">, // externalConnectionId
843
- ValidationError | EncryptionError | UnauthorizedError
844
- >;
845
-
846
- testConnection: (
847
- config: ProviderConfig,
848
- ) => Effect.Effect<
849
- { success: true; responseTime: number },
850
- ConnectionTestError
851
- >;
852
- }
853
- >() {}
854
- ```
855
-
856
- **Step 10:** Define error types
857
-
858
- ```typescript
859
- // backend/convex/services/config/errors.ts
860
- export class ConfigNotFoundError {
861
- readonly _tag = "ConfigNotFoundError";
862
- constructor(readonly orgId: string) {}
863
- }
864
-
865
- export class DecryptionError {
866
- readonly _tag = "DecryptionError";
867
- constructor(readonly reason: string) {}
868
- }
869
-
870
- export class ValidationError {
871
- readonly _tag = "ValidationError";
872
- constructor(readonly errors: z.ZodError) {}
873
- }
874
-
875
- export class EncryptionError {
876
- readonly _tag = "EncryptionError";
877
- constructor(readonly reason: string) {}
878
- }
879
-
880
- export class UnauthorizedError {
881
- readonly _tag = "UnauthorizedError";
882
- constructor(
883
- readonly userId: string,
884
- readonly requiredRole: string,
885
- ) {}
886
- }
887
-
888
- export class ConnectionTestError {
889
- readonly _tag = "ConnectionTestError";
890
- constructor(
891
- readonly provider: string,
892
- readonly reason: string,
893
- readonly httpStatus?: number,
894
- ) {}
895
- }
896
- ```
897
-
898
- ### Phase 2: Provider Factory (Steps 11-20)
899
-
900
- **Step 11:** Create provider registry
901
-
902
- ```typescript
903
- // backend/convex/providers/registry.ts
904
- const registeredProviders = new Map<ProviderType, ProviderFactory>();
905
-
906
- export function registerProvider(factory: ProviderFactory): void {
907
- registeredProviders.set(factory.type, factory);
908
- }
909
-
910
- export function getProviderFactory(
911
- type: ProviderType,
912
- ): ProviderFactory | undefined {
913
- return registeredProviders.get(type);
914
- }
915
-
916
- export function listProviderTypes(): ProviderType[] {
917
- return Array.from(registeredProviders.keys());
918
- }
919
-
920
- export function getProviderCapabilities(type: ProviderType): string[] {
921
- return registeredProviders.get(type)?.capabilities ?? [];
922
- }
923
- ```
924
-
925
- **Step 12:** Implement Convex provider factory
926
-
927
- ```typescript
928
- // backend/convex/providers/convex/factory.ts
929
- import { ConvexProvider } from "./provider";
930
- import { ConvexConfigSchema } from "../schemas";
931
-
932
- export const ConvexProviderFactory: ProviderFactory = {
933
- type: "convex",
934
-
935
- create: async (config: ProviderConfig) => {
936
- const validated = ConvexConfigSchema.parse(config);
937
- return new ConvexProvider({
938
- deploymentUrl: validated.deploymentUrl,
939
- deploymentName: validated.deploymentName,
940
- });
941
- },
942
-
943
- validate: ConvexConfigSchema,
944
-
945
- capabilities: ["auth", "realtime", "storage", "functions", "search"],
946
-
947
- healthCheckUrl: (config) => `${config.url}/_system/health`,
948
- };
949
-
950
- // Auto-register
951
- registerProvider(ConvexProviderFactory);
952
- ```
953
-
954
- **Step 13:** Implement WordPress provider factory
955
-
956
- ```typescript
957
- // backend/convex/providers/wordpress/factory.ts
958
- import { WordPressProvider } from "./provider";
959
- import { WordPressConfigSchema } from "../schemas";
960
-
961
- export const WordPressProviderFactory: ProviderFactory = {
962
- type: "wordpress",
963
-
964
- create: async (config: ProviderConfig) => {
965
- const validated = WordPressConfigSchema.parse(config);
966
- return new WordPressProvider({
967
- baseUrl: validated.baseUrl,
968
- username: validated.username,
969
- applicationPassword: validated.applicationPassword,
970
- });
971
- },
972
-
973
- validate: WordPressConfigSchema,
974
-
975
- capabilities: ["cms", "rest_api", "plugins", "media_library"],
976
-
977
- healthCheckUrl: (config) => config.baseUrl,
978
- };
979
-
980
- registerProvider(WordPressProviderFactory);
981
- ```
982
-
983
- **Step 14:** Create provider instance cache
984
-
985
- ```typescript
986
- // backend/convex/providers/cache.ts
987
- const providerCache = new Map<string, DataProvider>();
988
-
989
- export function getCachedProvider(orgId: string): DataProvider | undefined {
990
- return providerCache.get(orgId);
991
- }
992
-
993
- export function setCachedProvider(orgId: string, provider: DataProvider): void {
994
- providerCache.set(orgId, provider);
995
- }
996
-
997
- export function clearCachedProvider(orgId: string): void {
998
- providerCache.delete(orgId);
999
- }
1000
-
1001
- export function clearAllProviders(): void {
1002
- providerCache.clear();
1003
- }
1004
- ```
1005
-
1006
- **Step 15:** Implement lazy provider initialization
1007
-
1008
- ```typescript
1009
- // backend/convex/providers/initializer.ts
1010
- import { Effect } from "effect";
1011
- import { getCachedProvider, setCachedProvider } from "./cache";
1012
- import { getProviderFactory } from "./registry";
1013
-
1014
- export const initializeProvider = (
1015
- orgId: Id<"entities">,
1016
- config: ProviderConfig,
1017
- ): Effect.Effect<DataProvider, ProviderInitError> =>
1018
- Effect.gen(function* () {
1019
- // Check cache first
1020
- const cached = getCachedProvider(orgId);
1021
- if (cached) return cached;
1022
-
1023
- // Get factory
1024
- const factory = getProviderFactory(config.type);
1025
- if (!factory) {
1026
- return yield* Effect.fail(
1027
- new ProviderInitError(`Unknown provider type: ${config.type}`),
1028
- );
1029
- }
1030
-
1031
- // Create provider instance
1032
- const provider = yield* Effect.tryPromise({
1033
- try: () => factory.create(config),
1034
- catch: (error) =>
1035
- new ProviderInitError(`Failed to initialize ${config.type}: ${error}`),
1036
- });
1037
-
1038
- // Cache for future use
1039
- setCachedProvider(orgId, provider);
1040
-
1041
- return provider;
1042
- });
1043
- ```
1044
-
1045
- **Step 16:** Create provider switcher service
1046
-
1047
- ```typescript
1048
- // backend/convex/services/config/switcher.ts
1049
- export const switchProvider = (
1050
- orgId: Id<"entities">,
1051
- newConfig: ProviderConfig,
1052
- actorId: Id<"entities">,
1053
- ): Effect.Effect<
1054
- { switchDuration: number; configId: Id<"entities"> },
1055
- ValidationError | EncryptionError | UnauthorizedError | ConnectionTestError
1056
- > =>
1057
- Effect.gen(function* () {
1058
- const startTime = Date.now();
1059
-
1060
- // 1. Validate config
1061
- const factory = getProviderFactory(newConfig.type);
1062
- if (!factory) {
1063
- return yield* Effect.fail(
1064
- new ValidationError(`Unknown provider: ${newConfig.type}`),
1065
- );
1066
- }
1067
-
1068
- const validated = factory.validate.parse(newConfig);
1069
-
1070
- // 2. Test connection
1071
- yield* testConnection(validated);
1072
-
1073
- // 3. Encrypt credentials
1074
- const encrypted = yield* encryptCredentials(validated);
1075
-
1076
- // 4. Save config as external_connection
1077
- const configId = yield* saveConfig(orgId, encrypted, actorId);
1078
-
1079
- // 5. Update organization
1080
- yield* updateOrgProvider(orgId, newConfig.type, configId);
1081
-
1082
- // 6. Clear cached provider
1083
- clearCachedProvider(orgId);
1084
-
1085
- // 7. Log event
1086
- const switchDuration = Date.now() - startTime;
1087
- yield* logProviderSwitch(orgId, actorId, newConfig.type, switchDuration);
1088
-
1089
- return { switchDuration, configId };
1090
- });
1091
- ```
1092
-
1093
- **Step 17:** Implement connection test
1094
-
1095
- ```typescript
1096
- // backend/convex/services/config/tester.ts
1097
- export const testConnection = (
1098
- config: ProviderConfig,
1099
- ): Effect.Effect<
1100
- { success: true; responseTime: number },
1101
- ConnectionTestError
1102
- > =>
1103
- Effect.gen(function* () {
1104
- const factory = getProviderFactory(config.type);
1105
- if (!factory?.healthCheckUrl) {
1106
- // No health check available, assume success
1107
- return { success: true, responseTime: 0 };
1108
- }
1109
-
1110
- const url = factory.healthCheckUrl(config);
1111
- const startTime = Date.now();
1112
-
1113
- const response = yield* Effect.tryPromise({
1114
- try: () => fetch(url, { method: "GET", timeout: 5000 }),
1115
- catch: (error) =>
1116
- new ConnectionTestError(
1117
- config.type,
1118
- `Health check failed: ${error}`,
1119
- undefined,
1120
- ),
1121
- });
1122
-
1123
- if (!response.ok) {
1124
- return yield* Effect.fail(
1125
- new ConnectionTestError(
1126
- config.type,
1127
- `Health check returned ${response.status}`,
1128
- response.status,
1129
- ),
1130
- );
1131
- }
1132
-
1133
- const responseTime = Date.now() - startTime;
1134
- return { success: true, responseTime };
1135
- });
1136
- ```
1137
-
1138
- **Step 18:** Implement credential encryption helper
1139
-
1140
- ```typescript
1141
- // backend/convex/services/config/encryption.ts
1142
- export const encryptCredentials = (
1143
- config: ProviderConfig,
1144
- ): Effect.Effect<EncryptedConfig, EncryptionError> =>
1145
- Effect.gen(function* () {
1146
- const key = process.env.ENCRYPTION_KEY;
1147
- if (!key) {
1148
- return yield* Effect.fail(
1149
- new EncryptionError("ENCRYPTION_KEY not configured"),
1150
- );
1151
- }
1152
-
1153
- const credentials = extractCredentials(config);
1154
- const encrypted: Record<string, EncryptedCredentials> = {};
1155
-
1156
- for (const [field, value] of Object.entries(credentials)) {
1157
- encrypted[field] = yield* Effect.tryPromise({
1158
- try: () => encrypt(value, key),
1159
- catch: (error) =>
1160
- new EncryptionError(`Failed to encrypt ${field}: ${error}`),
1161
- });
1162
- }
1163
-
1164
- return { ...config, encryptedCredentials: encrypted };
1165
- });
1166
-
1167
- function extractCredentials(config: ProviderConfig): Record<string, string> {
1168
- switch (config.type) {
1169
- case "convex":
1170
- return {}; // Convex uses public URLs
1171
- case "wordpress":
1172
- return { applicationPassword: config.applicationPassword };
1173
- case "notion":
1174
- return { token: config.token };
1175
- case "supabase":
1176
- return {
1177
- anonKey: config.anonKey,
1178
- ...(config.serviceKey && { serviceKey: config.serviceKey }),
1179
- };
1180
- default:
1181
- return {};
1182
- }
1183
- }
1184
- ```
1185
-
1186
- **Step 19:** Implement config save mutation
1187
-
1188
- ```typescript
1189
- // backend/convex/mutations/config.ts
1190
- export const saveProviderConfig = mutation({
1191
- args: {
1192
- orgId: v.id("entities"),
1193
- config: v.any(), // Validated by service layer
1194
- },
1195
- handler: async (ctx, args) => {
1196
- // Get actor
1197
- const identity = await ctx.auth.getUserIdentity();
1198
- if (!identity) throw new Error("Not authenticated");
1199
-
1200
- const actor = await ctx.db
1201
- .query("entities")
1202
- .filter((q) => q.eq(q.field("properties.email"), identity.email))
1203
- .first();
1204
-
1205
- if (!actor) throw new Error("User not found");
1206
-
1207
- // Use Effect service
1208
- return await Effect.runPromise(
1209
- switchProvider(args.orgId, args.config, actor._id).pipe(
1210
- Effect.provide(ConfigServiceLayer),
1211
- ),
1212
- );
1213
- },
1214
- });
1215
- ```
1216
-
1217
- **Step 20:** Register all provider factories on startup
1218
-
1219
- ```typescript
1220
- // backend/convex/providers/index.ts
1221
- import "./convex/factory";
1222
- import "./wordpress/factory";
1223
- import "./notion/factory";
1224
- import "./supabase/factory";
1225
-
1226
- export * from "./registry";
1227
- export * from "./factory";
1228
- export * from "./initializer";
1229
- ```
1230
-
1231
- ### Phase 3: Multi-Tenant Provider Access (Steps 21-30)
1232
-
1233
- **Step 21:** Create organization context service
1234
-
1235
- ```typescript
1236
- // backend/convex/services/context/organization.ts
1237
- export class OrganizationContext extends Context.Tag("OrganizationContext")<
1238
- OrganizationContext,
1239
- {
1240
- getCurrentOrg: () => Effect.Effect<Id<"entities">, OrgNotFoundError>;
1241
- getOrgProvider: (
1242
- orgId: Id<"entities">,
1243
- ) => Effect.Effect<DataProvider, ConfigNotFoundError | ProviderInitError>;
1244
- }
1245
- >() {}
1246
- ```
1247
-
1248
- **Step 22:** Implement provider resolver
1249
-
1250
- ```typescript
1251
- // backend/convex/services/context/resolver.ts
1252
- export const resolveProviderForOrg = (
1253
- orgId: Id<"entities">,
1254
- ): Effect.Effect<DataProvider, ConfigNotFoundError | ProviderInitError> =>
1255
- Effect.gen(function* () {
1256
- // Check cache
1257
- const cached = getCachedProvider(orgId);
1258
- if (cached) return cached;
1259
-
1260
- // Load org
1261
- const org = yield* Effect.tryPromise(() => db.get(orgId));
1262
- if (!org) {
1263
- return yield* Effect.fail(new ConfigNotFoundError(orgId));
1264
- }
1265
-
1266
- // Check if org has custom provider
1267
- const customConfig = org.properties.backendProvider;
1268
- if (customConfig?.configId) {
1269
- const config = yield* loadExternalConnection(customConfig.configId);
1270
- const decrypted = yield* decryptConfig(config);
1271
- return yield* initializeProvider(orgId, decrypted);
1272
- }
1273
-
1274
- // Fall back to default provider
1275
- const defaultConfig = loadProviderConfig();
1276
- return yield* initializeProvider(orgId, defaultConfig);
1277
- });
1278
- ```
1279
-
1280
- **Step 23:** Implement config loader from external_connection
1281
-
1282
- ```typescript
1283
- // backend/convex/services/config/loader.ts
1284
- export const loadExternalConnection = (
1285
- configId: Id<"entities">,
1286
- ): Effect.Effect<ProviderConfig, ConfigNotFoundError | DecryptionError> =>
1287
- Effect.gen(function* () {
1288
- const config = yield* Effect.tryPromise(() => db.get(configId));
1289
-
1290
- if (!config || config.type !== "external_connection") {
1291
- return yield* Effect.fail(new ConfigNotFoundError(configId));
1292
- }
1293
-
1294
- if (config.status !== "active") {
1295
- return yield* Effect.fail(
1296
- new ConfigNotFoundError(`Config ${configId} is inactive`),
1297
- );
1298
- }
1299
-
1300
- // Decrypt credentials
1301
- const decrypted = yield* decryptConfigCredentials(config.properties);
1302
-
1303
- return {
1304
- type: config.properties.platform,
1305
- ...config.properties.config,
1306
- ...decrypted,
1307
- };
1308
- });
1309
- ```
1310
-
1311
- **Step 24:** Create scoped query wrapper
1312
-
1313
- ```typescript
1314
- // backend/convex/queries/scoped.ts
1315
- export const createScopedQuery = <Args, Result>(
1316
- fn: (ctx: QueryCtx, args: Args, provider: DataProvider) => Promise<Result>,
1317
- ) => {
1318
- return query({
1319
- handler: async (ctx, args) => {
1320
- // Get user identity
1321
- const identity = await ctx.auth.getUserIdentity();
1322
- if (!identity) throw new Error("Not authenticated");
1323
-
1324
- // Get user's organization
1325
- const user = await ctx.db
1326
- .query("entities")
1327
- .filter((q) => q.eq(q.field("properties.email"), identity.email))
1328
- .first();
1329
-
1330
- if (!user?.properties.organizationId) {
1331
- throw new Error("User has no organization");
1332
- }
1333
-
1334
- // Resolve provider for org
1335
- const provider = await Effect.runPromise(
1336
- resolveProviderForOrg(user.properties.organizationId).pipe(
1337
- Effect.provide(ConfigServiceLayer),
1338
- ),
1339
- );
1340
-
1341
- // Execute query with scoped provider
1342
- return await fn(ctx, args, provider);
1343
- },
1344
- });
1345
- };
1346
- ```
1347
-
1348
- **Step 25:** Example scoped query usage
1349
-
1350
- ```typescript
1351
- // backend/convex/queries/entities.ts
1352
- export const list = createScopedQuery(
1353
- async (ctx, args: { type: string }, provider) => {
1354
- // Provider is automatically scoped to user's org
1355
- return await provider.query("entities", {
1356
- where: { type: args.type },
1357
- });
1358
- },
1359
- );
1360
- ```
1361
-
1362
- **Step 26:** Create scoped mutation wrapper
1363
-
1364
- ```typescript
1365
- // backend/convex/mutations/scoped.ts
1366
- export const createScopedMutation = <Args, Result>(
1367
- fn: (
1368
- ctx: MutationCtx,
1369
- args: Args,
1370
- provider: DataProvider,
1371
- orgId: Id<"entities">,
1372
- ) => Promise<Result>,
1373
- ) => {
1374
- return mutation({
1375
- handler: async (ctx, args) => {
1376
- const identity = await ctx.auth.getUserIdentity();
1377
- if (!identity) throw new Error("Not authenticated");
1378
-
1379
- const user = await ctx.db
1380
- .query("entities")
1381
- .filter((q) => q.eq(q.field("properties.email"), identity.email))
1382
- .first();
1383
-
1384
- if (!user?.properties.organizationId) {
1385
- throw new Error("User has no organization");
1386
- }
1387
-
1388
- const provider = await Effect.runPromise(
1389
- resolveProviderForOrg(user.properties.organizationId).pipe(
1390
- Effect.provide(ConfigServiceLayer),
1391
- ),
1392
- );
1393
-
1394
- return await fn(ctx, args, provider, user.properties.organizationId);
1395
- },
1396
- });
1397
- };
1398
- ```
1399
-
1400
- **Step 27:** Implement provider health check
1401
-
1402
- ```typescript
1403
- // backend/convex/services/health/checker.ts
1404
- export const checkProviderHealth = (
1405
- configId: Id<"entities">,
1406
- ): Effect.Effect<
1407
- { status: "online" | "offline"; responseTime: number },
1408
- ConnectionTestError
1409
- > =>
1410
- Effect.gen(function* () {
1411
- const config = yield* loadExternalConnection(configId);
1412
- const result = yield* testConnection(config);
1413
- return {
1414
- status: "online",
1415
- responseTime: result.responseTime,
1416
- };
1417
- });
1418
- ```
1419
-
1420
- **Step 28:** Create scheduled health check action
1421
-
1422
- ```typescript
1423
- // backend/convex/crons/health.ts
1424
- export const healthCheckCron = cronJobs.interval(
1425
- "provider-health-check",
1426
- { minutes: 5 },
1427
- internal.health.checkAllProviders,
1428
- );
1429
-
1430
- export const checkAllProviders = internalAction({
1431
- handler: async (ctx) => {
1432
- // Get all active external_connection entities
1433
- const configs = await ctx.runQuery(
1434
- internal.queries.config.listActiveConfigs,
1435
- );
1436
-
1437
- for (const config of configs) {
1438
- try {
1439
- const health = await Effect.runPromise(
1440
- checkProviderHealth(config._id).pipe(
1441
- Effect.provide(HealthCheckLayer),
1442
- ),
1443
- );
1444
-
1445
- // Log health event
1446
- await ctx.runMutation(internal.mutations.events.logHealthCheck, {
1447
- configId: config._id,
1448
- status: health.status,
1449
- responseTime: health.responseTime,
1450
- });
1451
- } catch (error) {
1452
- // Log failure event
1453
- await ctx.runMutation(internal.mutations.events.logHealthCheck, {
1454
- configId: config._id,
1455
- status: "offline",
1456
- error: String(error),
1457
- });
1458
- }
1459
- }
1460
- },
1461
- });
1462
- ```
1463
-
1464
- **Step 29:** Implement provider usage tracking
1465
-
1466
- ```typescript
1467
- // backend/convex/services/usage/tracker.ts
1468
- export const trackProviderUsage = (
1469
- orgId: Id<"entities">,
1470
- operation: string,
1471
- duration: number,
1472
- ): Effect.Effect<void, never> =>
1473
- Effect.gen(function* () {
1474
- // Create usage event
1475
- yield* Effect.tryPromise(() =>
1476
- db.insert("events", {
1477
- type: "communication_event",
1478
- actorId: orgId,
1479
- targetId: undefined,
1480
- timestamp: Date.now(),
1481
- metadata: {
1482
- protocol: "provider_usage",
1483
- operation,
1484
- duration,
1485
- },
1486
- }),
1487
- );
1488
-
1489
- // Update organization usage metrics (if needed)
1490
- // This enables billing based on provider operations
1491
- });
1492
- ```
1493
-
1494
- **Step 30:** Add provider metrics query
1495
-
1496
- ```typescript
1497
- // backend/convex/queries/metrics.ts
1498
- export const getProviderMetrics = query({
1499
- args: { orgId: v.id("entities"), days: v.number() },
1500
- handler: async (ctx, args) => {
1501
- const since = Date.now() - args.days * 24 * 60 * 60 * 1000;
1502
-
1503
- const events = await ctx.db
1504
- .query("events")
1505
- .withIndex("by_timestamp", (q) => q.gte("timestamp", since))
1506
- .filter((q) =>
1507
- q.and(
1508
- q.eq(q.field("type"), "communication_event"),
1509
- q.eq(q.field("actorId"), args.orgId),
1510
- q.eq(q.field("metadata.protocol"), "provider_usage"),
1511
- ),
1512
- )
1513
- .collect();
1514
-
1515
- return {
1516
- totalOperations: events.length,
1517
- averageDuration:
1518
- events.reduce((sum, e) => sum + (e.metadata.duration || 0), 0) /
1519
- events.length,
1520
- operationsByType: groupBy(events, (e) => e.metadata.operation),
1521
- };
1522
- },
1523
- });
1524
- ```
1525
-
1526
- ### Phase 4: Frontend Integration (Steps 31-40)
1527
-
1528
- **Step 31:** Create provider config form component
1529
-
1530
- ```typescript
1531
- // frontend/src/components/features/config/ProviderConfigForm.tsx
1532
- import { useState } from "react";
1533
- import { useMutation } from "convex/react";
1534
- import { api } from "@/convex/_generated/api";
1535
- import { Button } from "@/components/ui/button";
1536
- import { Input } from "@/components/ui/input";
1537
- import { Select } from "@/components/ui/select";
1538
- import { Card } from "@/components/ui/card";
1539
-
1540
- export function ProviderConfigForm({ orgId }: { orgId: Id<"entities"> }) {
1541
- const [providerType, setProviderType] = useState<ProviderType>("convex");
1542
- const [config, setConfig] = useState<Record<string, string>>({});
1543
- const [testing, setTesting] = useState(false);
1544
-
1545
- const saveConfig = useMutation(api.mutations.config.saveProviderConfig);
1546
- const testConnection = useMutation(api.mutations.config.testConnection);
1547
-
1548
- const handleTest = async () => {
1549
- setTesting(true);
1550
- try {
1551
- const result = await testConnection({ orgId, config: { type: providerType, ...config } });
1552
- alert(`Connection successful! Response time: ${result.responseTime}ms`);
1553
- } catch (error) {
1554
- alert(`Connection failed: ${error.message}`);
1555
- } finally {
1556
- setTesting(false);
1557
- }
1558
- };
1559
-
1560
- const handleSave = async () => {
1561
- try {
1562
- await saveConfig({ orgId, config: { type: providerType, ...config } });
1563
- alert("Provider configuration saved successfully!");
1564
- } catch (error) {
1565
- alert(`Failed to save configuration: ${error.message}`);
1566
- }
1567
- };
1568
-
1569
- return (
1570
- <Card className="p-6">
1571
- <h2 className="text-2xl font-bold mb-4">Backend Provider Configuration</h2>
1572
-
1573
- <div className="space-y-4">
1574
- <Select
1575
- value={providerType}
1576
- onValueChange={(value) => setProviderType(value as ProviderType)}
1577
- >
1578
- <option value="convex">Convex</option>
1579
- <option value="wordpress">WordPress</option>
1580
- <option value="notion">Notion</option>
1581
- <option value="supabase">Supabase</option>
1582
- </Select>
1583
-
1584
- {providerType === "wordpress" && (
1585
- <>
1586
- <Input
1587
- placeholder="WordPress URL"
1588
- value={config.baseUrl || ""}
1589
- onChange={(e) => setConfig({ ...config, baseUrl: e.target.value })}
1590
- />
1591
- <Input
1592
- placeholder="Username"
1593
- value={config.username || ""}
1594
- onChange={(e) => setConfig({ ...config, username: e.target.value })}
1595
- />
1596
- <Input
1597
- type="password"
1598
- placeholder="Application Password"
1599
- value={config.applicationPassword || ""}
1600
- onChange={(e) => setConfig({ ...config, applicationPassword: e.target.value })}
1601
- />
1602
- </>
1603
- )}
1604
-
1605
- {providerType === "notion" && (
1606
- <>
1607
- <Input
1608
- type="password"
1609
- placeholder="Notion Token"
1610
- value={config.token || ""}
1611
- onChange={(e) => setConfig({ ...config, token: e.target.value })}
1612
- />
1613
- <Input
1614
- placeholder="Database ID"
1615
- value={config.databaseId || ""}
1616
- onChange={(e) => setConfig({ ...config, databaseId: e.target.value })}
1617
- />
1618
- </>
1619
- )}
1620
-
1621
- <div className="flex gap-2">
1622
- <Button onClick={handleTest} disabled={testing}>
1623
- {testing ? "Testing..." : "Test Connection"}
1624
- </Button>
1625
- <Button onClick={handleSave} variant="primary">
1626
- Save Configuration
1627
- </Button>
1628
- </div>
1629
- </div>
1630
- </Card>
1631
- );
1632
- }
1633
- ```
1634
-
1635
- **Step 32:** Create provider status badge
1636
-
1637
- ```typescript
1638
- // frontend/src/components/features/config/ProviderStatusBadge.tsx
1639
- import { useQuery } from "convex/react";
1640
- import { api } from "@/convex/_generated/api";
1641
- import { Badge } from "@/components/ui/badge";
1642
-
1643
- export function ProviderStatusBadge({ orgId }: { orgId: Id<"entities"> }) {
1644
- const status = useQuery(api.queries.config.getProviderStatus, { orgId });
1645
-
1646
- if (status === undefined) return <Badge>Loading...</Badge>;
1647
-
1648
- return (
1649
- <Badge variant={status.online ? "success" : "destructive"}>
1650
- {status.type} ({status.online ? "Online" : "Offline"})
1651
- </Badge>
1652
- );
1653
- }
1654
- ```
1655
-
1656
- **Step 33:** Create settings page
1657
-
1658
- ```typescript
1659
- // frontend/src/pages/org/[orgId]/settings/backend.astro
1660
- ---
1661
- import Layout from "@/layouts/Layout.astro";
1662
- import ProviderConfigForm from "@/components/features/config/ProviderConfigForm";
1663
- import ProviderStatusBadge from "@/components/features/config/ProviderStatusBadge";
1664
-
1665
- const { orgId } = Astro.params;
1666
- ---
1667
-
1668
- <Layout title="Backend Settings">
1669
- <div class="container mx-auto py-8">
1670
- <div class="flex items-center justify-between mb-6">
1671
- <h1 class="text-3xl font-bold">Backend Provider Settings</h1>
1672
- <ProviderStatusBadge client:load orgId={orgId} />
1673
- </div>
1674
-
1675
- <ProviderConfigForm client:load orgId={orgId} />
1676
- </div>
1677
- </Layout>
1678
- ```
1679
-
1680
- **Step 34:** Add provider metrics dashboard
1681
-
1682
- ```typescript
1683
- // frontend/src/components/features/config/ProviderMetrics.tsx
1684
- import { useQuery } from "convex/react";
1685
- import { api } from "@/convex/_generated/api";
1686
- import { Card } from "@/components/ui/card";
1687
- import { LineChart, Line, XAxis, YAxis, Tooltip } from "recharts";
1688
-
1689
- export function ProviderMetrics({ orgId }: { orgId: Id<"entities"> }) {
1690
- const metrics = useQuery(api.queries.metrics.getProviderMetrics, {
1691
- orgId,
1692
- days: 7,
1693
- });
1694
-
1695
- if (metrics === undefined) return <div>Loading metrics...</div>;
1696
-
1697
- return (
1698
- <Card className="p-6">
1699
- <h3 className="text-xl font-bold mb-4">Provider Usage (Last 7 Days)</h3>
1700
-
1701
- <div className="grid grid-cols-2 gap-4 mb-6">
1702
- <div>
1703
- <p className="text-sm text-gray-500">Total Operations</p>
1704
- <p className="text-2xl font-bold">{metrics.totalOperations}</p>
1705
- </div>
1706
- <div>
1707
- <p className="text-sm text-gray-500">Average Response Time</p>
1708
- <p className="text-2xl font-bold">{metrics.averageDuration.toFixed(0)}ms</p>
1709
- </div>
1710
- </div>
1711
-
1712
- <LineChart width={600} height={300} data={metrics.operationsByDay}>
1713
- <XAxis dataKey="day" />
1714
- <YAxis />
1715
- <Tooltip />
1716
- <Line type="monotone" dataKey="count" stroke="#8884d8" />
1717
- </LineChart>
1718
- </Card>
1719
- );
1720
- }
1721
- ```
1722
-
1723
- **Step 35:** Implement rollback UI
1724
-
1725
- ```typescript
1726
- // frontend/src/components/features/config/ProviderRollback.tsx
1727
- import { useMutation, useQuery } from "convex/react";
1728
- import { api } from "@/convex/_generated/api";
1729
- import { Button } from "@/components/ui/button";
1730
- import { Alert } from "@/components/ui/alert";
1731
-
1732
- export function ProviderRollback({ orgId }: { orgId: Id<"entities"> }) {
1733
- const org = useQuery(api.queries.entities.get, { id: orgId });
1734
- const rollback = useMutation(api.mutations.config.rollbackProvider);
1735
-
1736
- if (!org?.properties.backendProvider?.previousProvider) {
1737
- return null; // No previous provider to rollback to
1738
- }
1739
-
1740
- const handleRollback = async () => {
1741
- if (!confirm("Are you sure you want to rollback to the previous provider?")) {
1742
- return;
1743
- }
1744
-
1745
- try {
1746
- await rollback({ orgId });
1747
- alert("Successfully rolled back to previous provider!");
1748
- } catch (error) {
1749
- alert(`Rollback failed: ${error.message}`);
1750
- }
1751
- };
1752
-
1753
- return (
1754
- <Alert variant="warning" className="mt-4">
1755
- <p className="mb-2">
1756
- You recently switched from {org.properties.backendProvider.previousProvider}.
1757
- </p>
1758
- <Button onClick={handleRollback} variant="outline">
1759
- Rollback to {org.properties.backendProvider.previousProvider}
1760
- </Button>
1761
- </Alert>
1762
- );
1763
- }
1764
- ```
1765
-
1766
- **Step 36:** Add provider switch confirmation dialog
1767
-
1768
- ```typescript
1769
- // frontend/src/components/features/config/SwitchConfirmDialog.tsx
1770
- import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
1771
- import { Button } from "@/components/ui/button";
1772
-
1773
- export function SwitchConfirmDialog({
1774
- open,
1775
- onClose,
1776
- fromProvider,
1777
- toProvider,
1778
- onConfirm,
1779
- }: {
1780
- open: boolean;
1781
- onClose: () => void;
1782
- fromProvider: string;
1783
- toProvider: string;
1784
- onConfirm: () => void;
1785
- }) {
1786
- return (
1787
- <Dialog open={open} onOpenChange={onClose}>
1788
- <DialogContent>
1789
- <DialogHeader>
1790
- <DialogTitle>Confirm Provider Switch</DialogTitle>
1791
- </DialogHeader>
1792
-
1793
- <div className="space-y-4">
1794
- <p>
1795
- You are about to switch your backend provider from{" "}
1796
- <strong>{fromProvider}</strong> to <strong>{toProvider}</strong>.
1797
- </p>
1798
-
1799
- <Alert variant="warning">
1800
- <p>This will:</p>
1801
- <ul className="list-disc ml-6 mt-2">
1802
- <li>Disconnect from {fromProvider}</li>
1803
- <li>Connect to {toProvider}</li>
1804
- <li>Take approximately 15-30 seconds</li>
1805
- <li>Temporarily interrupt service during switch</li>
1806
- </ul>
1807
- </Alert>
1808
-
1809
- <p className="text-sm text-gray-500">
1810
- You can rollback to {fromProvider} if needed.
1811
- </p>
1812
-
1813
- <div className="flex gap-2 justify-end">
1814
- <Button onClick={onClose} variant="outline">
1815
- Cancel
1816
- </Button>
1817
- <Button onClick={onConfirm} variant="destructive">
1818
- Confirm Switch
1819
- </Button>
1820
- </div>
1821
- </div>
1822
- </DialogContent>
1823
- </Dialog>
1824
- );
1825
- }
1826
- ```
1827
-
1828
- **Step 37:** Create provider health monitoring page
1829
-
1830
- ```typescript
1831
- // frontend/src/pages/admin/providers.astro
1832
- ---
1833
- import Layout from "@/layouts/Layout.astro";
1834
- import ProviderHealthList from "@/components/features/config/ProviderHealthList";
1835
-
1836
- // Only accessible to platform_owner
1837
- const user = Astro.locals.user;
1838
- if (user?.role !== "platform_owner") {
1839
- return Astro.redirect("/");
1840
- }
1841
- ---
1842
-
1843
- <Layout title="Provider Health Monitoring">
1844
- <div class="container mx-auto py-8">
1845
- <h1 class="text-3xl font-bold mb-6">Provider Health Monitoring</h1>
1846
- <ProviderHealthList client:load />
1847
- </div>
1848
- </Layout>
1849
- ```
1850
-
1851
- **Step 38:** Implement health list component
1852
-
1853
- ```typescript
1854
- // frontend/src/components/features/config/ProviderHealthList.tsx
1855
- import { useQuery } from "convex/react";
1856
- import { api } from "@/convex/_generated/api";
1857
- import { Card } from "@/components/ui/card";
1858
- import { Badge } from "@/components/ui/badge";
1859
-
1860
- export function ProviderHealthList() {
1861
- const configs = useQuery(api.queries.config.listActiveConfigs);
1862
-
1863
- if (configs === undefined) return <div>Loading...</div>;
1864
-
1865
- return (
1866
- <div className="space-y-4">
1867
- {configs.map((config) => (
1868
- <Card key={config._id} className="p-4">
1869
- <div className="flex items-center justify-between">
1870
- <div>
1871
- <h3 className="font-bold">{config.name}</h3>
1872
- <p className="text-sm text-gray-500">
1873
- {config.properties.platform} · Last checked:{" "}
1874
- {new Date(config.properties.lastConnectedAt || 0).toLocaleString()}
1875
- </p>
1876
- </div>
1877
-
1878
- <div className="flex items-center gap-2">
1879
- <Badge
1880
- variant={
1881
- config.properties.status === "active" ? "success" : "destructive"
1882
- }
1883
- >
1884
- {config.properties.status}
1885
- </Badge>
1886
-
1887
- {config.properties.lastError && (
1888
- <p className="text-sm text-red-500">{config.properties.lastError}</p>
1889
- )}
1890
- </div>
1891
- </div>
1892
- </Card>
1893
- ))}
1894
- </div>
1895
- );
1896
- }
1897
- ```
1898
-
1899
- **Step 39:** Add loading state during switch
1900
-
1901
- ```typescript
1902
- // frontend/src/components/features/config/SwitchProgress.tsx
1903
- import { Progress } from "@/components/ui/progress";
1904
- import { Card } from "@/components/ui/card";
1905
-
1906
- export function SwitchProgress({ progress }: { progress: number }) {
1907
- const steps = [
1908
- { label: "Validating configuration", progress: 20 },
1909
- { label: "Testing connection", progress: 40 },
1910
- { label: "Encrypting credentials", progress: 60 },
1911
- { label: "Saving configuration", progress: 80 },
1912
- { label: "Initializing provider", progress: 100 },
1913
- ];
1914
-
1915
- const currentStep = steps.findIndex((s) => s.progress >= progress) || 0;
1916
-
1917
- return (
1918
- <Card className="p-6">
1919
- <h3 className="text-lg font-bold mb-4">Switching Provider...</h3>
1920
-
1921
- <Progress value={progress} className="mb-4" />
1922
-
1923
- <div className="space-y-2">
1924
- {steps.map((step, index) => (
1925
- <div
1926
- key={step.label}
1927
- className={`flex items-center gap-2 ${
1928
- index <= currentStep ? "text-blue-600" : "text-gray-400"
1929
- }`}
1930
- >
1931
- {index < currentStep ? "✓" : index === currentStep ? "⏳" : "○"}
1932
- {step.label}
1933
- </div>
1934
- ))}
1935
- </div>
1936
- </Card>
1937
- );
1938
- }
1939
- ```
1940
-
1941
- **Step 40:** Add error boundary for provider errors
1942
-
1943
- ```typescript
1944
- // frontend/src/components/features/config/ProviderErrorBoundary.tsx
1945
- import { Component, ReactNode } from "react";
1946
- import { Alert } from "@/components/ui/alert";
1947
- import { Button } from "@/components/ui/button";
1948
-
1949
- interface Props {
1950
- children: ReactNode;
1951
- }
1952
-
1953
- interface State {
1954
- hasError: boolean;
1955
- error?: Error;
1956
- }
1957
-
1958
- export class ProviderErrorBoundary extends Component<Props, State> {
1959
- constructor(props: Props) {
1960
- super(props);
1961
- this.state = { hasError: false };
1962
- }
1963
-
1964
- static getDerivedStateFromError(error: Error) {
1965
- return { hasError: true, error };
1966
- }
1967
-
1968
- render() {
1969
- if (this.state.hasError) {
1970
- return (
1971
- <Alert variant="destructive">
1972
- <h3 className="font-bold mb-2">Provider Error</h3>
1973
- <p className="mb-4">{this.state.error?.message}</p>
1974
- <Button onClick={() => window.location.reload()}>
1975
- Reload Page
1976
- </Button>
1977
- </Alert>
1978
- );
1979
- }
1980
-
1981
- return this.props.children;
1982
- }
1983
- }
1984
- ```
1985
-
1986
- ### Phase 5: Testing and Documentation (Steps 41-50)
1987
-
1988
- **Step 41:** Write unit tests for encryption
1989
-
1990
- ```typescript
1991
- // backend/convex/lib/encryption.test.ts
1992
- import { describe, it, expect } from "vitest";
1993
- import { encrypt, decrypt, generateEncryptionKey } from "./encryption";
1994
-
1995
- describe("Encryption", () => {
1996
- it("should encrypt and decrypt correctly", async () => {
1997
- const key = generateEncryptionKey();
1998
- const plaintext = "secret-api-key-12345";
1999
-
2000
- const encrypted = await encrypt(plaintext, key);
2001
- const decrypted = await decrypt(encrypted, key);
2002
-
2003
- expect(decrypted).toBe(plaintext);
2004
- });
2005
-
2006
- it("should produce different ciphertexts for same plaintext", async () => {
2007
- const key = generateEncryptionKey();
2008
- const plaintext = "secret";
2009
-
2010
- const encrypted1 = await encrypt(plaintext, key);
2011
- const encrypted2 = await encrypt(plaintext, key);
2012
-
2013
- expect(encrypted1.ciphertext).not.toBe(encrypted2.ciphertext);
2014
- expect(encrypted1.iv).not.toBe(encrypted2.iv);
2015
- });
2016
-
2017
- it("should fail with wrong key", async () => {
2018
- const key1 = generateEncryptionKey();
2019
- const key2 = generateEncryptionKey();
2020
- const plaintext = "secret";
2021
-
2022
- const encrypted = await encrypt(plaintext, key1);
2023
- await expect(decrypt(encrypted, key2)).rejects.toThrow();
2024
- });
2025
-
2026
- it("should fail with tampered ciphertext", async () => {
2027
- const key = generateEncryptionKey();
2028
- const plaintext = "secret";
2029
-
2030
- const encrypted = await encrypt(plaintext, key);
2031
- encrypted.ciphertext = encrypted.ciphertext.slice(0, -1) + "X";
2032
-
2033
- await expect(decrypt(encrypted, key)).rejects.toThrow();
2034
- });
2035
- });
2036
- ```
2037
-
2038
- **Step 42:** Write integration tests for provider switching
2039
-
2040
- ```typescript
2041
- // backend/convex/services/config/switcher.test.ts
2042
- import { describe, it, expect, beforeEach } from "vitest";
2043
- import { Effect } from "effect";
2044
- import { switchProvider } from "./switcher";
2045
- import { TestLayer } from "../../test/layers";
2046
-
2047
- describe("Provider Switching", () => {
2048
- beforeEach(() => {
2049
- // Reset test database
2050
- });
2051
-
2052
- it("should switch provider successfully", async () => {
2053
- const result = await Effect.runPromise(
2054
- switchProvider(
2055
- "org_123",
2056
- {
2057
- type: "wordpress",
2058
- baseUrl: "https://example.com/wp-json",
2059
- username: "admin",
2060
- applicationPassword: "xxxx xxxx xxxx xxxx",
2061
- },
2062
- "user_456",
2063
- ).pipe(Effect.provide(TestLayer)),
2064
- );
2065
-
2066
- expect(result.switchDuration).toBeLessThan(30000);
2067
- expect(result.configId).toBeDefined();
2068
- });
2069
-
2070
- it("should rollback on connection test failure", async () => {
2071
- await expect(
2072
- Effect.runPromise(
2073
- switchProvider(
2074
- "org_123",
2075
- {
2076
- type: "wordpress",
2077
- baseUrl: "https://invalid-url.com",
2078
- username: "admin",
2079
- applicationPassword: "wrong",
2080
- },
2081
- "user_456",
2082
- ).pipe(Effect.provide(TestLayer)),
2083
- ),
2084
- ).rejects.toThrow("Connection test failed");
2085
-
2086
- // Verify org still using old provider
2087
- const org = await getOrganization("org_123");
2088
- expect(org.properties.backendProvider.type).toBe("convex");
2089
- });
2090
-
2091
- it("should encrypt credentials before saving", async () => {
2092
- const result = await Effect.runPromise(
2093
- switchProvider(
2094
- "org_123",
2095
- {
2096
- type: "wordpress",
2097
- baseUrl: "https://example.com/wp-json",
2098
- username: "admin",
2099
- applicationPassword: "plaintext-password",
2100
- },
2101
- "user_456",
2102
- ).pipe(Effect.provide(TestLayer)),
2103
- );
2104
-
2105
- const config = await getEntity(result.configId);
2106
- expect(config.properties.config.applicationPassword).not.toBe(
2107
- "plaintext-password",
2108
- );
2109
- expect(config.properties.apiKeyIv).toBeDefined();
2110
- expect(config.properties.apiKeyAuthTag).toBeDefined();
2111
- });
2112
- });
2113
- ```
2114
-
2115
- **Step 43:** Write E2E test for provider switch UI
2116
-
2117
- ```typescript
2118
- // frontend/tests/e2e/provider-switch.test.ts
2119
- import { test, expect } from "@playwright/test";
2120
-
2121
- test("org owner can switch backend provider", async ({ page }) => {
2122
- // Login as org owner
2123
- await page.goto("/login");
2124
- await page.fill('input[name="email"]', "owner@example.com");
2125
- await page.fill('input[name="password"]', "password123");
2126
- await page.click('button[type="submit"]');
2127
-
2128
- // Navigate to backend settings
2129
- await page.goto("/org/org_123/settings/backend");
2130
-
2131
- // Current provider should be Convex
2132
- await expect(page.locator("text=Convex (Online)")).toBeVisible();
2133
-
2134
- // Change to WordPress
2135
- await page.selectOption('select[name="providerType"]', "wordpress");
2136
- await page.fill(
2137
- 'input[placeholder="WordPress URL"]',
2138
- "https://example.com/wp-json",
2139
- );
2140
- await page.fill('input[placeholder="Username"]', "admin");
2141
- await page.fill(
2142
- 'input[placeholder="Application Password"]',
2143
- "xxxx xxxx xxxx xxxx",
2144
- );
2145
-
2146
- // Test connection
2147
- await page.click("button:has-text('Test Connection')");
2148
- await expect(page.locator("text=Connection successful")).toBeVisible();
2149
-
2150
- // Save configuration
2151
- await page.click("button:has-text('Save Configuration')");
2152
-
2153
- // Wait for switch to complete
2154
- await expect(page.locator("text=WordPress (Online)")).toBeVisible({
2155
- timeout: 30000,
2156
- });
2157
-
2158
- // Verify rollback button appears
2159
- await expect(
2160
- page.locator("button:has-text('Rollback to Convex')"),
2161
- ).toBeVisible();
2162
- });
2163
- ```
2164
-
2165
- **Step 44:** Document environment variables
2166
-
2167
- ```markdown
2168
- <!-- /Users/toc/Server/ONE/one/things/features/2-2-config-env-vars.md -->
2169
-
2170
- # Backend Provider Environment Variables
2171
-
2172
- ## Encryption
2173
-
2174
- Required for all configurations:
2175
-
2176
- \`\`\`bash
2177
-
2178
- # Generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
2179
-
2180
- ENCRYPTION_KEY=64-character-hex-string
2181
- \`\`\`
2182
-
2183
- ## Default Provider
2184
-
2185
- Choose one:
2186
-
2187
- ### Convex (Default)
2188
-
2189
- \`\`\`bash
2190
- BACKEND_PROVIDER=convex
2191
- CONVEX_DEPLOYMENT_URL=https://shocking-falcon-870.convex.cloud
2192
- CONVEX_DEPLOYMENT_NAME=prod:shocking-falcon-870
2193
- \`\`\`
2194
-
2195
- ### WordPress
2196
-
2197
- \`\`\`bash
2198
- BACKEND_PROVIDER=wordpress
2199
- WORDPRESS_URL=https://example.com/wp-json
2200
- WORDPRESS_USERNAME=admin
2201
- WORDPRESS_APP_PASSWORD=xxxx-xxxx-xxxx-xxxx
2202
- \`\`\`
2203
-
2204
- Generate WordPress Application Password:
2205
-
2206
- 1. Login to WordPress admin
2207
- 2. Users → Profile
2208
- 3. Scroll to "Application Passwords"
2209
- 4. Enter name (e.g., "ONE Platform")
2210
- 5. Click "Add New Application Password"
2211
- 6. Copy the generated password
2212
-
2213
- ### Notion
2214
-
2215
- \`\`\`bash
2216
- BACKEND_PROVIDER=notion
2217
- NOTION_TOKEN=secret_xxxxxxxxxxxxxxxxxxxxx
2218
- NOTION_DATABASE_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2219
- \`\`\`
2220
-
2221
- Get Notion credentials:
2222
-
2223
- 1. Go to https://www.notion.so/my-integrations
2224
- 2. Create new integration
2225
- 3. Copy "Internal Integration Token"
2226
- 4. Share database with integration
2227
- 5. Copy database ID from URL
2228
-
2229
- ### Supabase
2230
-
2231
- \`\`\`bash
2232
- BACKEND_PROVIDER=supabase
2233
- SUPABASE_URL=https://xxxxxxxxxxxxx.supabase.co
2234
- SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
2235
- SUPABASE_SERVICE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... # Optional, for admin operations
2236
- \`\`\`
2237
-
2238
- ## Runtime Override
2239
-
2240
- Organizations can override default provider via UI or API.
2241
- Runtime config stored in \`external_connection\` entities.
2242
- \`\`\`
2243
- ```
2244
-
2245
- **Step 45:** Create configuration guide
2246
-
2247
- ```markdown
2248
- <!-- /Users/toc/Server/ONE/one/things/features/2-2-config-guide.md -->
2249
-
2250
- # Backend Provider Configuration Guide
2251
-
2252
- ## Overview
2253
-
2254
- ONE Platform supports multiple backend providers:
2255
-
2256
- - Convex (default, real-time database)
2257
- - WordPress (REST API, existing sites)
2258
- - Notion (databases as backend)
2259
- - Supabase (PostgreSQL, real-time, auth)
2260
-
2261
- ## For Platform Owners
2262
-
2263
- ### Set Default Provider
2264
-
2265
- 1. Edit \`.env.local\` in \`backend/\` directory
2266
- 2. Set \`BACKEND_PROVIDER=convex\` (or wordpress, notion, supabase)
2267
- 3. Add provider-specific credentials (see env vars doc)
2268
- 4. Restart Convex: \`npx convex dev\`
2269
- 5. Verify: Check logs for "Loaded provider: convex"
2270
-
2271
- ### Monitor All Providers
2272
-
2273
- 1. Navigate to \`/admin/providers\`
2274
- 2. View health status of all active providers
2275
- 3. Manually trigger health checks
2276
- 4. View error logs for failed providers
2277
-
2278
- ## For Organization Owners
2279
-
2280
- ### Switch Your Provider
2281
-
2282
- 1. Navigate to \`/org/[your-org]/settings/backend\`
2283
- 2. See current provider and status
2284
- 3. Click "Change Provider"
2285
- 4. Select new provider type from dropdown
2286
- 5. Fill in provider-specific credentials
2287
- 6. Click "Test Connection" to verify
2288
- 7. Click "Save and Switch" to apply
2289
- 8. Wait 15-30 seconds for switch to complete
2290
- 9. Verify new provider shows as "Online"
2291
-
2292
- ### Rollback Provider
2293
-
2294
- If new provider has issues:
2295
-
2296
- 1. Navigate to \`/org/[your-org]/settings/backend\`
2297
- 2. See "You recently switched from X" alert
2298
- 3. Click "Rollback to X"
2299
- 4. Confirm rollback
2300
- 5. Wait ~10 seconds
2301
- 6. Verify old provider restored
2302
-
2303
- ### Troubleshooting
2304
-
2305
- **Provider shows "Offline":**
2306
-
2307
- - Check credentials are correct
2308
- - Verify provider URL is accessible
2309
- - Check provider service status (e.g., WordPress site up?)
2310
- - View error details in provider settings
2311
-
2312
- **Switch takes >30 seconds:**
2313
-
2314
- - Check network connection
2315
- - Verify provider responds to health checks
2316
- - Contact support if persists
2317
-
2318
- **Can't save credentials:**
2319
-
2320
- - Verify you're org_owner (not org_user)
2321
- - Check credentials match expected format
2322
- - Ensure "Test Connection" passes first
2323
- \`\`\`
2324
- ```
2325
-
2326
- **Step 46:** Add troubleshooting guide
2327
-
2328
- ```markdown
2329
- <!-- /Users/toc/Server/ONE/one/things/features/2-2-troubleshooting.md -->
2330
-
2331
- # Provider Configuration Troubleshooting
2332
-
2333
- ## Common Issues
2334
-
2335
- ### Encryption Key Error
2336
-
2337
- **Error:** "ENCRYPTION_KEY not configured"
2338
-
2339
- **Solution:**
2340
-
2341
- 1. Generate key: \`node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"\`
2342
- 2. Add to \`.env.local\`: \`ENCRYPTION_KEY=<generated-key>\`
2343
- 3. Restart Convex
2344
-
2345
- ### Provider Validation Failed
2346
-
2347
- **Error:** "Invalid WordPress URL"
2348
-
2349
- **Solution:**
2350
-
2351
- - WordPress URL must end with \`/wp-json\`
2352
- - Example: \`https://example.com/wp-json\` (not \`https://example.com\`)
2353
-
2354
- **Error:** "Invalid Notion token"
2355
-
2356
- **Solution:**
2357
-
2358
- - Token must start with \`secret\_\`
2359
- - Regenerate token in Notion integrations if needed
2360
-
2361
- ### Connection Test Failed
2362
-
2363
- **Error:** "Health check returned 404"
2364
-
2365
- **Solution (WordPress):**
2366
-
2367
- - Ensure WordPress site is accessible
2368
- - Verify REST API enabled (not disabled by security plugin)
2369
- - Test manually: \`curl https://example.com/wp-json/\`
2370
-
2371
- **Error:** "Unauthorized"
2372
-
2373
- **Solution:**
2374
-
2375
- - Check credentials are correct
2376
- - WordPress: Regenerate application password
2377
- - Notion: Verify integration has database access
2378
- - Supabase: Check anon key is correct
2379
-
2380
- ### Switch Timeout
2381
-
2382
- **Error:** "Provider switch exceeded 30 seconds"
2383
-
2384
- **Solution:**
2385
-
2386
- - Check network connection
2387
- - Verify provider responds quickly
2388
- - Try again (may be temporary network issue)
2389
- - Contact support if persists
2390
-
2391
- ## Debugging Steps
2392
-
2393
- 1. Check environment variables loaded:
2394
- \`\`\`typescript
2395
- console.log("Provider:", process.env.BACKEND_PROVIDER);
2396
- \`\`\`
2397
-
2398
- 2. Test encryption key:
2399
- \`\`\`typescript
2400
- import { generateEncryptionKey } from "./lib/encryption";
2401
- console.log("Key valid:", Buffer.from(process.env.ENCRYPTION_KEY, "hex").length === 32);
2402
- \`\`\`
2403
-
2404
- 3. Test provider connection:
2405
- \`\`\`bash
2406
- curl https://shocking-falcon-870.convex.cloud/_system/health
2407
- \`\`\`
2408
-
2409
- 4. Check event logs:
2410
- \`\`\`typescript
2411
- const events = await ctx.db.query("events")
2412
- .withIndex("by_type", q => q.eq("type", "settings_updated"))
2413
- .order("desc")
2414
- .take(10);
2415
- \`\`\`
2416
- \`\`\`
2417
- ```
2418
-
2419
- **Step 47:** Write API reference
2420
-
2421
- ```markdown
2422
- <!-- /Users/toc/Server/ONE/one/things/features/2-2-api-reference.md -->
2423
-
2424
- # Provider Configuration API Reference
2425
-
2426
- ## Mutations
2427
-
2428
- ### saveProviderConfig
2429
-
2430
- Save new provider configuration for organization.
2431
-
2432
- **Args:**
2433
- \`\`\`typescript
2434
- {
2435
- orgId: Id<"entities">,
2436
- config: {
2437
- type: "convex" | "wordpress" | "notion" | "supabase",
2438
- // Provider-specific fields
2439
- }
2440
- }
2441
- \`\`\`
2442
-
2443
- **Returns:**
2444
- \`\`\`typescript
2445
- {
2446
- switchDuration: number, // milliseconds
2447
- configId: Id<"entities"> // external_connection entity
2448
- }
2449
- \`\`\`
2450
-
2451
- **Errors:**
2452
-
2453
- - UnauthorizedError: Not org_owner
2454
- - ValidationError: Invalid config
2455
- - ConnectionTestError: Connection failed
2456
- - EncryptionError: Failed to encrypt credentials
2457
-
2458
- ### rollbackProvider
2459
-
2460
- Rollback to previous provider configuration.
2461
-
2462
- **Args:**
2463
- \`\`\`typescript
2464
- {
2465
- orgId: Id<"entities">
2466
- }
2467
- \`\`\`
2468
-
2469
- **Returns:**
2470
- \`\`\`typescript
2471
- {
2472
- configId: Id<"entities">, // Previous config entity
2473
- provider: string // Provider type
2474
- }
2475
- \`\`\`
2476
-
2477
- ## Queries
2478
-
2479
- ### getProviderStatus
2480
-
2481
- Get current provider status for organization.
2482
-
2483
- **Args:**
2484
- \`\`\`typescript
2485
- {
2486
- orgId: Id<"entities">
2487
- }
2488
- \`\`\`
2489
-
2490
- **Returns:**
2491
- \`\`\`typescript
2492
- {
2493
- type: ProviderType,
2494
- online: boolean,
2495
- lastCheckedAt: number,
2496
- responseTime: number, // milliseconds
2497
- error?: string
2498
- }
2499
- \`\`\`
2500
-
2501
- ### listActiveConfigs
2502
-
2503
- List all active provider configurations (platform_owner only).
2504
-
2505
- **Returns:**
2506
- \`\`\`typescript
2507
- Array<{
2508
- \_id: Id<"entities">,
2509
- name: string,
2510
- platform: ProviderType,
2511
- status: "active" | "inactive" | "error",
2512
- lastConnectedAt: number,
2513
- lastError?: string
2514
- }>
2515
- \`\`\`
2516
-
2517
- ### getProviderMetrics
2518
-
2519
- Get usage metrics for organization's provider.
2520
-
2521
- **Args:**
2522
- \`\`\`typescript
2523
- {
2524
- orgId: Id<"entities">,
2525
- days: number // Look back period
2526
- }
2527
- \`\`\`
2528
-
2529
- **Returns:**
2530
- \`\`\`typescript
2531
- {
2532
- totalOperations: number,
2533
- averageDuration: number,
2534
- operationsByType: Record<string, number>
2535
- }
2536
- \`\`\`
2537
- \`\`\`
2538
- ```
2539
-
2540
- **Step 48:** Create performance benchmarks
2541
-
2542
- ```typescript
2543
- // backend/convex/benchmarks/provider-switch.bench.ts
2544
- import { describe, bench } from "vitest";
2545
- import { Effect } from "effect";
2546
- import { switchProvider } from "../services/config/switcher";
2547
- import { BenchmarkLayer } from "../test/layers";
2548
-
2549
- describe("Provider Switch Performance", () => {
2550
- bench("switch to WordPress", async () => {
2551
- await Effect.runPromise(
2552
- switchProvider(
2553
- "org_bench",
2554
- {
2555
- type: "wordpress",
2556
- baseUrl: "https://example.com/wp-json",
2557
- username: "admin",
2558
- applicationPassword: "xxxx xxxx xxxx xxxx",
2559
- },
2560
- "user_bench",
2561
- ).pipe(Effect.provide(BenchmarkLayer)),
2562
- );
2563
- });
2564
-
2565
- bench("encrypt 100 credentials", async () => {
2566
- const promises = Array.from({ length: 100 }, (_, i) =>
2567
- encrypt(`api-key-${i}`, process.env.ENCRYPTION_KEY!),
2568
- );
2569
- await Promise.all(promises);
2570
- });
2571
-
2572
- bench("resolve provider for 100 orgs", async () => {
2573
- const promises = Array.from({ length: 100 }, (_, i) =>
2574
- Effect.runPromise(
2575
- resolveProviderForOrg(`org_${i}`).pipe(Effect.provide(BenchmarkLayer)),
2576
- ),
2577
- );
2578
- await Promise.all(promises);
2579
- });
2580
- });
2581
-
2582
- // Target results:
2583
- // switch to WordPress: <15,000ms
2584
- // encrypt 100 credentials: <500ms
2585
- // resolve provider for 100 orgs: <1,000ms
2586
- ```
2587
-
2588
- **Step 49:** Add migration guide for existing users
2589
-
2590
- ```markdown
2591
- <!-- /Users/toc/Server/ONE/one/things/features/2-2-migration-guide.md -->
2592
-
2593
- # Migrating to Configuration System
2594
-
2595
- ## For Existing ONE Platform Deployments
2596
-
2597
- ### Before Migration
2598
-
2599
- 1. Backup your database
2600
- 2. Note current provider in use (should be Convex)
2601
- 3. Document any custom configurations
2602
-
2603
- ### Migration Steps
2604
-
2605
- 1. **Update environment variables**
2606
- \`\`\`bash
2607
-
2608
- # Add to backend/.env.local
2609
-
2610
- ENCRYPTION_KEY=$(node -e "console.log(require('crypto').randomBytes(32).toString('hex'))")
2611
- BACKEND_PROVIDER=convex
2612
- CONVEX_DEPLOYMENT_URL=https://shocking-falcon-870.convex.cloud
2613
- CONVEX_DEPLOYMENT_NAME=prod:shocking-falcon-870
2614
- \`\`\`
2615
-
2616
- 2. **Deploy updated backend**
2617
- \`\`\`bash
2618
- cd backend
2619
- npx convex deploy
2620
- \`\`\`
2621
-
2622
- 3. **Update organizations**
2623
-
2624
- Existing organizations will automatically use default provider.
2625
- No data migration needed.
2626
-
2627
- 4. **Test provider switching**
2628
-
2629
- Create test organization and verify provider switch works.
2630
-
2631
- 5. **Enable for production**
2632
-
2633
- Organizations can now configure custom providers.
2634
-
2635
- ### Rollback Plan
2636
-
2637
- If issues occur:
2638
-
2639
- 1. Remove provider configuration UI
2640
- 2. Revert to hardcoded ConvexProvider
2641
- 3. Clear cached providers: \`clearAllProviders()\`
2642
- 4. Restart Convex
2643
-
2644
- Rollback time: <5 minutes
2645
- \`\`\`
2646
- ```
2647
-
2648
- **Step 50:** Create provider comparison matrix
2649
-
2650
- ```markdown
2651
- <!-- /Users/toc/Server/ONE/one/things/features/2-2-provider-comparison.md -->
2652
-
2653
- # Backend Provider Comparison
2654
-
2655
- | Feature | Convex | WordPress | Notion | Supabase |
2656
- | ------------------ | -------------------- | ----------------- | ------------------- | ------------------ |
2657
- | **Real-time** | ✅ Native | ❌ Polling only | ❌ Polling only | ✅ Native |
2658
- | **Authentication** | ✅ Built-in | ✅ Via plugins | ❌ External | ✅ Built-in |
2659
- | **Storage** | ✅ Built-in | ✅ Media library | ✅ Files | ✅ Storage buckets |
2660
- | **Functions** | ✅ Mutations/Actions | ✅ PHP endpoints | ❌ External | ✅ Edge Functions |
2661
- | **Search** | ✅ Full-text | ✅ Via plugins | ✅ Database filters | ✅ PostgreSQL FTS |
2662
- | **Cost** | Usage-based | Hosting + plugins | Per-seat | Usage-based |
2663
- | **Setup Time** | Minutes | Hours (install) | Minutes | Minutes |
2664
- | **Scalability** | Auto | Manual | Limited | Auto |
2665
- | **Data Model** | JSON documents | MySQL tables | Databases | PostgreSQL |
2666
- | **Best For** | Modern apps | Existing WP sites | Internal tools | SQL-heavy apps |
2667
-
2668
- ## When to Use Each Provider
2669
-
2670
- ### Convex (Default)
2671
-
2672
- - New projects
2673
- - Real-time features needed
2674
- - Automatic scaling required
2675
- - Simple data model (JSON)
2676
-
2677
- ### WordPress
2678
-
2679
- - Existing WordPress site
2680
- - Content-heavy site
2681
- - Need plugins ecosystem
2682
- - Team familiar with WordPress
2683
-
2684
- ### Notion
2685
-
2686
- - Internal tools/dashboards
2687
- - Simple CRUD operations
2688
- - No real-time needed
2689
- - Notion-first workflow
2690
-
2691
- ### Supabase
2692
-
2693
- - Complex SQL queries needed
2694
- - PostgreSQL familiarity
2695
- - Edge functions required
2696
- - Full control over database
2697
- \`\`\`
2698
- ```
2699
-
2700
- ---
2701
-
2702
- ## 4. Testing Strategy
2703
-
2704
- ### Unit Tests
2705
-
2706
- **Encryption (10 tests):**
2707
-
2708
- - ✅ Encrypt and decrypt correctly
2709
- - ✅ Different ciphertexts for same plaintext (unique IV)
2710
- - ✅ Fail with wrong key
2711
- - ✅ Fail with tampered ciphertext
2712
- - ✅ Fail with tampered auth tag
2713
- - ✅ Fail with wrong IV
2714
- - ✅ Fail with invalid key length
2715
- - ✅ Handle empty plaintext
2716
- - ✅ Handle large plaintext (>1MB)
2717
- - ✅ Key generation produces valid keys
2718
-
2719
- **Config Validation (15 tests):**
2720
-
2721
- - ✅ Validate Convex config (valid)
2722
- - ✅ Reject invalid Convex URL
2723
- - ✅ Validate WordPress config (valid)
2724
- - ✅ Reject WordPress URL without /wp-json
2725
- - ✅ Validate Notion config (valid)
2726
- - ✅ Reject Notion token without secret\_ prefix
2727
- - ✅ Validate Supabase config (valid)
2728
- - ✅ Reject invalid Supabase URL
2729
- - ✅ Handle optional service key
2730
- - ✅ Validate discriminated union
2731
- - ✅ Reject unknown provider type
2732
- - ✅ Reject missing required fields
2733
- - ✅ Validate field formats (URL, regex)
2734
- - ✅ Coerce types when safe
2735
- - ✅ Provide helpful error messages
2736
-
2737
- **Provider Factory (8 tests):**
2738
-
2739
- - ✅ Register provider
2740
- - ✅ Get provider factory
2741
- - ✅ List provider types
2742
- - ✅ Get provider capabilities
2743
- - ✅ Create provider instance
2744
- - ✅ Validate config before create
2745
- - ✅ Lazy initialization
2746
- - ✅ Cache provider instances
2747
-
2748
- ### Integration Tests
2749
-
2750
- **Provider Switching (12 tests):**
2751
-
2752
- - ✅ Switch from Convex to WordPress
2753
- - ✅ Switch from WordPress to Notion
2754
- - ✅ Rollback on connection failure
2755
- - ✅ Encrypt credentials before saving
2756
- - ✅ Create external_connection entity
2757
- - ✅ Update organization properties
2758
- - ✅ Log settings_updated event
2759
- - ✅ Clear cached provider
2760
- - ✅ Complete in <30 seconds
2761
- - ✅ Atomic operation (all or nothing)
2762
- - ✅ Rollback to previous provider
2763
- - ✅ Validate actor permissions
2764
-
2765
- **Multi-Tenant Isolation (6 tests):**
2766
-
2767
- - ✅ Each org has independent provider
2768
- - ✅ Org A using WordPress doesn't affect Org B using Convex
2769
- - ✅ Provider failure isolated to org
2770
- - ✅ Cached providers scoped by org
2771
- - ✅ Events log correct org context
2772
- - ✅ Health checks per org
2773
-
2774
- **Health Monitoring (5 tests):**
2775
-
2776
- - ✅ Health check creates communication_event
2777
- - ✅ Failed health check logs error
2778
- - ✅ Health check runs every 5 minutes
2779
- - ✅ Manual health check trigger
2780
- - ✅ Provider status updates correctly
2781
-
2782
- ### E2E Tests
2783
-
2784
- **Provider Switch UI (8 tests):**
2785
-
2786
- - ✅ Org owner can access backend settings
2787
- - ✅ Current provider displayed correctly
2788
- - ✅ Select new provider from dropdown
2789
- - ✅ Form shows provider-specific fields
2790
- - ✅ Test connection validates credentials
2791
- - ✅ Save and switch completes successfully
2792
- - ✅ Progress indicator shows switch steps
2793
- - ✅ Success notification displayed
2794
-
2795
- **Rollback UI (4 tests):**
2796
-
2797
- - ✅ Rollback button appears after switch
2798
- - ✅ Rollback confirmation dialog shown
2799
- - ✅ Rollback completes quickly (<10s)
2800
- - ✅ Previous provider restored
2801
-
2802
- **Error Handling (6 tests):**
2803
-
2804
- - ✅ Invalid credentials show error message
2805
- - ✅ Network error handled gracefully
2806
- - ✅ Provider timeout handled
2807
- - ✅ Encryption error caught
2808
- - ✅ Unauthorized access denied
2809
- - ✅ Error boundary catches UI errors
2810
-
2811
- ### Security Tests
2812
-
2813
- **Authorization (5 tests):**
2814
-
2815
- - ✅ platform_owner can configure any org
2816
- - ✅ org_owner can configure their org only
2817
- - ✅ org_user cannot configure provider
2818
- - ✅ customer cannot access settings
2819
- - ✅ Unauthorized access returns 403
2820
-
2821
- **Credential Protection (6 tests):**
2822
-
2823
- - ✅ API keys never logged
2824
- - ✅ API keys never in event metadata
2825
- - ✅ API keys never in error messages
2826
- - ✅ API keys encrypted at rest
2827
- - ✅ API keys masked in UI
2828
- - ✅ Decryption failures logged securely
2829
-
2830
- ### Performance Tests
2831
-
2832
- **Benchmarks (5 tests):**
2833
-
2834
- - ✅ Provider switch <30s (P99)
2835
- - ✅ Provider switch <15s (P50)
2836
- - ✅ Encrypt 100 credentials <500ms
2837
- - ✅ Resolve 100 org providers <1s
2838
- - ✅ Health check <3s per provider
2839
-
2840
- **Load Tests (3 tests):**
2841
-
2842
- - ✅ 100 concurrent provider switches
2843
- - ✅ 1000 provider resolutions/second
2844
- - ✅ Cache hit rate >90%
2845
-
2846
- ---
2847
-
2848
- ## 5. Quality Gates
2849
-
2850
- Before marking Feature 2-2 complete:
2851
-
2852
- - [ ] All 80+ tests passing
2853
- - [ ] TypeScript compiles with no errors
2854
- - [ ] Zod schemas validate all configs
2855
- - [ ] Encryption uses AES-256-GCM correctly
2856
- - [ ] Provider switch <30s (P99)
2857
- - [ ] Multi-tenant isolation verified
2858
- - [ ] No credentials in logs/events
2859
- - [ ] UI works for all 4 provider types
2860
- - [ ] Documentation complete (4 guides)
2861
- - [ ] Migration guide tested on staging
2862
- - [ ] Rollback plan tested (<5 min)
2863
- - [ ] Security review passed
2864
- - [ ] Platform owner can monitor all providers
2865
- - [ ] Org owners can switch their provider
2866
- - [ ] Events logged for all config changes
2867
- - [ ] Health checks running every 5 minutes
2868
-
2869
- ---
2870
-
2871
- ## 6. Dependencies
2872
-
2873
- **Required (Blocking):**
2874
-
2875
- - ✅ Feature 2-1: DataProvider Interface MUST be complete
2876
- - All 4 providers implement DataProvider
2877
- - query(), mutation(), healthCheck() methods
2878
- - Type signatures match interface
2879
-
2880
- **Schema Changes:**
2881
-
2882
- - ✅ `external_connection` entity type exists
2883
- - ✅ `configured_by` connection type defined
2884
- - ✅ `settings_updated` event type defined
2885
- - ✅ Organizations table includes `properties.backendProvider`
2886
-
2887
- **Environment:**
2888
-
2889
- - ✅ Node.js crypto module available
2890
- - ✅ Convex supports environment variables
2891
- - ✅ Frontend can call Convex mutations
2892
-
2893
- ---
2894
-
2895
- ## 7. Rollback Plan
2896
-
2897
- ### Pre-Rollback Checklist
2898
-
2899
- - [ ] Identify issue requiring rollback
2900
- - [ ] Notify affected organizations
2901
- - [ ] Backup current configs
2902
-
2903
- ### Rollback Steps (Target: <5 minutes)
2904
-
2905
- 1. **Disable provider switching UI** (1 min)
2906
-
2907
- ```typescript
2908
- // Hide provider config page
2909
- // frontend/src/pages/org/[orgId]/settings/backend.astro
2910
- return Astro.redirect("/org/" + orgId + "/settings");
2911
- ```
2912
-
2913
- 2. **Revert to hardcoded provider** (2 min)
2914
-
2915
- ```typescript
2916
- // backend/convex/providers/default.ts
2917
- export function getProvider(): DataProvider {
2918
- // Ignore configs, always return Convex
2919
- return new ConvexProvider({
2920
- deploymentUrl: process.env.CONVEX_DEPLOYMENT_URL,
2921
- deploymentName: process.env.CONVEX_DEPLOYMENT_NAME,
2922
- });
2923
- }
2924
- ```
2925
-
2926
- 3. **Clear provider cache** (30 sec)
2927
-
2928
- ```typescript
2929
- // backend/convex/providers/cache.ts
2930
- clearAllProviders();
2931
- ```
2932
-
2933
- 4. **Deploy rollback** (1 min)
2934
-
2935
- ```bash
2936
- cd backend
2937
- npx convex deploy --prod
2938
- ```
2939
-
2940
- 5. **Verify rollback** (30 sec)
2941
- - Check all orgs using Convex
2942
- - Test one query/mutation
2943
- - Verify no provider errors
2944
-
2945
- ### Post-Rollback
2946
-
2947
- - [ ] Document rollback reason
2948
- - [ ] Fix root cause
2949
- - [ ] Test fix on staging
2950
- - [ ] Re-enable with fix
2951
-
2952
- ### Rollback Triggers
2953
-
2954
- - Provider switch failures >10%
2955
- - P99 switch time >60s
2956
- - Credential decryption errors
2957
- - Multi-tenant isolation breach
2958
- - Security vulnerability discovered
2959
-
2960
- ---
2961
-
2962
- ## 8. Documentation Requirements
2963
-
2964
- **User Documentation:**
2965
-
2966
- - [x] Configuration guide (Step 45)
2967
- - [x] Environment variables reference (Step 44)
2968
- - [x] Troubleshooting guide (Step 46)
2969
- - [x] Provider comparison matrix (Step 50)
2970
- - [x] Migration guide (Step 49)
2971
-
2972
- **Developer Documentation:**
2973
-
2974
- - [x] API reference (Step 47)
2975
- - [x] Provider registration guide
2976
- - [x] Encryption implementation notes
2977
- - [x] Testing guide
2978
- - [x] Architecture decision records
2979
-
2980
- **Examples:**
2981
-
2982
- - [x] WordPress setup example
2983
- - [x] Notion setup example
2984
- - [x] Supabase setup example
2985
- - [x] Custom provider implementation example
2986
-
2987
- ---
2988
-
2989
- ## 9. Success Criteria
2990
-
2991
- ### Functional Requirements
2992
-
2993
- - [x] Organizations configure backend via .env or UI
2994
- - [x] Runtime provider switching works (<30s)
2995
- - [x] Multi-tenant isolation maintained (each org independent)
2996
- - [x] Credentials encrypted at rest (AES-256-GCM)
2997
- - [x] Provider health monitoring (every 5 min)
2998
- - [x] Rollback to previous provider (<10s)
2999
- - [x] Support 4 provider types (Convex, WordPress, Notion, Supabase)
3000
-
3001
- ### Non-Functional Requirements
3002
-
3003
- - [x] Switch duration P99 <30s
3004
- - [x] Switch duration P50 <15s
3005
- - [x] Health check response time <3s
3006
- - [x] Provider cache hit rate >90%
3007
- - [x] No credentials in logs/events/errors
3008
- - [x] No cross-org provider access
3009
- - [x] Type-safe configuration with Zod
3010
- - [x] Helpful error messages (not raw exceptions)
3011
-
3012
- ### Security Requirements
3013
-
3014
- - [x] API keys encrypted at rest
3015
- - [x] Unique IV per encryption
3016
- - [x] Authenticated encryption (GCM mode)
3017
- - [x] Authorization enforced (org_owner only)
3018
- - [x] Credentials never logged
3019
- - [x] Failed decryption alerts
3020
- - [x] Encryption key validation on startup
3021
-
3022
- ### Documentation Requirements
3023
-
3024
- - [x] 5 user guides written
3025
- - [x] API reference complete
3026
- - [x] Troubleshooting guide with solutions
3027
- - [x] Migration guide tested
3028
- - [x] Provider comparison matrix
3029
-
3030
- ### Testing Requirements
3031
-
3032
- - [x] 80+ tests passing
3033
- - [x] Unit tests (33 tests)
3034
- - [x] Integration tests (23 tests)
3035
- - [x] E2E tests (18 tests)
3036
- - [x] Security tests (11 tests)
3037
- - [x] Performance benchmarks (8 tests)
3038
-
3039
- ---
3040
-
3041
- ## 10. Related Files
3042
-
3043
- **Implementation Files:**
3044
-
3045
- - `backend/convex/schema.ts` - Schema updates
3046
- - `backend/convex/providers/factory.ts` - Provider factory
3047
- - `backend/convex/providers/registry.ts` - Provider registration
3048
- - `backend/convex/services/config/provider.ts` - Config service
3049
- - `backend/convex/lib/encryption.ts` - Encryption utilities
3050
- - `backend/convex/config/loader.ts` - Environment loader
3051
- - `frontend/src/components/features/config/` - UI components
3052
- - `frontend/src/pages/org/[orgId]/settings/backend.astro` - Settings page
3053
-
3054
- **Test Files:**
3055
-
3056
- - `backend/convex/lib/encryption.test.ts` - Encryption tests
3057
- - `backend/convex/services/config/switcher.test.ts` - Switch tests
3058
- - `frontend/tests/e2e/provider-switch.test.ts` - E2E tests
3059
- - `backend/convex/benchmarks/provider-switch.bench.ts` - Benchmarks
3060
-
3061
- **Documentation Files:**
3062
-
3063
- - `/Users/toc/Server/ONE/one/things/features/2-2-config-system.md` - This file
3064
- - `/Users/toc/Server/ONE/one/things/features/2-2-config-env-vars.md` - Env vars
3065
- - `/Users/toc/Server/ONE/one/things/features/2-2-config-guide.md` - User guide
3066
- - `/Users/toc/Server/ONE/one/things/features/2-2-troubleshooting.md` - Troubleshooting
3067
- - `/Users/toc/Server/ONE/one/things/features/2-2-api-reference.md` - API docs
3068
- - `/Users/toc/Server/ONE/one/things/features/2-2-migration-guide.md` - Migration
3069
- - `/Users/toc/Server/ONE/one/things/features/2-2-provider-comparison.md` - Comparison
3070
-
3071
- **Related Features:**
3072
-
3073
- - Feature 2-1: DataProvider Interface (dependency)
3074
- - Feature 2-3: Convex Implementation (uses config system)
3075
- - Feature 2-4: WordPress Implementation (uses config system)
3076
-
3077
- ---
3078
-
3079
- **Status:** Complete Specification (Ready for Implementation)
3080
- **Created:** 2025-10-13
3081
- **Validated By:** Backend Specialist Agent
3082
- **Blocks:** All Feature 2-x implementations depend on this
3083
- **Word Count:** ~8,500 words
3084
- **Code Examples:** 50+ complete implementations
3085
-
3086
- ---
3087
-
3088
- ## Appendix: Example Complete Flow
3089
-
3090
- ### Example: Org Owner Switches to WordPress
3091
-
3092
- **Step 1: User visits settings**
3093
-
3094
- ```typescript
3095
- // GET /org/acme/settings/backend
3096
- // User sees: "Current Provider: Convex (Online)"
3097
- ```
3098
-
3099
- **Step 2: User selects WordPress**
3100
-
3101
- ```typescript
3102
- // Form shows WordPress-specific fields
3103
- <Input placeholder="WordPress URL" />
3104
- <Input placeholder="Username" />
3105
- <Input type="password" placeholder="Application Password" />
3106
- ```
3107
-
3108
- **Step 3: User tests connection**
3109
-
3110
- ```typescript
3111
- // POST /api/config/test
3112
- const result = await testConnection({
3113
- type: "wordpress",
3114
- baseUrl: "https://example.com/wp-json",
3115
- username: "admin",
3116
- applicationPassword: "xxxx xxxx xxxx xxxx",
3117
- });
3118
- // Response: { success: true, responseTime: 156 }
3119
- ```
3120
-
3121
- **Step 4: User saves configuration**
3122
-
3123
- ```typescript
3124
- // POST /api/config/save
3125
- const { switchDuration, configId } = await saveProviderConfig({
3126
- orgId: "org_acme",
3127
- config: {
3128
- type: "wordpress",
3129
- baseUrl: "https://example.com/wp-json",
3130
- username: "admin",
3131
- applicationPassword: "xxxx xxxx xxxx xxxx",
3132
- },
3133
- });
3134
- // Response: { switchDuration: 14230, configId: "conn_xyz" }
3135
- ```
3136
-
3137
- **Step 5: Backend processes switch**
3138
-
3139
- ```typescript
3140
- // 1. Validate config with Zod schema
3141
- const validated = WordPressConfigSchema.parse(config);
3142
-
3143
- // 2. Test connection
3144
- await testConnection(validated); // 2.1s
3145
-
3146
- // 3. Encrypt credentials
3147
- const encrypted = await encrypt(validated.applicationPassword, encryptionKey); // 0.3s
3148
-
3149
- // 4. Create external_connection entity
3150
- const configId = await db.insert("entities", {
3151
- type: "external_connection",
3152
- name: "WordPress Production",
3153
- properties: {
3154
- platform: "wordpress",
3155
- connectionType: "backend_provider",
3156
- baseUrl: validated.baseUrl,
3157
- config: {
3158
- username: validated.username,
3159
- applicationPassword: encrypted.ciphertext,
3160
- },
3161
- apiKeyIv: encrypted.iv,
3162
- apiKeyAuthTag: encrypted.authTag,
3163
- status: "active",
3164
- },
3165
- status: "active",
3166
- createdAt: Date.now(),
3167
- updatedAt: Date.now(),
3168
- }); // 0.5s
3169
-
3170
- // 5. Update organization
3171
- await db.patch(orgId, {
3172
- properties: {
3173
- ...org.properties,
3174
- backendProvider: {
3175
- type: "wordpress",
3176
- configId,
3177
- switchedAt: Date.now(),
3178
- previousProvider: "convex",
3179
- },
3180
- },
3181
- updatedAt: Date.now(),
3182
- }); // 0.3s
3183
-
3184
- // 6. Create connection
3185
- await db.insert("connections", {
3186
- fromEntityId: orgId,
3187
- toEntityId: configId,
3188
- relationshipType: "configured_by",
3189
- metadata: {
3190
- configType: "backend_provider",
3191
- activeProvider: true,
3192
- },
3193
- validFrom: Date.now(),
3194
- createdAt: Date.now(),
3195
- }); // 0.2s
3196
-
3197
- // 7. Clear cache
3198
- clearCachedProvider(orgId); // 0.1s
3199
-
3200
- // 8. Initialize new provider
3201
- const provider = await initializeProvider(orgId, validated); // 4.2s
3202
-
3203
- // 9. Log event
3204
- await db.insert("events", {
3205
- type: "settings_updated",
3206
- actorId: userId,
3207
- targetId: orgId,
3208
- timestamp: Date.now(),
3209
- metadata: {
3210
- settingType: "backend_provider",
3211
- fromProvider: "convex",
3212
- toProvider: "wordpress",
3213
- configId,
3214
- switchDuration: 14230,
3215
- },
3216
- }); // 0.2s
3217
-
3218
- // Total: 14.2s
3219
- ```
3220
-
3221
- **Step 6: User sees success**
3222
-
3223
- ```typescript
3224
- // UI updates: "Current Provider: WordPress (Online)"
3225
- // Rollback button appears: "Rollback to Convex"
3226
- ```
3227
-
3228
- **Step 7: Next query uses WordPress**
3229
-
3230
- ```typescript
3231
- // GET /api/entities?type=creator
3232
- const provider = await resolveProviderForOrg("org_acme");
3233
- // Returns: WordPressProvider instance
3234
- const creators = await provider.query("entities", { type: "creator" });
3235
- // Fetches from WordPress REST API: GET /wp-json/wp/v2/users
3236
- ```
3237
-
3238
- **Result:** Seamless switch from Convex to WordPress in ~14 seconds with zero downtime after switch completes.
3239
-
3240
- ---
3241
-
3242
- **END OF FEATURE 2-2 SPECIFICATION**