oneie 2.0.1 → 2.0.3

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 (406) hide show
  1. package/AGENTS.md +245 -0
  2. package/CLAUDE.md +534 -0
  3. package/README.md +61 -4
  4. package/one/.obsidian/app.json +1 -0
  5. package/one/.obsidian/appearance.json +1 -0
  6. package/one/.obsidian/core-plugins.json +33 -0
  7. package/one/.obsidian/workspace.json +211 -0
  8. package/one/connections/a2a.md +551 -0
  9. package/one/connections/acp.md +761 -0
  10. package/one/connections/acps.md +731 -0
  11. package/one/connections/agui.md +767 -0
  12. package/one/connections/any-backend.md +1702 -0
  13. package/one/connections/ap2.md +998 -0
  14. package/one/connections/api-docs.md +1891 -0
  15. package/one/connections/api.md +2190 -0
  16. package/one/connections/architecture-diagram.md +94 -0
  17. package/one/connections/communications.md +449 -0
  18. package/one/connections/connections.md +339 -0
  19. package/one/connections/cryptonetworks.md +781 -0
  20. package/one/connections/documentation.md +1120 -0
  21. package/one/connections/effect.md +279 -0
  22. package/one/connections/elizaos.md +1290 -0
  23. package/one/connections/inference.md +58 -0
  24. package/one/connections/kyc.md +632 -0
  25. package/one/connections/mcp.md +842 -0
  26. package/one/connections/membership.md +1152 -0
  27. package/one/connections/middleware.md +1067 -0
  28. package/one/connections/multitenant.md +1341 -0
  29. package/one/connections/n8n.md +1015 -0
  30. package/one/connections/patterns.md +89 -0
  31. package/one/connections/protocols.md +279 -0
  32. package/one/connections/relationships.md +107 -0
  33. package/one/connections/schema.md +587 -0
  34. package/one/connections/service-layer.md +550 -0
  35. package/one/connections/structure.md +0 -0
  36. package/one/connections/vectors.md +207 -0
  37. package/one/connections/wordpress.md +1302 -0
  38. package/one/connections/workflow-copy.md +905 -0
  39. package/one/connections/workflow-examples.md +741 -0
  40. package/one/connections/workflow.md +905 -0
  41. package/one/connections/workflows/delegation.md +885 -0
  42. package/one/connections/workflows/frontend.md +1037 -0
  43. package/one/connections/workflows/strategy.md +903 -0
  44. package/one/connections/workflows/tasks.md +698 -0
  45. package/one/connections/x402.md +1249 -0
  46. package/one/events/events.md +545 -0
  47. package/one/knowledge/ai-platform.md +305 -0
  48. package/one/knowledge/architecture-diagram.md +94 -0
  49. package/one/knowledge/architecture-frontend.md +930 -0
  50. package/one/knowledge/architecture.md +2077 -0
  51. package/one/knowledge/crypto.md +960 -0
  52. package/one/knowledge/dsl.md +1660 -0
  53. package/one/knowledge/files.md +2471 -0
  54. package/one/knowledge/frontend.md +1038 -0
  55. package/one/knowledge/hono.md +2109 -0
  56. package/one/knowledge/implementation-examples.md +2536 -0
  57. package/one/knowledge/inference-score.md +159 -0
  58. package/one/knowledge/knowledge.md +642 -0
  59. package/one/knowledge/language.md +980 -0
  60. package/one/knowledge/lessons-learned.md +70 -0
  61. package/one/knowledge/ontology-6-dimensions.md +0 -0
  62. package/one/knowledge/ontology-documentation.md +356 -0
  63. package/one/knowledge/ontology-engineering-specification.md +1292 -0
  64. package/one/knowledge/ontology-engineering.md +1652 -0
  65. package/one/knowledge/ontology-frontend-copy-2.md +1492 -0
  66. package/one/knowledge/ontology-frontend-copy.md +753 -0
  67. package/one/knowledge/ontology-frontend-specifications.md +2188 -0
  68. package/one/knowledge/ontology-frontend.md +2427 -0
  69. package/one/knowledge/ontology-minimal.yaml +299 -0
  70. package/one/knowledge/ontology.md +2819 -0
  71. package/one/knowledge/ontology.yaml +1165 -0
  72. package/one/knowledge/patterns/backend/convex-mutation-pattern.md +100 -0
  73. package/one/knowledge/patterns/backend/convex-query-pattern.md +88 -0
  74. package/one/knowledge/patterns/backend/mutation-template.md +231 -0
  75. package/one/knowledge/patterns/backend/query-template.md +267 -0
  76. package/one/knowledge/patterns/backend/service-template.md +237 -0
  77. package/one/knowledge/patterns/design/component-architecture.md +399 -0
  78. package/one/knowledge/patterns/design/test-driven-design-pattern.md +162 -0
  79. package/one/knowledge/patterns/design/wireframe-template.md +216 -0
  80. package/one/knowledge/patterns/frontend/component-template.md +195 -0
  81. package/one/knowledge/patterns/frontend/form-template.md +276 -0
  82. package/one/knowledge/patterns/frontend/page-template.md +178 -0
  83. package/one/knowledge/patterns/frontend/react-component-pattern.md +128 -0
  84. package/one/knowledge/patterns/test/acceptance-criteria-template.md +378 -0
  85. package/one/knowledge/patterns/test/technical-test-template.md +544 -0
  86. package/one/knowledge/patterns/test/test-driven-pattern.md +140 -0
  87. package/one/knowledge/patterns/test/user-flow-template.md +254 -0
  88. package/one/knowledge/quality-loop.md +401 -0
  89. package/one/knowledge/readme.md +131 -0
  90. package/one/knowledge/rules.md +626 -0
  91. package/one/knowledge/score.md +67 -0
  92. package/one/knowledge/specifications.md +855 -0
  93. package/one/knowledge/tags.md +130 -0
  94. package/one/organisation/one.md +599 -0
  95. package/one/organisation/organisation.md +438 -0
  96. package/one/organisation/revenue.md +673 -0
  97. package/one/organisation/strategy.md +869 -0
  98. package/one/organisation/vision.md +98 -0
  99. package/one/people/anthony-o-connell.md +440 -0
  100. package/one/people/people.md +567 -0
  101. package/one/repomix-output.md +92634 -0
  102. package/one/things/agentkit.md +349 -0
  103. package/one/things/agents/agent-backend.md +1401 -0
  104. package/one/things/agents/agent-builder.md +955 -0
  105. package/one/things/agents/agent-clean.md +709 -0
  106. package/one/things/agents/agent-clone.md +1341 -0
  107. package/one/things/agents/agent-designer.md +2177 -0
  108. package/one/things/agents/agent-director.md +1508 -0
  109. package/one/things/agents/agent-documenter.md +1049 -0
  110. package/one/things/agents/agent-frontend.md +1119 -0
  111. package/one/things/agents/agent-integrator.md +1192 -0
  112. package/one/things/agents/agent-problem-solver.md +1379 -0
  113. package/one/things/agents/agent-quality.md +1353 -0
  114. package/one/things/agents/agent-sales.md +986 -0
  115. package/one/things/cascade/cascade.yaml +464 -0
  116. package/one/things/cascade/docs/examples/1-1-agent-prompts/design.md +470 -0
  117. package/one/things/cascade/docs/examples/1-1-agent-prompts/tests.md +264 -0
  118. package/one/things/cascade/docs/examples/1-1-agent-prompts.md +486 -0
  119. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/design.md +497 -0
  120. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/tests.md +227 -0
  121. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator.md +516 -0
  122. package/one/things/cascade/docs/examples/1-3-event-coordination/design.md +544 -0
  123. package/one/things/cascade/docs/examples/1-3-event-coordination/tests.md +223 -0
  124. package/one/things/cascade/docs/examples/1-3-event-coordination.md +508 -0
  125. package/one/things/cascade/docs/examples/1-4-knowledge-management/design.md +609 -0
  126. package/one/things/cascade/docs/examples/1-4-knowledge-management/tests.md +195 -0
  127. package/one/things/cascade/docs/examples/1-4-knowledge-management.md +577 -0
  128. package/one/things/cascade/docs/examples/1-5-quality-loops/design.md +797 -0
  129. package/one/things/cascade/docs/examples/1-5-quality-loops/tests.md +212 -0
  130. package/one/things/cascade/docs/examples/1-5-quality-loops.md +641 -0
  131. package/one/things/cascade/docs/examples/1-6-numbering-structure/design.md +610 -0
  132. package/one/things/cascade/docs/examples/1-6-numbering-structure/tests.md +213 -0
  133. package/one/things/cascade/docs/examples/1-6-numbering-structure.md +575 -0
  134. package/one/things/cascade/docs/examples/readme.md +222 -0
  135. package/one/things/cascade/docs/getting-started.md +515 -0
  136. package/one/things/cascade/docs/workflow.md +1372 -0
  137. package/one/things/cascade/readme.md +336 -0
  138. package/one/things/cascade/templates/feature-template.md +267 -0
  139. package/one/things/claude/agents/advocacy-activation-manager.md +685 -0
  140. package/one/things/claude/agents/advocacy-campaign-designer.md +663 -0
  141. package/one/things/claude/agents/analyst.md +483 -0
  142. package/one/things/claude/agents/architect.md +480 -0
  143. package/one/things/claude/agents/brand-identity-specialist.md +513 -0
  144. package/one/things/claude/agents/bstp-token-strategist.md +667 -0
  145. package/one/things/claude/agents/builder-repo.md +489 -0
  146. package/one/things/claude/agents/bullstamp-community-builder.md +574 -0
  147. package/one/things/claude/agents/bullstamp-marketing-orchestrator.md +506 -0
  148. package/one/things/claude/agents/bulltilt-platform-growth.md +567 -0
  149. package/one/things/claude/agents/company-bullstamp-character.md +587 -0
  150. package/one/things/claude/agents/company-bullstamp-community.md +292 -0
  151. package/one/things/claude/agents/company-bullstamp-marketing.md +292 -0
  152. package/one/things/claude/agents/company-bullstamp-token.md +292 -0
  153. package/one/things/claude/agents/company-bulltilt-growth.md +292 -0
  154. package/one/things/claude/agents/content-bibliography-formatter.md +381 -0
  155. package/one/things/claude/agents/content-calendar-planner.md +448 -0
  156. package/one/things/claude/agents/content-chapter-formatter.md +488 -0
  157. package/one/things/claude/agents/content-formatter.md +546 -0
  158. package/one/things/claude/agents/content-hook-specialist.md +462 -0
  159. package/one/things/claude/agents/content-image-formatter.md +535 -0
  160. package/one/things/claude/agents/content-introduction-formatter.md +485 -0
  161. package/one/things/claude/agents/content-multiplication-engine.md +556 -0
  162. package/one/things/claude/agents/content-playbook-writer.md +448 -0
  163. package/one/things/claude/agents/content-team-manager.md +622 -0
  164. package/one/things/claude/agents/content-toc-formatter.md +522 -0
  165. package/one/things/claude/agents/convex-backend-specialist.md +2561 -0
  166. package/one/things/claude/agents/core-manager.md +582 -0
  167. package/one/things/claude/agents/core-master.md +403 -0
  168. package/one/things/claude/agents/cross-functional-manager.md +471 -0
  169. package/one/things/claude/agents/crypto-airdrop-strategist.md +602 -0
  170. package/one/things/claude/agents/crypto-analytics-educator.md +553 -0
  171. package/one/things/claude/agents/crypto-architecture-specialist.md +466 -0
  172. package/one/things/claude/agents/crypto-community-analyst.md +298 -0
  173. package/one/things/claude/agents/crypto-community-psychologist.md +509 -0
  174. package/one/things/claude/agents/crypto-dex-optimization-expert.md +538 -0
  175. package/one/things/claude/agents/crypto-dex-optimizer.md +292 -0
  176. package/one/things/claude/agents/crypto-diamond-formation-specialist.md +513 -0
  177. package/one/things/claude/agents/crypto-diamond-hands.md +292 -0
  178. package/one/things/claude/agents/crypto-ecosystem-expansion-manager.md +554 -0
  179. package/one/things/claude/agents/crypto-engagement-specialist.md +540 -0
  180. package/one/things/claude/agents/crypto-market-researcher.md +292 -0
  181. package/one/things/claude/agents/crypto-marketing-orchestrator.md +523 -0
  182. package/one/things/claude/agents/crypto-network-effect-amplifier.md +569 -0
  183. package/one/things/claude/agents/crypto-optimization-analyst.md +554 -0
  184. package/one/things/claude/agents/crypto-strategic-synthesizer.md +517 -0
  185. package/one/things/claude/agents/crypto-team-manager.md +387 -0
  186. package/one/things/claude/agents/crypto-token-analyst.md +278 -0
  187. package/one/things/claude/agents/crypto-viral-content-creator.md +546 -0
  188. package/one/things/claude/agents/crypto-wallet-identification-expert.md +517 -0
  189. package/one/things/claude/agents/crypto-wallet-identifier.md +292 -0
  190. package/one/things/claude/agents/customer-journey-designer.md +481 -0
  191. package/one/things/claude/agents/customer-success-manager.md +581 -0
  192. package/one/things/claude/agents/dev.md +413 -0
  193. package/one/things/claude/agents/documenter.md +546 -0
  194. package/one/things/claude/agents/elevate-marketing-orchestrator.md +410 -0
  195. package/one/things/claude/agents/engagement-specialist.md +509 -0
  196. package/one/things/claude/agents/engineering-architect.md +387 -0
  197. package/one/things/claude/agents/engineering-business-analyst.md +537 -0
  198. package/one/things/claude/agents/engineering-developer.md +387 -0
  199. package/one/things/claude/agents/engineering-director.md +282 -0
  200. package/one/things/claude/agents/engineering-ingestor.md +649 -0
  201. package/one/things/claude/agents/engineering-product-manager.md +537 -0
  202. package/one/things/claude/agents/engineering-product-owner.md +537 -0
  203. package/one/things/claude/agents/engineering-project-coordinator.md +537 -0
  204. package/one/things/claude/agents/engineering-quality-assurance.md +393 -0
  205. package/one/things/claude/agents/engineering-team-manager.md +512 -0
  206. package/one/things/claude/agents/engineering-user-experience.md +387 -0
  207. package/one/things/claude/agents/framework-elevate-manager.md +294 -0
  208. package/one/things/claude/agents/improver.md +763 -0
  209. package/one/things/claude/agents/intelligence-team-manager.md +385 -0
  210. package/one/things/claude/agents/lead-capture-expert.md +466 -0
  211. package/one/things/claude/agents/lead-magnet-creator.md +453 -0
  212. package/one/things/claude/agents/market-research-analyst.md +412 -0
  213. package/one/things/claude/agents/marketing-brand-identity.md +314 -0
  214. package/one/things/claude/agents/marketing-content-hooks.md +450 -0
  215. package/one/things/claude/agents/marketing-content-multiplier.md +326 -0
  216. package/one/things/claude/agents/marketing-content-poster.md +361 -0
  217. package/one/things/claude/agents/marketing-customer-journey.md +326 -0
  218. package/one/things/claude/agents/marketing-director.md +397 -0
  219. package/one/things/claude/agents/marketing-engagement.md +326 -0
  220. package/one/things/claude/agents/marketing-lead-capture.md +326 -0
  221. package/one/things/claude/agents/marketing-lead-magnet.md +326 -0
  222. package/one/things/claude/agents/marketing-network-effects.md +326 -0
  223. package/one/things/claude/agents/marketing-nurture-campaigns.md +326 -0
  224. package/one/things/claude/agents/marketing-share-optimizer.md +326 -0
  225. package/one/things/claude/agents/marketing-team-manager.md +446 -0
  226. package/one/things/claude/agents/marketing-viral-growth.md +201 -0
  227. package/one/things/claude/agents/mission-commander.md +373 -0
  228. package/one/things/claude/agents/network-effect-analyst.md +587 -0
  229. package/one/things/claude/agents/nextjs-15-specialist.md +1547 -0
  230. package/one/things/claude/agents/npx.md +890 -0
  231. package/one/things/claude/agents/nurture-campaign-manager.md +531 -0
  232. package/one/things/claude/agents/one-master.md +355 -0
  233. package/one/things/claude/agents/one-orchestrator.md +315 -0
  234. package/one/things/claude/agents/one.md +601 -0
  235. package/one/things/claude/agents/playbook-generator.md +503 -0
  236. package/one/things/claude/agents/pm.md +326 -0
  237. package/one/things/claude/agents/po.md +345 -0
  238. package/one/things/claude/agents/qa.md +336 -0
  239. package/one/things/claude/agents/research-foundation-analyst.md +307 -0
  240. package/one/things/claude/agents/research-intelligence-gatherer.md +408 -0
  241. package/one/things/claude/agents/research-market-analyst.md +307 -0
  242. package/one/things/claude/agents/research-team-manager.md +482 -0
  243. package/one/things/claude/agents/sales-environment-optimizer.md +494 -0
  244. package/one/things/claude/agents/sales-team-manager.md +400 -0
  245. package/one/things/claude/agents/sales-upsell-strategist.md +307 -0
  246. package/one/things/claude/agents/service-advocacy-campaigns.md +307 -0
  247. package/one/things/claude/agents/service-advocacy-manager.md +307 -0
  248. package/one/things/claude/agents/service-success-manager.md +307 -0
  249. package/one/things/claude/agents/service-team-manager.md +400 -0
  250. package/one/things/claude/agents/shadcn-ui-design-system-specialist.md +2302 -0
  251. package/one/things/claude/agents/share-optimization-specialist.md +551 -0
  252. package/one/things/claude/agents/sm.md +327 -0
  253. package/one/things/claude/agents/story-teller.md +473 -0
  254. package/one/things/claude/agents/task-master.md +596 -0
  255. package/one/things/claude/agents/tauri-cross-platform-specialist.md +1827 -0
  256. package/one/things/claude/agents/tester.md +556 -0
  257. package/one/things/claude/agents/the-bull-character-manager.md +580 -0
  258. package/one/things/claude/agents/tools-playbook-generator.md +489 -0
  259. package/one/things/claude/agents/turbo-repo-builder.md +316 -0
  260. package/one/things/claude/agents/upsell-strategist.md +480 -0
  261. package/one/things/claude/agents/ux-expert.md +335 -0
  262. package/one/things/claude/agents/viral-growth-orchestrator.md +497 -0
  263. package/one/things/claude/claude-code-hooks-development.json +21 -0
  264. package/one/things/claude/claude-code-hooks-production.json +21 -0
  265. package/one/things/claude/claude-code-hooks.json +25 -0
  266. package/one/things/claude/commands/agent.md +104 -0
  267. package/one/things/claude/commands/cascade-status.md +128 -0
  268. package/one/things/claude/commands/ingest.md +290 -0
  269. package/one/things/claude/commands/ingestor.md +136 -0
  270. package/one/things/claude/commands/mission.md +83 -0
  271. package/one/things/claude/commands/npx.md +133 -0
  272. package/one/things/claude/commands/one.md +440 -0
  273. package/one/things/claude/commands/quality-check.md +204 -0
  274. package/one/things/claude/commands/smart-route.md +220 -0
  275. package/one/things/claude/commands/start.md +121 -0
  276. package/one/things/claude/commands/story.md +83 -0
  277. package/one/things/claude/commands/task.md +173 -0
  278. package/one/things/claude/hook-bypass.json +32 -0
  279. package/one/things/claude/hooks/agent-hook-config.json +427 -0
  280. package/one/things/claude/hooks/agent-hook-manager.js +525 -0
  281. package/one/things/claude/hooks/agent-load-balancer.js +271 -0
  282. package/one/things/claude/hooks/agent-request-interceptor.js +70 -0
  283. package/one/things/claude/hooks/build-hook.sh +156 -0
  284. package/one/things/claude/hooks/cascade-feedback.js +297 -0
  285. package/one/things/claude/hooks/cascade-integration-hooks.js +648 -0
  286. package/one/things/claude/hooks/cleanup-hook.sh +201 -0
  287. package/one/things/claude/hooks/continuous-improvement-monitor.js +510 -0
  288. package/one/things/claude/hooks/file-organization-engine.js +427 -0
  289. package/one/things/claude/hooks/file-organization-hook.sh +80 -0
  290. package/one/things/claude/hooks/file-organization-monitor.js +269 -0
  291. package/one/things/claude/hooks/format-hook.sh +43 -0
  292. package/one/things/claude/hooks/hook-bypass.sh +293 -0
  293. package/one/things/claude/hooks/hook-config-manager.js +202 -0
  294. package/one/things/claude/hooks/hook-debouncer.sh +62 -0
  295. package/one/things/claude/hooks/hook-logger.sh +89 -0
  296. package/one/things/claude/hooks/hook-orchestrator.js +662 -0
  297. package/one/things/claude/hooks/hook-performance-report.js +120 -0
  298. package/one/things/claude/hooks/lint-hook.sh +140 -0
  299. package/one/things/claude/hooks/mcp-cascade-integration.js +816 -0
  300. package/one/things/claude/hooks/memory-optimizer.js +510 -0
  301. package/one/things/claude/hooks/notification-hook.sh +204 -0
  302. package/one/things/claude/hooks/ontology-compliance.js +394 -0
  303. package/one/things/claude/hooks/ontology-hook-manager.js +316 -0
  304. package/one/things/claude/hooks/ontology-validation-engine.js +317 -0
  305. package/one/things/claude/hooks/ontology-validation-hook.sh +86 -0
  306. package/one/things/claude/hooks/performance-metrics.json +25 -0
  307. package/one/things/claude/hooks/performance-monitoring-hook.js +422 -0
  308. package/one/things/claude/hooks/quality-scoring-engine.js +834 -0
  309. package/one/things/claude/hooks/security-hook.sh +256 -0
  310. package/one/things/claude/hooks/simple-load-balancer.js +238 -0
  311. package/one/things/claude/hooks/startup-optimizer.js +625 -0
  312. package/one/things/claude/hooks/story-scoring-system.js +445 -0
  313. package/one/things/claude/hooks/story-validation-engine.js +473 -0
  314. package/one/things/claude/hooks/story-validation-hook-enhanced.sh +210 -0
  315. package/one/things/claude/hooks/story-validation-hook.sh +145 -0
  316. package/one/things/claude/hooks/structure-synchronizer.js +194 -0
  317. package/one/things/claude/hooks/sub-agent-output-validator.js +647 -0
  318. package/one/things/claude/hooks/sub-agent-validation-hook.js +343 -0
  319. package/one/things/claude/hooks/test-hook.sh +145 -0
  320. package/one/things/claude/hooks/test-story-validation.sh +170 -0
  321. package/one/things/claude/hooks/trinity-validation-system.js +392 -0
  322. package/one/things/claude/settings-local.json +86 -0
  323. package/one/things/cli-code.md +652 -0
  324. package/one/things/cli-compiler-code.md +652 -0
  325. package/one/things/cli.md +1045 -0
  326. package/one/things/components/card-shadcn.md +929 -0
  327. package/one/things/components/card.md +1050 -0
  328. package/one/things/components.md +1669 -0
  329. package/one/things/componets.md +4 -0
  330. package/one/things/copilotkit.md +1559 -0
  331. package/one/things/creator-diagram.md +166 -0
  332. package/one/things/examples/children/lemonade-stand.md +366 -0
  333. package/one/things/examples/enterprise/crm-saas.md +1429 -0
  334. package/one/things/features/1-1-agent-prompts/design.md +470 -0
  335. package/one/things/features/1-1-agent-prompts/tests.md +264 -0
  336. package/one/things/features/1-1-agent-prompts.md +486 -0
  337. package/one/things/features/1-2-yaml-orchestrator/design.md +497 -0
  338. package/one/things/features/1-2-yaml-orchestrator/tests.md +227 -0
  339. package/one/things/features/1-2-yaml-orchestrator.md +516 -0
  340. package/one/things/features/1-3-event-coordination/design.md +544 -0
  341. package/one/things/features/1-3-event-coordination/tests.md +223 -0
  342. package/one/things/features/1-3-event-coordination.md +508 -0
  343. package/one/things/features/1-4-knowledge-management/design.md +609 -0
  344. package/one/things/features/1-4-knowledge-management/tests.md +195 -0
  345. package/one/things/features/1-4-knowledge-management.md +577 -0
  346. package/one/things/features/1-5-quality-loops/design.md +797 -0
  347. package/one/things/features/1-5-quality-loops/tests.md +212 -0
  348. package/one/things/features/1-5-quality-loops.md +641 -0
  349. package/one/things/features/1-6-numbering-structure/design.md +610 -0
  350. package/one/things/features/1-6-numbering-structure/tests.md +213 -0
  351. package/one/things/features/1-6-numbering-structure.md +575 -0
  352. package/one/things/features/2-cli.md +1235 -0
  353. package/one/things/features/use-one-backend.md +1180 -0
  354. package/one/things/ideas/1-create-workflow.md +189 -0
  355. package/one/things/plans/1-create-workflow-status.md +555 -0
  356. package/one/things/plans/1-create-workflow.md +713 -0
  357. package/one/things/plans/app.md +761 -0
  358. package/one/things/plans/better-auth-any-backend-revised.md +1065 -0
  359. package/one/things/plans/better-auth-any-backend.md +1852 -0
  360. package/one/things/plans/better-auth-available-features.md +235 -0
  361. package/one/things/plans/big-plan.md +38 -0
  362. package/one/things/plans/convex-better-auth.md +1109 -0
  363. package/one/things/plans/convex-on-off.md +389 -0
  364. package/one/things/plans/desktop.md +1121 -0
  365. package/one/things/plans/effect-components.md +1669 -0
  366. package/one/things/plans/effect.md +973 -0
  367. package/one/things/plans/email.md +953 -0
  368. package/one/things/plans/enhance-auth.md +1669 -0
  369. package/one/things/plans/install-components.md +198 -0
  370. package/one/things/plans/landing.md +728 -0
  371. package/one/things/plans/layout.md +205 -0
  372. package/one/things/plans/mail-backend.md +1308 -0
  373. package/one/things/plans/mail.md +2624 -0
  374. package/one/things/plans/next-features.md +83 -0
  375. package/one/things/plans/one.md +658 -0
  376. package/one/things/plans/ontology-6-dimensions.md +2216 -0
  377. package/one/things/plans/ontology-driven-strategy.md +866 -0
  378. package/one/things/plans/ontology-ui-approach.md +357 -0
  379. package/one/things/plans/open-agent.md +785 -0
  380. package/one/things/plans/performace.md +90 -0
  381. package/one/things/plans/releases.md +809 -0
  382. package/one/things/plans/repos.md +76 -0
  383. package/one/things/plans/separate-copy-2.md +1293 -0
  384. package/one/things/plans/separate-copy-3.md +2458 -0
  385. package/one/things/plans/separate-copy.md +1293 -0
  386. package/one/things/plans/separate.md +1983 -0
  387. package/one/things/plans/shadcn-integration-summary.md +450 -0
  388. package/one/things/plans/sidebar.md +172 -0
  389. package/one/things/plans/small-fixes.md +5 -0
  390. package/one/things/plans/test-backend-connection.md +476 -0
  391. package/one/things/plans/workflow-files.md +1196 -0
  392. package/one/things/plans/workflow.md +1372 -0
  393. package/one/things/products/cascade-landing-page.md +737 -0
  394. package/one/things/products/cascade.md +1518 -0
  395. package/one/things/products/context-engineering.md +1427 -0
  396. package/one/things/products/onthology.md +0 -0
  397. package/one/things/products/ontology-ui-shadcn.md +1280 -0
  398. package/one/things/products/ontology-ui.md +1387 -0
  399. package/one/things/products/ontology.md +717 -0
  400. package/one/things/products/sdk.md +557 -0
  401. package/one/things/promptkit.md +903 -0
  402. package/one/things/service-providers-new.md +982 -0
  403. package/one/things/service-providers.md +1092 -0
  404. package/one/things/things.md +349 -0
  405. package/one/things/todo.md +1248 -0
  406. package/package.json +5 -2
@@ -0,0 +1,2819 @@
1
+ # ONE Platform - Ontology Specification
2
+
3
+ **Version:** 2.0.0 (6-Dimension Architecture)
4
+ **Status:** Complete - Reality-Aware Architecture
5
+ **Design Principle:** This ontology models reality in six dimensions. All protocols map TO this ontology via metadata.
6
+ ## Structure
7
+
8
+ This ontology is organized into 6 dimension files:
9
+
10
+ 1. **[organisation.md](./organisation.md)** - Multi-tenant isolation & ownership
11
+ 2. **[people.md](./people.md)** - Authorization, governance, & user customization
12
+ 3. **[things.md](./things.md)** - 66 entity types (what exists)
13
+ 4. **[connections.md](./connections.md)** - 25 relationship types (how they relate)
14
+ 5. **[events.md](./events.md)** - 67 event types (what happened)
15
+ 6. **[knowledge.md](./knowledge.md)** - Vectors, embeddings, RAG (what it means)
16
+
17
+ **This document (Ontology.md)** contains the complete technical specification. The consolidated files above provide focused summaries and patterns.
18
+
19
+ ## The 6-Dimension Reality Model
20
+
21
+ Every single thing in ONE platform exists within one of these 6 dimensions:
22
+
23
+ ```
24
+ ┌──────────────────────────────────────────────────────────────┐
25
+ │ 1. ORGANIZATIONS │
26
+ │ Multi-tenant isolation boundary - who owns what at org level │
27
+ └──────────────────────────────────────────────────────────────┘
28
+ ↓
29
+ ┌──────────────────────────────────────────────────────────────┐
30
+ │ 2. PEOPLE │
31
+ │ Authorization & governance - platform owner, org owners │
32
+ └──────────────────────────────────────────────────────────────┘
33
+ ↓
34
+ ┌──────────────────────────────────────────────────────────────┐
35
+ │ 3. THINGS │
36
+ │ Every "thing" - users, agents, content, tokens, courses │
37
+ └──────────────────────────────────────────────────────────────┘
38
+ ↓
39
+ ┌──────────────────────────────────────────────────────────────┐
40
+ │ 4. CONNECTIONS │
41
+ │ Every relationship - owns, follows, taught_by, powers │
42
+ └──────────────────────────────────────────────────────────────┘
43
+ ↓
44
+ ┌──────────────────────────────────────────────────────────────┐
45
+ │ 5. EVENTS │
46
+ │ Every action - purchased, created, viewed, completed │
47
+ └──────────────────────────────────────────────────────────────┘
48
+ ↓
49
+ ┌──────────────────────────────────────────────────────────────┐
50
+ │ 6. KNOWLEDGE │
51
+ │ Labels + chunks + vectors powering RAG & search │
52
+ └──────────────────────────────────────────────────────────────┘
53
+ ```
54
+
55
+ **Golden Rule:** If you can't map your feature to these 6 dimensions, you're thinking about it wrong.
56
+
57
+ **Simplicity:** ONE is six dimensions — organizations partition, people authorize, things exist, connections relate, events record, and knowledge understands. Everything composes from these building blocks.
58
+
59
+ ---
60
+
61
+ ## ORGANIZATIONS: The Isolation Boundary
62
+
63
+ Purpose: Partition the system for multi-tenant scale. Every organization owns its own graph of things, connections, events, and knowledge.
64
+
65
+ ### Organization Structure
66
+
67
+ ```typescript
68
+ {
69
+ _id: Id<'organizations'>,
70
+ name: string,
71
+ slug: string, // URL-friendly identifier
72
+ domain?: string, // Custom domain
73
+ status: 'active' | 'suspended' | 'trial' | 'cancelled',
74
+ plan: 'starter' | 'pro' | 'enterprise',
75
+
76
+ limits: {
77
+ users: number,
78
+ storage: number, // GB
79
+ apiCalls: number,
80
+ inference: number, // Monthly LLM calls
81
+ },
82
+
83
+ usage: {
84
+ users: number,
85
+ storage: number,
86
+ apiCalls: number,
87
+ inference: number,
88
+ },
89
+
90
+ billing: {
91
+ customerId?: string, // Stripe customer
92
+ subscriptionId?: string,
93
+ },
94
+
95
+ settings: {
96
+ allowSignups: boolean,
97
+ requireEmailVerification: boolean,
98
+ enableTwoFactor: boolean,
99
+ },
100
+
101
+ createdAt: number,
102
+ updatedAt: number,
103
+ trialEndsAt?: number,
104
+ }
105
+ ```
106
+
107
+ ### Why Organizations Matter
108
+
109
+ 1. **Multi-Tenant Isolation:** Each org's data is completely separate
110
+ 2. **Resource Quotas:** Control costs and usage per organization
111
+ 3. **Custom Branding:** Each org can have unique frontend/domain
112
+ 4. **Billing Flexibility:** Per-org subscriptions and revenue sharing
113
+
114
+ ---
115
+
116
+ ## PEOPLE: Authorization & Governance
117
+
118
+ Purpose: Define who can do what. People direct organizations, customize AI agents, and govern access.
119
+
120
+ ### Person Structure
121
+
122
+ ```typescript
123
+ {
124
+ _id: Id<'people'>,
125
+ email: string,
126
+ username: string,
127
+ displayName: string,
128
+
129
+ // CRITICAL: Role determines access level
130
+ role: 'platform_owner' | 'org_owner' | 'org_user' | 'customer',
131
+
132
+ // Organization context
133
+ organizationId?: Id<'organizations'>, // Current/default org
134
+ permissions?: string[],
135
+
136
+ // Profile
137
+ bio?: string,
138
+ avatar?: string,
139
+
140
+ // Multi-tenant tracking
141
+ organizations: Id<'organizations'>[], // All orgs this person belongs to
142
+
143
+ createdAt: number,
144
+ updatedAt: number,
145
+ }
146
+ ```
147
+
148
+ ### Four Roles
149
+
150
+ 1. **Platform Owner** (Anthony)
151
+ - Owns the ONE Platform
152
+ - 100% revenue from platform-level services
153
+ - Can access all organizations (support/debugging)
154
+ - Creates new organizations
155
+
156
+ 2. **Org Owner**
157
+ - Owns/manages one or more organizations
158
+ - Controls users, permissions, billing within org
159
+ - Customizes AI agents and frontend
160
+ - Revenue sharing with platform
161
+
162
+ 3. **Org User**
163
+ - Works within an organization
164
+ - Limited permissions (defined by org owner)
165
+ - Can create content, run agents (within quotas)
166
+
167
+ 4. **Customer**
168
+ - External user consuming content
169
+ - Purchases tokens, enrolls in courses
170
+ - No admin access
171
+
172
+ ### Why People Matter
173
+
174
+ 1. **Authorization:** Every action must have an actor (person)
175
+ 2. **Governance:** Org owners control who can do what
176
+ 3. **Audit Trail:** Events log who did what when
177
+ 4. **Customization:** People teach AI agents their preferences
178
+
179
+ ---
180
+
181
+ ## KNOWLEDGE: Labels, Chunks, and Vectors (RAG)
182
+
183
+ Purpose: unify taxonomy (“tags”) and retrieval‑augmented generation (RAG) under one table. A knowledge item can be a label (former tag), a document wrapper, or a chunk with an embedding.
184
+
185
+ Design principles:
186
+ - Protocol‑agnostic: store protocol details in `metadata`.
187
+ - Many‑to‑many: link knowledge ⇄ things via `thingKnowledge` with optional context metadata.
188
+ - Scalable: consolidated types minimize index fan‑out; embeddings enable semantic search.
189
+
190
+ ### Knowledge Types
191
+
192
+ ```typescript
193
+ type KnowledgeType =
194
+ | 'label' // replaces legacy "tag"; lightweight categorical marker
195
+ | 'document' // wrapper for a source text/blob (pre-chunking)
196
+ | 'chunk' // atomic chunk of text with embedding
197
+ | 'vector_only'; // embedding without stored text (e.g., privacy)
198
+ ```
199
+
200
+ ### Knowledge Structure
201
+
202
+ ```typescript
203
+ {
204
+ _id: Id<'knowledge'>,
205
+ knowledgeType: KnowledgeType,
206
+ // Textual content (optional for label/vector_only)
207
+ text?: string,
208
+ // Embedding for semantic search (optional for label/document)
209
+ embedding?: number[], // Float32 vector; model-dependent dimension
210
+ embeddingModel?: string, // e.g., "text-embedding-3-large"
211
+ embeddingDim?: number,
212
+ // Source linkage
213
+ sourceThingId?: Id<'things'>, // Primary source entity
214
+ sourceField?: string, // e.g., 'content', 'transcript', 'title'
215
+ chunk?: { index: number; start?: number; end?: number; tokenCount?: number; overlap?: number },
216
+ // Lightweight categorization (free-form)
217
+ labels?: string[], // Replaces per-thing tags; applied to knowledge
218
+ // Additional metadata (protocol, language, mime, hash, version)
219
+ metadata?: Record<string, any>,
220
+ createdAt: number,
221
+ updatedAt: number,
222
+ deletedAt?: number,
223
+ }
224
+ ```
225
+
226
+ ### Junction: thingKnowledge
227
+
228
+ ```typescript
229
+ {
230
+ _id: Id<'thingKnowledge'>,
231
+ thingId: Id<'things'>,
232
+ knowledgeId: Id<'knowledge'>,
233
+ role?: 'label' | 'summary' | 'chunk_of' | 'caption' | 'keyword',
234
+ // Context for the link (e.g., confidence, section name)
235
+ metadata?: Record<string, any>,
236
+ createdAt: number,
237
+ }
238
+ ```
239
+
240
+ ### Indexes (recommended)
241
+
242
+ - `knowledge.by_type` (knowledgeType)
243
+ - `knowledge.by_source` (sourceThingId)
244
+ - `knowledge.by_created` (createdAt)
245
+ - `thingKnowledge.by_thing` (thingId)
246
+ - `thingKnowledge.by_knowledge` (knowledgeId)
247
+ - Vector index (provider-dependent): `knowledge.by_embedding` for ANN search
248
+
249
+ Notes:
250
+ - The legacy ThingType `embedding` is deprecated for operational vectors; use the `knowledge` table with `knowledgeType: 'chunk' | 'vector_only'`.
251
+ - Labels (formerly tags) now live in `knowledge.labels` and via `thingKnowledge` relations. Use labels to curate taxonomy without enum churn.
252
+
253
+ ---
254
+
255
+ ## THINGS: All The "Things"
256
+
257
+ ### What Goes in Things?
258
+
259
+ **Simple test:** If you can point at it and say "this is a \_\_\_", it's a thing.
260
+
261
+ Examples:
262
+
263
+ - "This is a **creator**" ✅ Thing
264
+ - "This is a **blog post**" ✅ Thing
265
+ - "This is a **token**" ✅ Thing
266
+ - "This is a **relationship**" ❌ Connection, not thing
267
+ - "This is a **purchase**" ❌ Event, not thing
268
+
269
+ ### Thing Types
270
+
271
+ ```typescript
272
+ type ThingType =
273
+ // CORE
274
+ | 'creator' // Human creator (role: platform_owner, org_owner, org_user, customer)
275
+ | 'ai_clone' // Digital twin of creator
276
+ | 'audience_member' // Fan/user (role: customer)
277
+ | 'organization' // Multi-tenant organization
278
+
279
+ // BUSINESS AGENTS (10 types)
280
+ | 'strategy_agent' // Vision, planning, OKRs
281
+ | 'research_agent' // Market, trends, competitors
282
+ | 'marketing_agent' // Content strategy, SEO, distribution
283
+ | 'sales_agent' // Funnels, conversion, follow-up
284
+ | 'service_agent' // Support, onboarding, success
285
+ | 'design_agent' // Brand, UI/UX, assets
286
+ | 'engineering_agent' // Tech, integration, automation
287
+ | 'finance_agent' // Revenue, costs, forecasting
288
+ | 'legal_agent' // Compliance, contracts, IP
289
+ | 'intelligence_agent' // Analytics, insights, predictions
290
+
291
+ // CONTENT
292
+ | 'blog_post' // Written content
293
+ | 'video' // Video content
294
+ | 'podcast' // Audio content
295
+ | 'social_post' // Social media post
296
+ | 'email' // Email content
297
+ | 'course' // Educational course
298
+ | 'lesson' // Individual lesson
299
+
300
+ // PRODUCTS
301
+ | 'digital_product' // Templates, tools, assets
302
+ | 'membership' // Tiered membership
303
+ | 'consultation' // 1-on-1 session
304
+ | 'nft' // NFT collectible
305
+
306
+ // COMMUNITY
307
+ | 'community' // Community space
308
+ | 'conversation' // Thread/discussion
309
+ | 'message' // Individual message
310
+
311
+ // TOKEN
312
+ | 'token' // Actual token instance
313
+ | 'token_contract' // Smart contract
314
+
315
+ // KNOWLEDGE
316
+ | 'knowledge_item' // Piece of creator knowledge
317
+ | 'embedding' // Vector embedding
318
+
319
+ // PLATFORM
320
+ | 'website' // Auto-generated creator site
321
+ | 'landing_page' // Custom landing pages
322
+ | 'template' // Design templates
323
+ | 'livestream' // Live broadcast
324
+ | 'recording' // Saved livestream content
325
+ | 'media_asset' // Images, videos, files
326
+
327
+ // BUSINESS
328
+ | 'payment' // Payment transaction
329
+ | 'subscription' // Recurring subscription
330
+ | 'invoice' // Invoice record
331
+ | 'metric' // Tracked metric
332
+ | 'insight' // AI-generated insight
333
+ | 'prediction' // AI prediction
334
+ | 'report' // Analytics report
335
+
336
+ // AUTHENTICATION & SESSION
337
+ | 'session' // User session (Better Auth)
338
+ | 'oauth_account' // OAuth connection (GitHub, Google)
339
+ | 'verification_token' // Email/2FA verification token
340
+ | 'password_reset_token' // Password reset token
341
+
342
+ // UI & PREFERENCES
343
+ | 'ui_preferences' // User UI settings (theme, layout, etc.)
344
+
345
+ // MARKETING
346
+ | 'notification' // System notification
347
+ | 'email_campaign' // Email marketing campaign
348
+ | 'announcement' // Platform announcement
349
+ | 'referral' // Referral record
350
+ | 'campaign' // Marketing campaign
351
+ | 'lead' // Potential customer/lead
352
+
353
+ // EXTERNAL INTEGRATIONS
354
+ | 'external_agent' // External AI agent (ElizaOS, etc.)
355
+ | 'external_workflow' // External workflow (n8n, Zapier, Make)
356
+ | 'external_connection' // Connection config to external service
357
+
358
+ // PROTOCOL ENTITIES (protocol-agnostic via properties.protocol)
359
+ | 'mandate' // Intent or cart mandate (AP2)
360
+ | 'product'; // Sellable product (ACP/marketplace)
361
+ ```
362
+
363
+ ### Thing Structure
364
+
365
+ ```typescript
366
+ {
367
+ _id: Id<"things">,
368
+ type: ThingType,
369
+ name: string, // Display name
370
+ properties: { // Type-specific properties (JSON)
371
+ // For creator:
372
+ email?: string,
373
+ username?: string,
374
+ niche?: string[],
375
+ // For token:
376
+ contractAddress?: string,
377
+ totalSupply?: number,
378
+ // etc...
379
+ },
380
+ status: "active" | "inactive" | "draft" | "published" | "archived",
381
+ createdAt: number,
382
+ updatedAt: number,
383
+ deletedAt?: number
384
+ }
385
+ ```
386
+
387
+ ### Properties by Thing Type
388
+
389
+ **Creator Properties:**
390
+
391
+ ```typescript
392
+ {
393
+ email: string,
394
+ username: string,
395
+ displayName: string,
396
+ bio?: string,
397
+ avatar?: string,
398
+ niche: string[],
399
+ expertise: string[],
400
+ targetAudience: string,
401
+ brandColors?: {
402
+ primary: string,
403
+ secondary: string,
404
+ accent: string
405
+ },
406
+ totalFollowers: number,
407
+ totalContent: number,
408
+ totalRevenue: number,
409
+ // MULTI-TENANT ROLES
410
+ role: "platform_owner" | "org_owner" | "org_user" | "customer",
411
+ organizationId?: Id<"things">, // Current/default org (if org_owner or org_user)
412
+ permissions?: string[], // Additional permissions
413
+ }
414
+ ```
415
+
416
+ **Organization Properties:**
417
+
418
+ ```typescript
419
+ {
420
+ name: string,
421
+ slug: string, // URL-friendly identifier
422
+ domain?: string, // Custom domain (e.g., acme.one.ie)
423
+ logo?: string,
424
+ description?: string,
425
+ status: "active" | "suspended" | "trial" | "cancelled",
426
+ plan: "starter" | "pro" | "enterprise",
427
+ limits: {
428
+ users: number, // Max users allowed
429
+ storage: number, // GB
430
+ apiCalls: number, // Per month
431
+ },
432
+ usage: {
433
+ users: number, // Current users
434
+ storage: number, // GB used
435
+ apiCalls: number, // This month
436
+ },
437
+ billing: {
438
+ customerId?: string, // Stripe customer ID
439
+ subscriptionId?: string, // Stripe subscription ID
440
+ currentPeriodEnd?: number,
441
+ },
442
+ settings: {
443
+ allowSignups: boolean,
444
+ requireEmailVerification: boolean,
445
+ enableTwoFactor: boolean,
446
+ allowedDomains?: string[], // Email domain whitelist
447
+ },
448
+ createdAt: number,
449
+ trialEndsAt?: number,
450
+ }
451
+ ```
452
+
453
+ **AI Clone Properties:**
454
+
455
+ ```typescript
456
+ {
457
+ voiceId?: string,
458
+ voiceProvider?: "elevenlabs" | "azure" | "custom",
459
+ appearanceId?: string,
460
+ appearanceProvider?: "d-id" | "heygen" | "custom",
461
+ systemPrompt: string,
462
+ temperature: number,
463
+ knowledgeBaseSize: number,
464
+ lastTrainingDate: number,
465
+ totalInteractions: number,
466
+ satisfactionScore: number
467
+ }
468
+ ```
469
+
470
+ **Agent Properties:**
471
+
472
+ ```typescript
473
+ {
474
+ agentType: "strategy" | "marketing" | "sales" | ...,
475
+ systemPrompt: string,
476
+ model: string,
477
+ temperature: number,
478
+ capabilities: string[],
479
+ tools: string[],
480
+ totalExecutions: number,
481
+ successRate: number,
482
+ averageExecutionTime: number
483
+ }
484
+ ```
485
+
486
+ **Token Properties:**
487
+
488
+ ```typescript
489
+ {
490
+ contractAddress: string,
491
+ blockchain: "base" | "ethereum" | "polygon",
492
+ standard: "ERC20" | "ERC721" | "ERC1155",
493
+ totalSupply: number,
494
+ circulatingSupply: number,
495
+ price: number,
496
+ marketCap: number,
497
+ utility: string[],
498
+ burnRate: number,
499
+ holders: number,
500
+ transactions24h: number,
501
+ volume24h: number
502
+ }
503
+ ```
504
+
505
+ **Course Properties:**
506
+
507
+ ```typescript
508
+ {
509
+ title: string,
510
+ description: string,
511
+ thumbnail?: string,
512
+ modules: number,
513
+ lessons: number,
514
+ totalDuration: number,
515
+ price: number,
516
+ currency: string,
517
+ tokenPrice?: number,
518
+ enrollments: number,
519
+ completions: number,
520
+ averageRating: number,
521
+ generatedBy: "ai" | "human" | "hybrid",
522
+ personalizationLevel: "none" | "basic" | "advanced"
523
+ }
524
+ ```
525
+
526
+ **Website Properties:**
527
+
528
+ ```typescript
529
+ {
530
+ domain: string,
531
+ subdomain: string, // creator.one.ie
532
+ template: "minimal" | "showcase" | "portfolio",
533
+ customCSS?: string,
534
+ customDomain?: string,
535
+ sslEnabled: boolean,
536
+ analytics: {
537
+ visitors30d: number,
538
+ pageViews: number,
539
+ conversionRate: number
540
+ }
541
+ }
542
+ ```
543
+
544
+ **Livestream Properties:**
545
+
546
+ ```typescript
547
+ {
548
+ title: string,
549
+ scheduledAt: number,
550
+ startedAt?: number,
551
+ endedAt?: number,
552
+ platform: "youtube" | "twitch" | "custom",
553
+ streamUrl: string,
554
+ recordingUrl?: string,
555
+ viewersPeak: number,
556
+ viewersAverage: number,
557
+ chatEnabled: boolean,
558
+ aiCloneMixEnabled: boolean, // For human + AI mixing
559
+ status: "scheduled" | "live" | "ended" | "cancelled"
560
+ }
561
+ ```
562
+
563
+ **Payment Properties:**
564
+
565
+ ```typescript
566
+ {
567
+ amount: number,
568
+ currency: "usd" | "eur",
569
+ paymentMethod: "stripe" | "crypto",
570
+ stripePaymentIntentId?: string,
571
+ txHash?: string, // Blockchain transaction
572
+ status: "pending" | "completed" | "failed" | "refunded",
573
+ fees: number,
574
+ netAmount: number,
575
+ processedAt?: number
576
+ }
577
+ ```
578
+
579
+ **Subscription Properties:**
580
+
581
+ ```typescript
582
+ {
583
+ tier: "starter" | "pro" | "enterprise",
584
+ price: number,
585
+ currency: string,
586
+ interval: "monthly" | "yearly",
587
+ status: "active" | "cancelled" | "past_due" | "expired",
588
+ currentPeriodStart: number,
589
+ currentPeriodEnd: number,
590
+ cancelAt?: number,
591
+ stripeSubscriptionId?: string
592
+ }
593
+ ```
594
+
595
+ **Metric Properties:**
596
+
597
+ ```typescript
598
+ {
599
+ name: string,
600
+ value: number,
601
+ unit: string,
602
+ timestamp: number,
603
+ period: "realtime" | "hourly" | "daily" | "weekly" | "monthly",
604
+ change: number, // Percentage change from previous
605
+ trend: "up" | "down" | "stable"
606
+ }
607
+ ```
608
+
609
+ **Insight Properties:**
610
+
611
+ ```typescript
612
+ {
613
+ title: string,
614
+ description: string,
615
+ category: "performance" | "audience" | "revenue" | "content",
616
+ confidence: number, // 0.0 to 1.0
617
+ actionable: boolean,
618
+ recommendations: string[],
619
+ generatedAt: number,
620
+ generatedBy: Id<"things"> // intelligence_agent
621
+ }
622
+ ```
623
+
624
+ **Referral Properties:**
625
+
626
+ ```typescript
627
+ {
628
+ referrerCode: string,
629
+ referredEmail: string,
630
+ referredUserId?: Id<"things">,
631
+ status: "pending" | "converted" | "expired",
632
+ tokensEarned: number,
633
+ bonusEarned?: number,
634
+ conversionDate?: number,
635
+ expiresAt: number
636
+ }
637
+ ```
638
+
639
+ **Notification Properties:**
640
+
641
+ ```typescript
642
+ {
643
+ title: string,
644
+ message: string,
645
+ type: "info" | "success" | "warning" | "error",
646
+ channel: "email" | "sms" | "push" | "in_app",
647
+ read: boolean,
648
+ readAt?: number,
649
+ actionUrl?: string,
650
+ actionLabel?: string
651
+ }
652
+ ```
653
+
654
+ **External Agent Properties:**
655
+
656
+ ```typescript
657
+ {
658
+ platform: "elizaos" | "autogen" | "crewai" | "langchain" | "custom",
659
+ agentId: string, // External platform's agent ID
660
+ name: string, // Agent name
661
+ description?: string, // What the agent does
662
+ capabilities: string[], // Available actions/tools
663
+ apiEndpoint?: string, // REST/GraphQL endpoint
664
+ websocketUrl?: string, // WebSocket endpoint for real-time
665
+ status: "online" | "offline" | "busy" | "unknown",
666
+ lastSeen?: number,
667
+ metadata: { // Platform-specific data
668
+ personality?: any, // For ElizaOS character
669
+ tools?: string[], // Available tools
670
+ model?: string, // LLM model used
671
+ [key: string]: any // Other platform-specific fields
672
+ },
673
+ conversationCount: number, // Total conversations
674
+ messageCount: number, // Total messages exchanged
675
+ createdAt: number,
676
+ updatedAt: number
677
+ }
678
+ ```
679
+
680
+ **External Workflow Properties:**
681
+
682
+ ```typescript
683
+ {
684
+ platform: "n8n" | "zapier" | "make" | "pipedream" | "custom",
685
+ workflowId: string, // External platform's workflow ID
686
+ name: string, // Workflow name
687
+ description: string, // What the workflow does
688
+ webhookUrl?: string, // Trigger URL
689
+ active: boolean, // Is workflow active?
690
+ tags: string[], // Workflow tags/categories
691
+ inputSchema: { // Expected input parameters
692
+ [key: string]: {
693
+ type: "string" | "number" | "boolean" | "object" | "array",
694
+ required: boolean,
695
+ description: string,
696
+ default?: any
697
+ }
698
+ },
699
+ outputSchema: { // Expected output structure
700
+ [key: string]: {
701
+ type: "string" | "number" | "boolean" | "object" | "array",
702
+ description: string
703
+ }
704
+ },
705
+ executionCount: number, // Total executions
706
+ successRate: number, // 0.0 to 1.0
707
+ averageExecutionTime: number, // milliseconds
708
+ lastExecutedAt?: number,
709
+ createdAt: number,
710
+ updatedAt: number
711
+ }
712
+ ```
713
+
714
+ **External Connection Properties:**
715
+
716
+ ```typescript
717
+ {
718
+ platform: "elizaos" | "n8n" | "zapier" | "make" | "autogen" | "custom",
719
+ name: string, // Connection name
720
+ baseUrl?: string, // API base URL
721
+ apiKey?: string, // Encrypted API key
722
+ websocketUrl?: string, // WebSocket endpoint
723
+ webhookSecret?: string, // Webhook signature secret
724
+ connectionType: "rest" | "websocket" | "webhook" | "graphql",
725
+ authentication: {
726
+ type: "apiKey" | "oauth" | "basic" | "bearer" | "custom",
727
+ credentials: any // Encrypted credentials
728
+ },
729
+ status: "active" | "inactive" | "error",
730
+ lastConnectedAt?: number,
731
+ lastError?: string,
732
+ linkedEntityIds: string[], // Connected agents/workflows
733
+ rateLimits?: {
734
+ requestsPerMinute: number,
735
+ requestsPerDay: number
736
+ },
737
+ createdAt: number,
738
+ updatedAt: number
739
+ }
740
+ ```
741
+
742
+ **Session Properties:**
743
+
744
+ ```typescript
745
+ {
746
+ userId: Id<"things">, // User this session belongs to
747
+ token: string, // Session token (hashed)
748
+ expiresAt: number, // Expiration timestamp
749
+ ipAddress?: string, // IP address
750
+ userAgent?: string, // Browser/device info
751
+ lastActivityAt: number, // Last activity timestamp
752
+ createdAt: number,
753
+ }
754
+ ```
755
+
756
+ **OAuth Account Properties:**
757
+
758
+ ```typescript
759
+ {
760
+ userId: Id<"things">, // User this account belongs to
761
+ provider: "github" | "google" | "discord" | "twitter",
762
+ providerAccountId: string, // Provider's user ID
763
+ accessToken?: string, // Encrypted access token
764
+ refreshToken?: string, // Encrypted refresh token
765
+ expiresAt?: number, // Token expiration
766
+ tokenType?: string, // Bearer, etc.
767
+ scope?: string, // Granted scopes
768
+ idToken?: string, // OpenID Connect ID token
769
+ createdAt: number,
770
+ updatedAt: number,
771
+ }
772
+ ```
773
+
774
+ **Verification Token Properties:**
775
+
776
+ ```typescript
777
+ {
778
+ userId: Id<"things">, // User to verify
779
+ token: string, // Verification token (hashed)
780
+ type: "email" | "two_factor", // Verification type
781
+ expiresAt: number, // Expiration timestamp
782
+ attempts: number, // Failed attempts count
783
+ maxAttempts: number, // Max allowed attempts
784
+ verifiedAt?: number, // When verified (if completed)
785
+ createdAt: number,
786
+ }
787
+ ```
788
+
789
+ **Password Reset Token Properties:**
790
+
791
+ ```typescript
792
+ {
793
+ userId: Id<"things">, // User requesting reset
794
+ token: string, // Reset token (hashed)
795
+ expiresAt: number, // Expiration timestamp (15-30 min)
796
+ usedAt?: number, // When token was used
797
+ createdAt: number,
798
+ }
799
+ ```
800
+
801
+ **UI Preferences Properties:**
802
+
803
+ ```typescript
804
+ {
805
+ userId: Id<"things">, // User these preferences belong to
806
+ theme: "light" | "dark" | "system",
807
+ language: string, // ISO language code
808
+ timezone: string, // IANA timezone
809
+ dashboardLayout: {
810
+ sidebarCollapsed: boolean,
811
+ defaultView: "grid" | "list" | "kanban",
812
+ itemsPerPage: number,
813
+ },
814
+ notifications: {
815
+ email: boolean,
816
+ push: boolean,
817
+ sms: boolean,
818
+ inApp: boolean,
819
+ },
820
+ accessibility: {
821
+ reducedMotion: boolean,
822
+ highContrast: boolean,
823
+ fontSize: "small" | "medium" | "large",
824
+ },
825
+ customSettings: any, // App-specific settings
826
+ updatedAt: number,
827
+ }
828
+ ```
829
+
830
+ ---
831
+
832
+ ## CONNECTIONS: All The Relationships
833
+
834
+ ### What Goes in Connections?
835
+
836
+ **Simple test:** If you're describing how thing X relates to thing Y, it's a connection.
837
+
838
+ Examples:
839
+
840
+ - "Creator **owns** token" ✅ Connection
841
+ - "User **enrolled_in** course" ✅ Connection
842
+ - "Agent **powers** AI clone" ✅ Connection
843
+ - "Creator created a post" ❌ Event (action), not connection
844
+
845
+ ### Connection Types (25 total)
846
+
847
+ **Design Principle:** Consolidated types with metadata for variants. Protocol identity stored in `metadata.protocol`.
848
+
849
+ ```typescript
850
+ type ConnectionType =
851
+ // OWNERSHIP (2)
852
+ | 'owns'
853
+ | 'created_by'
854
+
855
+ // AI RELATIONSHIPS (3)
856
+ | 'clone_of'
857
+ | 'trained_on'
858
+ | 'powers'
859
+
860
+ // CONTENT RELATIONSHIPS (5)
861
+ | 'authored'
862
+ | 'generated_by'
863
+ | 'published_to'
864
+ | 'part_of'
865
+ | 'references'
866
+
867
+ // COMMUNITY RELATIONSHIPS (4)
868
+ | 'member_of'
869
+ | 'following'
870
+ | 'moderates'
871
+ | 'participated_in'
872
+
873
+ // BUSINESS RELATIONSHIPS (3)
874
+ | 'manages'
875
+ | 'reports_to'
876
+ | 'collaborates_with'
877
+
878
+ // TOKEN RELATIONSHIPS (3)
879
+ | 'holds_tokens'
880
+ | 'staked_in'
881
+ | 'earned_from'
882
+
883
+ // PRODUCT RELATIONSHIPS (4)
884
+ | 'purchased'
885
+ | 'enrolled_in'
886
+ | 'completed'
887
+ | 'teaching'
888
+
889
+ // CONSOLIDATED TYPES (use metadata for variants + protocol)
890
+ | 'transacted' // Payment/subscription/invoice (metadata.transactionType + protocol)
891
+ | 'notified' // Notifications (metadata.channel + notificationType)
892
+ | 'referred' // Referrals (metadata.referralType)
893
+ | 'communicated' // Agent/protocol communication (metadata.protocol + messageType)
894
+ | 'delegated' // Task/workflow delegation (metadata.protocol + taskType)
895
+ | 'approved' // Approvals (metadata.approvalType + protocol)
896
+ | 'fulfilled'; // Fulfillment (metadata.fulfillmentType + protocol)
897
+
898
+ // Total: 25 connection types
899
+ ```
900
+
901
+ ### Connection Structure
902
+
903
+ ```typescript
904
+ {
905
+ _id: Id<"connections">,
906
+ fromThingId: Id<"things">,
907
+ toThingId: Id<"things">,
908
+ relationshipType: ConnectionType,
909
+ metadata?: { // Optional relationship data
910
+ // For revenue splits:
911
+ revenueShare?: number, // 0.0 to 1.0
912
+ // For token holdings:
913
+ balance?: number,
914
+ // For course enrollment:
915
+ enrolledAt?: number,
916
+ progress?: number,
917
+ // etc...
918
+ },
919
+ strength?: number, // Relationship strength (0-1)
920
+ validFrom?: number, // When relationship started
921
+ validTo?: number, // When relationship ended
922
+ createdAt: number,
923
+ updatedAt?: number
924
+ }
925
+ ```
926
+
927
+ ### Common Connection Patterns
928
+
929
+ **Pattern: Ownership**
930
+
931
+ ```typescript
932
+ // Creator owns AI clone (thing-to-thing)
933
+ {
934
+ fromThingId: creatorId,
935
+ toThingId: cloneId,
936
+ relationshipType: "owns",
937
+ createdAt: Date.now()
938
+ }
939
+ ```
940
+
941
+ **Pattern: Revenue Split**
942
+
943
+ ```typescript
944
+ // Collaborator owns 30% of course
945
+ {
946
+ fromThingId: collaboratorId,
947
+ toThingId: courseId,
948
+ relationshipType: "owns",
949
+ metadata: {
950
+ revenueShare: 0.3
951
+ },
952
+ createdAt: Date.now()
953
+ }
954
+ ```
955
+
956
+ **Pattern: Token Holding**
957
+
958
+ ```typescript
959
+ // User holds 1000 tokens
960
+ {
961
+ fromThingId: userId,
962
+ toThingId: tokenId,
963
+ relationshipType: "holds_tokens",
964
+ metadata: {
965
+ balance: 1000,
966
+ acquiredAt: Date.now()
967
+ },
968
+ createdAt: Date.now()
969
+ }
970
+ ```
971
+
972
+ **Pattern: Course Enrollment**
973
+
974
+ ```typescript
975
+ // User enrolled in course
976
+ {
977
+ fromThingId: userId,
978
+ toThingId: courseId,
979
+ relationshipType: "enrolled_in",
980
+ metadata: {
981
+ progress: 0.45, // 45% complete
982
+ enrolledAt: Date.now(),
983
+ lastAccessedAt: Date.now()
984
+ },
985
+ createdAt: Date.now()
986
+ }
987
+ ```
988
+
989
+ **Pattern: Organization Membership**
990
+
991
+ ```typescript
992
+ // User is member of organization with role
993
+ {
994
+ fromThingId: userId,
995
+ toThingId: organizationId,
996
+ relationshipType: "member_of",
997
+ metadata: {
998
+ role: "org_owner" | "org_user", // Organization-specific role
999
+ permissions: ["read", "write", "admin"],
1000
+ invitedBy?: Id<"things">, // Who invited this user
1001
+ invitedAt?: number,
1002
+ joinedAt: Date.now(),
1003
+ },
1004
+ createdAt: Date.now()
1005
+ }
1006
+
1007
+ // Organization owns content/resources
1008
+ {
1009
+ fromThingId: organizationId,
1010
+ toThingId: contentId,
1011
+ relationshipType: "owns",
1012
+ metadata: {
1013
+ createdBy: userId, // User who created it
1014
+ },
1015
+ createdAt: Date.now()
1016
+ }
1017
+ ```
1018
+
1019
+ **Pattern: Payment Transaction (Consolidated)**
1020
+
1021
+ ```typescript
1022
+ // User paid for product (use "transacted" with metadata)
1023
+ {
1024
+ fromThingId: userId,
1025
+ toThingId: productId,
1026
+ relationshipType: "transacted",
1027
+ metadata: {
1028
+ transactionType: "payment", // or "subscription" or "invoice"
1029
+ amount: 99.00,
1030
+ currency: "USD",
1031
+ paymentId: "pi_123456",
1032
+ status: "completed"
1033
+ },
1034
+ createdAt: Date.now()
1035
+ }
1036
+
1037
+ // User subscribed to service
1038
+ {
1039
+ fromThingId: userId,
1040
+ toThingId: subscriptionId,
1041
+ relationshipType: "transacted",
1042
+ metadata: {
1043
+ transactionType: "subscription",
1044
+ amount: 29.00,
1045
+ currency: "USD",
1046
+ interval: "monthly",
1047
+ subscriptionId: "sub_123456",
1048
+ status: "active"
1049
+ },
1050
+ createdAt: Date.now()
1051
+ }
1052
+ ```
1053
+
1054
+ **Pattern: Referral (Consolidated)**
1055
+
1056
+ ```typescript
1057
+ // User referred by another user (use "referred" with metadata)
1058
+ {
1059
+ fromThingId: newUserId,
1060
+ toThingId: referrerId,
1061
+ relationshipType: "referred",
1062
+ metadata: {
1063
+ referralType: "direct", // or "conversion" or "campaign"
1064
+ source: "referral_link",
1065
+ referralCode: "REF123",
1066
+ tokensEarned: 100,
1067
+ status: "converted"
1068
+ },
1069
+ createdAt: Date.now()
1070
+ }
1071
+ ```
1072
+
1073
+ **Pattern: Notification (Consolidated)**
1074
+
1075
+ ```typescript
1076
+ // User notified about event (use "notified" with metadata)
1077
+ {
1078
+ fromThingId: userId,
1079
+ toThingId: notificationId,
1080
+ relationshipType: "notified",
1081
+ metadata: {
1082
+ channel: "email", // or "sms" or "push" or "in_app"
1083
+ campaignId: campaignId, // optional
1084
+ deliveredAt: Date.now(),
1085
+ readAt: Date.now(),
1086
+ clicked: true
1087
+ },
1088
+ createdAt: Date.now()
1089
+ }
1090
+ ```
1091
+
1092
+ ---
1093
+
1094
+ ## EVENTS: All The Actions
1095
+
1096
+ ### What Goes in Events?
1097
+
1098
+ **Simple test:** If you're describing something that HAPPENED at a specific TIME, it's an event.
1099
+
1100
+ Examples:
1101
+
1102
+ - "User **purchased** tokens at 3pm" ✅ Event
1103
+ - "Content **was published** yesterday" ✅ Event
1104
+ - "Clone **interacted** with user" ✅ Event
1105
+ - "User owns tokens" ❌ Connection (state), not event
1106
+
1107
+ ### Event Types (35 total)
1108
+
1109
+ **Design Principle:** Consolidated types with metadata for variants. Protocol identity stored in `metadata.protocol`.
1110
+
1111
+ ```typescript
1112
+ type EventType =
1113
+ // ENTITY LIFECYCLE (4)
1114
+ | 'entity_created'
1115
+ | 'entity_updated'
1116
+ | 'entity_deleted'
1117
+ | 'entity_archived'
1118
+
1119
+ // USER EVENTS (5)
1120
+ | 'user_registered'
1121
+ | 'user_verified'
1122
+ | 'user_login'
1123
+ | 'user_logout'
1124
+ | 'profile_updated'
1125
+
1126
+ // AUTHENTICATION EVENTS (6)
1127
+ | 'password_reset_requested'
1128
+ | 'password_reset_completed'
1129
+ | 'email_verification_sent'
1130
+ | 'email_verified'
1131
+ | 'two_factor_enabled'
1132
+ | 'two_factor_disabled'
1133
+
1134
+ // ORGANIZATION EVENTS (5)
1135
+ | 'organization_created'
1136
+ | 'organization_updated'
1137
+ | 'user_invited_to_org'
1138
+ | 'user_joined_org'
1139
+ | 'user_removed_from_org'
1140
+
1141
+ // DASHBOARD & UI EVENTS (4)
1142
+ | 'dashboard_viewed'
1143
+ | 'settings_updated'
1144
+ | 'theme_changed'
1145
+ | 'preferences_updated'
1146
+
1147
+ // AI/CLONE EVENTS (4)
1148
+ | 'clone_created'
1149
+ | 'clone_updated'
1150
+ | 'voice_cloned'
1151
+ | 'appearance_cloned'
1152
+
1153
+ // AGENT EVENTS (4)
1154
+ | 'agent_created'
1155
+ | 'agent_executed'
1156
+ | 'agent_completed'
1157
+ | 'agent_failed'
1158
+
1159
+ // TOKEN EVENTS (7)
1160
+ | 'token_created'
1161
+ | 'token_minted'
1162
+ | 'token_burned'
1163
+ | 'tokens_purchased'
1164
+ | 'tokens_staked'
1165
+ | 'tokens_unstaked'
1166
+ | 'tokens_transferred'
1167
+
1168
+ // COURSE EVENTS (5)
1169
+ | 'course_created'
1170
+ | 'course_enrolled'
1171
+ | 'lesson_completed'
1172
+ | 'course_completed'
1173
+ | 'certificate_earned'
1174
+
1175
+ // ANALYTICS EVENTS (5)
1176
+ | 'metric_calculated'
1177
+ | 'insight_generated'
1178
+ | 'prediction_made'
1179
+ | 'optimization_applied'
1180
+ | 'report_generated'
1181
+
1182
+ // INFERENCE EVENTS (7) - NEW
1183
+ | 'inference_request' // User requests AI inference
1184
+ | 'inference_completed' // Inference result delivered
1185
+ | 'inference_failed' // Inference failed
1186
+ | 'inference_quota_exceeded' // Monthly limit hit
1187
+ | 'inference_revenue_collected' // Daily revenue sweep
1188
+ | 'org_revenue_generated' // Org generates platform revenue
1189
+ | 'revenue_share_distributed' // Revenue share paid out
1190
+
1191
+ // BLOCKCHAIN EVENTS (5) - NEW
1192
+ | 'nft_minted' // NFT created on-chain
1193
+ | 'nft_transferred' // NFT ownership changed
1194
+ | 'tokens_bridged' // Cross-chain bridge
1195
+ | 'contract_deployed' // Smart contract deployed
1196
+ | 'treasury_withdrawal' // Platform owner withdraws revenue
1197
+
1198
+ // CONSOLIDATED EVENTS (use metadata for variants + protocol)
1199
+ | 'content_event' // metadata.action: created|updated|deleted|viewed|shared|liked
1200
+ | 'payment_event' // metadata.status: requested|verified|processed + protocol
1201
+ | 'subscription_event' // metadata.action: started|renewed|cancelled
1202
+ | 'commerce_event' // metadata.eventType + protocol (ACP, AP2)
1203
+ | 'livestream_event' // metadata.status: started|ended + metadata.action: joined|left|chat|donation
1204
+ | 'notification_event' // metadata.channel: email|sms|push|in_app + deliveryStatus
1205
+ | 'referral_event' // metadata.action: created|completed|rewarded
1206
+ | 'communication_event' // metadata.protocol (A2A, ACP, AG-UI) + messageType
1207
+ | 'task_event' // metadata.action: delegated|completed|failed + protocol
1208
+ | 'mandate_event' // metadata.mandateType: intent|cart + protocol (AP2)
1209
+ | 'price_event'; // metadata.action: checked|changed
1210
+
1211
+ // Total: 52 event types (35 original + 7 inference + 5 blockchain + 5 NFT overlap)
1212
+ ```
1213
+
1214
+ ### Event Structure
1215
+
1216
+ ```typescript
1217
+ {
1218
+ _id: Id<"events">,
1219
+ type: EventType, // What happened
1220
+ actorId: Id<"things">, // Who/what caused this
1221
+ targetId?: Id<"things">, // Optional target thing
1222
+ timestamp: number, // When it happened
1223
+ metadata: any // Event-specific data
1224
+ }
1225
+ ```
1226
+
1227
+ **Metadata Structure:**
1228
+
1229
+ The `metadata` field is flexible JSON that ALWAYS includes `protocol` for protocol-specific events:
1230
+
1231
+ ```typescript
1232
+ // Protocol-agnostic events (no protocol field needed)
1233
+ { action: "created", contentType: "blog_post" }
1234
+
1235
+ // Protocol-specific events (includes protocol identifier)
1236
+ {
1237
+ protocol: "a2a" | "acp" | "ap2" | "x402" | "ag-ui",
1238
+ // ... protocol-specific fields
1239
+ }
1240
+
1241
+ // Examples:
1242
+ // A2A message
1243
+ { protocol: "a2a", messageType: "task_delegation", task: "research" }
1244
+
1245
+ // ACP commerce
1246
+ { protocol: "acp", eventType: "purchase_initiated", agentPlatform: "chatgpt" }
1247
+
1248
+ // AP2 mandate
1249
+ { protocol: "ap2", mandateType: "intent", autoExecute: true }
1250
+
1251
+ // X402 payment
1252
+ { protocol: "x402", network: "base", txHash: "0x..." }
1253
+ ```
1254
+
1255
+ ### Event Patterns
1256
+
1257
+ **Pattern: User Action**
1258
+
1259
+ ```typescript
1260
+ // User purchased tokens
1261
+ {
1262
+ type: "tokens_purchased",
1263
+ actorId: userId,
1264
+ targetId: tokenId,
1265
+ timestamp: Date.now(),
1266
+ metadata: {
1267
+ amount: 100,
1268
+ usdAmount: 10,
1269
+ paymentId: "pi_123",
1270
+ txHash: "0x456"
1271
+ }
1272
+ }
1273
+ ```
1274
+
1275
+ **Pattern: Payment Event (Consolidated)**
1276
+
1277
+ ```typescript
1278
+ // Payment completed (use "payment_processed" with metadata.status)
1279
+ {
1280
+ type: "payment_processed",
1281
+ actorId: userId,
1282
+ targetId: paymentId,
1283
+ timestamp: Date.now(),
1284
+ metadata: {
1285
+ status: "completed", // or "initiated" | "failed" | "refunded"
1286
+ amount: 99.00,
1287
+ currency: "USD",
1288
+ paymentId: "pi_123456",
1289
+ method: "stripe"
1290
+ }
1291
+ }
1292
+
1293
+ // Subscription renewed (use "subscription_updated" with metadata.action)
1294
+ {
1295
+ type: "subscription_updated",
1296
+ actorId: userId,
1297
+ targetId: subscriptionId,
1298
+ timestamp: Date.now(),
1299
+ metadata: {
1300
+ action: "renewed", // or "started" | "cancelled"
1301
+ tier: "pro",
1302
+ amount: 29.00,
1303
+ nextBillingDate: Date.now() + 30 * 24 * 60 * 60 * 1000
1304
+ }
1305
+ }
1306
+ ```
1307
+
1308
+ **Pattern: Content Event (Consolidated)**
1309
+
1310
+ ```typescript
1311
+ // Content created (use "content_changed" with metadata.action)
1312
+ {
1313
+ type: "content_changed",
1314
+ actorId: creatorId,
1315
+ targetId: contentId,
1316
+ timestamp: Date.now(),
1317
+ metadata: {
1318
+ action: "created", // or "updated" | "deleted"
1319
+ contentType: "blog_post",
1320
+ generatedBy: "marketing_agent",
1321
+ platform: "instagram"
1322
+ }
1323
+ }
1324
+
1325
+ // Content viewed (use "content_interacted" with metadata.interactionType)
1326
+ {
1327
+ type: "content_interacted",
1328
+ actorId: userId,
1329
+ targetId: contentId,
1330
+ timestamp: Date.now(),
1331
+ metadata: {
1332
+ interactionType: "viewed", // or "shared" | "liked"
1333
+ duration: 120, // seconds
1334
+ source: "feed"
1335
+ }
1336
+ }
1337
+ ```
1338
+
1339
+ **Pattern: Livestream Event (Consolidated)**
1340
+
1341
+ ```typescript
1342
+ // Livestream started (use "livestream_status_changed" with metadata.status)
1343
+ {
1344
+ type: "livestream_status_changed",
1345
+ actorId: creatorId,
1346
+ targetId: livestreamId,
1347
+ timestamp: Date.now(),
1348
+ metadata: {
1349
+ status: "started", // or "scheduled" | "ended"
1350
+ streamId: "stream_123",
1351
+ platform: "cloudflare",
1352
+ rtmpUrl: "rtmp://..."
1353
+ }
1354
+ }
1355
+
1356
+ // Viewer joined (use "livestream_interaction" with metadata.type)
1357
+ {
1358
+ type: "livestream_interaction",
1359
+ actorId: viewerId,
1360
+ targetId: livestreamId,
1361
+ timestamp: Date.now(),
1362
+ metadata: {
1363
+ type: "joined", // or "left" | "message"
1364
+ viewerCount: 42,
1365
+ message: "Hello!" // if type === "message"
1366
+ }
1367
+ }
1368
+ ```
1369
+
1370
+ **Pattern: Notification Event (Consolidated)**
1371
+
1372
+ ```typescript
1373
+ // Email notification sent (use "notification_delivered" with metadata.channel)
1374
+ {
1375
+ type: "notification_delivered",
1376
+ actorId: systemId,
1377
+ targetId: userId,
1378
+ timestamp: Date.now(),
1379
+ metadata: {
1380
+ channel: "email", // or "sms" | "push" | "in_app"
1381
+ messageId: "msg_123",
1382
+ subject: "New content available",
1383
+ deliveredAt: Date.now(),
1384
+ readAt: Date.now() + 1000 // optional
1385
+ }
1386
+ }
1387
+ ```
1388
+
1389
+ **Pattern: AI Interaction**
1390
+
1391
+ ```typescript
1392
+ // Clone chatted with user
1393
+ {
1394
+ type: "clone_interaction",
1395
+ actorId: userId,
1396
+ targetId: cloneId,
1397
+ timestamp: Date.now(),
1398
+ metadata: {
1399
+ message: "How do I start?",
1400
+ response: "Let me help you...",
1401
+ tokensUsed: 150,
1402
+ sentiment: "positive"
1403
+ }
1404
+ }
1405
+ ```
1406
+
1407
+ **Pattern: Metric Tracking**
1408
+
1409
+ ```typescript
1410
+ // Token price calculated
1411
+ {
1412
+ type: "metric_calculated",
1413
+ actorId: systemId,
1414
+ targetId: tokenId,
1415
+ timestamp: Date.now(),
1416
+ metadata: {
1417
+ metric: "token_price",
1418
+ value: 0.12,
1419
+ change: +0.05,
1420
+ changePercent: 4.2
1421
+ }
1422
+ }
1423
+ ```
1424
+
1425
+ **Pattern: Authentication Events**
1426
+
1427
+ ```typescript
1428
+ // Password reset requested
1429
+ {
1430
+ type: "password_reset_requested",
1431
+ actorId: userId,
1432
+ targetId: passwordResetTokenId,
1433
+ timestamp: Date.now(),
1434
+ metadata: {
1435
+ email: "user@example.com",
1436
+ ipAddress: "192.168.1.1",
1437
+ expiresAt: Date.now() + 30 * 60 * 1000 // 30 minutes
1438
+ }
1439
+ }
1440
+
1441
+ // Email verified
1442
+ {
1443
+ type: "email_verified",
1444
+ actorId: userId,
1445
+ targetId: verificationTokenId,
1446
+ timestamp: Date.now(),
1447
+ metadata: {
1448
+ email: "user@example.com",
1449
+ verificationMethod: "link" | "code"
1450
+ }
1451
+ }
1452
+
1453
+ // Two-factor enabled
1454
+ {
1455
+ type: "two_factor_enabled",
1456
+ actorId: userId,
1457
+ timestamp: Date.now(),
1458
+ metadata: {
1459
+ method: "totp" | "sms" | "email",
1460
+ backupCodesGenerated: 10
1461
+ }
1462
+ }
1463
+ ```
1464
+
1465
+ **Pattern: Organization Events**
1466
+
1467
+ ```typescript
1468
+ // Organization created
1469
+ {
1470
+ type: "organization_created",
1471
+ actorId: creatorId,
1472
+ targetId: organizationId,
1473
+ timestamp: Date.now(),
1474
+ metadata: {
1475
+ name: "Acme Corp",
1476
+ slug: "acme",
1477
+ plan: "pro",
1478
+ trialEndsAt: Date.now() + 14 * 24 * 60 * 60 * 1000 // 14 days
1479
+ }
1480
+ }
1481
+
1482
+ // User invited to organization
1483
+ {
1484
+ type: "user_invited_to_org",
1485
+ actorId: inviterId,
1486
+ targetId: organizationId,
1487
+ timestamp: Date.now(),
1488
+ metadata: {
1489
+ invitedEmail: "newuser@example.com",
1490
+ role: "org_user",
1491
+ inviteToken: "inv_123456",
1492
+ expiresAt: Date.now() + 7 * 24 * 60 * 60 * 1000 // 7 days
1493
+ }
1494
+ }
1495
+
1496
+ // User joined organization
1497
+ {
1498
+ type: "user_joined_org",
1499
+ actorId: userId,
1500
+ targetId: organizationId,
1501
+ timestamp: Date.now(),
1502
+ metadata: {
1503
+ role: "org_user",
1504
+ invitedBy: inviterId
1505
+ }
1506
+ }
1507
+ ```
1508
+
1509
+ **Pattern: Dashboard & UI Events**
1510
+
1511
+ ```typescript
1512
+ // Dashboard viewed
1513
+ {
1514
+ type: "dashboard_viewed",
1515
+ actorId: userId,
1516
+ timestamp: Date.now(),
1517
+ metadata: {
1518
+ dashboardType: "platform_owner" | "org_owner" | "org_user" | "customer",
1519
+ organizationId?: organizationId,
1520
+ route: "/admin/dashboard",
1521
+ sessionDuration: 0 // Updated on session end
1522
+ }
1523
+ }
1524
+
1525
+ // Theme changed
1526
+ {
1527
+ type: "theme_changed",
1528
+ actorId: userId,
1529
+ targetId: uiPreferencesId,
1530
+ timestamp: Date.now(),
1531
+ metadata: {
1532
+ previousTheme: "light",
1533
+ newTheme: "dark"
1534
+ }
1535
+ }
1536
+
1537
+ // Settings updated
1538
+ {
1539
+ type: "settings_updated",
1540
+ actorId: userId,
1541
+ targetId: uiPreferencesId,
1542
+ timestamp: Date.now(),
1543
+ metadata: {
1544
+ updatedFields: ["dashboardLayout", "notifications"],
1545
+ changes: {
1546
+ "dashboardLayout.sidebarCollapsed": { from: false, to: true },
1547
+ "notifications.email": { from: true, to: false }
1548
+ }
1549
+ }
1550
+ }
1551
+ ```
1552
+
1553
+ ---
1554
+
1555
+ ## KNOWLEDGE Labels & Semantic Chunks
1556
+
1557
+ Use knowledge items of `knowledgeType: 'label'` for taxonomy and `knowledgeType: 'chunk'` for RAG. Associate via `thingKnowledge`.
1558
+
1559
+ Examples:
1560
+
1561
+ - "This creator is in the fitness industry" ✅ label knowledge with `labels: ['industry:fitness']`
1562
+ - "This content is video format" ✅ label knowledge with `labels: ['format:video']`
1563
+ - "This page content paragraph 3" ✅ chunk knowledge with `text` + `embedding`
1564
+
1565
+ Pattern: multi‑label entity
1566
+
1567
+ ```typescript
1568
+ const labels = [ 'industry:fitness', 'skill:video-editing', 'technology:youtube', 'audience:beginners' ];
1569
+ for (const label of labels) {
1570
+ const kid = await getOrCreateKnowledgeLabel(label);
1571
+ await db.insert('thingKnowledge', { thingId: creatorId, knowledgeId: kid, role: 'label', createdAt: Date.now() });
1572
+ }
1573
+ ```
1574
+
1575
+ Pattern: semantic search across chunks
1576
+
1577
+ ```typescript
1578
+ // Given a query embedding, find top-k similar chunks for an org
1579
+ const topK = await vectorSearch('knowledge', {
1580
+ vectorField: 'embedding',
1581
+ query: queryEmbedding,
1582
+ filter: { 'sourceThingId.orgId': orgId, knowledgeType: 'chunk' },
1583
+ k: 10,
1584
+ });
1585
+ ```
1586
+
1587
+ ---
1588
+
1589
+ ## How Features Map to Ontology
1590
+
1591
+ ### Feature: AI Clone Creation
1592
+
1593
+ **Things Created:**
1594
+
1595
+ 1. `ai_clone` thing (the clone)
1596
+ 2. `knowledge_item` entities (training data)
1597
+
1598
+ **Connections Created:**
1599
+
1600
+ 1. creator → ai_clone (relationship: "owns")
1601
+ 2. ai_clone → knowledge_items (relationship: "trained_on")
1602
+
1603
+ **Events Logged:**
1604
+
1605
+ 1. `clone_created` (when clone created)
1606
+ 2. `voice_cloned` (when voice ready)
1607
+ 3. `appearance_cloned` (when appearance ready)
1608
+
1609
+ **Knowledge Labels Added:**
1610
+
1611
+ - Clone inherits creator's labels
1612
+ - Additional: "ai_clone", "active"
1613
+
1614
+ ### Feature: Token Purchase
1615
+
1616
+ **Things Involved:**
1617
+
1618
+ 1. `token` thing (the token being purchased)
1619
+ 2. `audience_member` thing (the buyer)
1620
+
1621
+ **Connections Created/Updated:**
1622
+
1623
+ 1. buyer → token (relationship: "holds_tokens", metadata: { balance: 100 })
1624
+
1625
+ **Events Logged:**
1626
+
1627
+ 1. `tokens_purchased` (the purchase)
1628
+ 2. `revenue_generated` (for creator)
1629
+
1630
+ **Knowledge Labels Added:**
1631
+
1632
+ - None (tokens already labeled)
1633
+
1634
+ ### Feature: Course Generation
1635
+
1636
+ **Things Created:**
1637
+
1638
+ 1. `course` entity
1639
+ 2. `lesson` entities (multiple)
1640
+
1641
+ **Connections Created:**
1642
+
1643
+ 1. creator → course (relationship: "owns")
1644
+ 2. ai_clone → course (relationship: "teaching")
1645
+ 3. course → lessons (relationship: "part_of")
1646
+
1647
+ **Events Logged:**
1648
+
1649
+ 1. `course_created`
1650
+ 2. `content_generated` (for each lesson)
1651
+
1652
+ **Knowledge Labels Added:**
1653
+
1654
+ - skill labels (what course teaches)
1655
+ - industry labels (course category)
1656
+ - audience labels (target audience)
1657
+
1658
+ ### Feature: ELEVATE Journey
1659
+
1660
+ **Things Involved:**
1661
+
1662
+ 1. `audience_member` (user going through journey)
1663
+ 2. Workflow thing (tracks progress)
1664
+
1665
+ **Connections Created:**
1666
+
1667
+ - None (journey tracked in workflow state)
1668
+
1669
+ **Events Logged:**
1670
+
1671
+ 1. `journey_step_completed` (for each step: hook, gift, identify, etc.)
1672
+ 2. `achievement_unlocked` (at milestones)
1673
+ 3. `tokens_earned` (rewards)
1674
+
1675
+ **Knowledge Labels Added:**
1676
+
1677
+ - Status labels (current step)
1678
+
1679
+ ---
1680
+
1681
+ ## Querying the Ontology
1682
+
1683
+ ### Get Thing by ID (table: things)
1684
+
1685
+ ```typescript
1686
+ const thing = await db.get(thingId);
1687
+ ```
1688
+
1689
+ ### Get All Things of Type (index: by_type)
1690
+
1691
+ ```typescript
1692
+ const creators = await db
1693
+ .query('things')
1694
+ .withIndex('by_type', (q) => q.eq('type', 'creator'))
1695
+ .collect();
1696
+ ```
1697
+
1698
+ ### Get Thing's Relationships (table: connections)
1699
+
1700
+ ```typescript
1701
+ // Get all entities this entity owns
1702
+ const owned = await db
1703
+ .query('connections')
1704
+ .withIndex('from_type', (q) =>
1705
+ q.eq('fromThingId', thingId).eq('relationshipType', 'owns')
1706
+ )
1707
+ .collect();
1708
+
1709
+ const ownedThings = await Promise.all(
1710
+ owned.map((conn) => db.get(conn.toThingId))
1711
+ );
1712
+ ```
1713
+
1714
+ ### Get Thing's History (table: events)
1715
+
1716
+ ```typescript
1717
+ // Get all events for this entity
1718
+ const history = await db
1719
+ .query('events')
1720
+ .withIndex('thing_type_time', (q) => q.eq('thingId', thingId))
1721
+ .order('desc') // Most recent first
1722
+ .collect();
1723
+ ```
1724
+
1725
+ ### Get Thing's Knowledge (junction: thingKnowledge)
1726
+
1727
+ ```typescript
1728
+ const knowledgeAssocs = await db
1729
+ .query('thingKnowledge')
1730
+ .withIndex('by_thing', (q) => q.eq('thingId', thingId))
1731
+ .collect();
1732
+
1733
+ const knowledgeItems = await Promise.all(
1734
+ knowledgeAssocs.map((assoc) => db.get(assoc.knowledgeId))
1735
+ );
1736
+ ```
1737
+
1738
+ ### Search by Multiple Criteria
1739
+
1740
+ ```typescript
1741
+ // Find fitness creators with >10k followers
1742
+ const creators = await db
1743
+ .query('things')
1744
+ .withIndex('by_type', (q) => q.eq('type', 'creator'))
1745
+ .collect();
1746
+
1747
+ const fitnessCreators = creators.filter(
1748
+ (c) =>
1749
+ c.properties.totalFollowers > 10000 &&
1750
+ c.properties.niche.includes('fitness')
1751
+ );
1752
+ ```
1753
+
1754
+ ---
1755
+
1756
+ ## Migration from Old Systems
1757
+
1758
+ When migrating from one.ie or bullfm:
1759
+
1760
+ ### Step 1: Identify Thing Types
1761
+
1762
+ Map old models to new thing types:
1763
+
1764
+ - Old "User" → "creator" or "audience_member"
1765
+ - Old "Post" → "blog_post" or "social_post"
1766
+ - Old "Follow" → connection with "following" type
1767
+ - Old "Like" → event with "content_liked" type
1768
+
1769
+ ### Step 2: Transform Properties
1770
+
1771
+ Extract structured data into `properties` JSON:
1772
+
1773
+ ```typescript
1774
+ // Old user model
1775
+ {
1776
+ id: "123",
1777
+ name: "John",
1778
+ email: "john@example.com",
1779
+ bio: "Fitness coach",
1780
+ followers: 5000
1781
+ }
1782
+
1783
+ // New entity
1784
+ {
1785
+ type: "creator",
1786
+ name: "John",
1787
+ properties: {
1788
+ email: "john@example.com",
1789
+ username: "john",
1790
+ displayName: "John",
1791
+ bio: "Fitness coach",
1792
+ niche: ["fitness"],
1793
+ totalFollowers: 5000,
1794
+ totalContent: 0,
1795
+ totalRevenue: 0
1796
+ },
1797
+ status: "active",
1798
+ createdAt: Date.now(),
1799
+ updatedAt: Date.now()
1800
+ }
1801
+ ```
1802
+
1803
+ ### Step 3: Convert Relationships
1804
+
1805
+ Transform foreign keys into connections:
1806
+
1807
+ ```typescript
1808
+ // Old: user_id in posts table
1809
+ // New: connection
1810
+ {
1811
+ fromThingId: userId,
1812
+ toThingId: postId,
1813
+ relationshipType: "authored",
1814
+ createdAt: Date.now()
1815
+ }
1816
+ ```
1817
+
1818
+ ### Step 4: Preserve History
1819
+
1820
+ Convert activity logs to events:
1821
+
1822
+ ```typescript
1823
+ // Old: activity log entry
1824
+ { user: "123", action: "viewed", post: "456", timestamp: 1234567890 }
1825
+
1826
+ // New: event
1827
+ {
1828
+ thingId: "post-456",
1829
+ eventType: "content_viewed",
1830
+ timestamp: 1234567890,
1831
+ actorType: "user",
1832
+ actorId: "user-123"
1833
+ }
1834
+ ```
1835
+
1836
+ ---
1837
+
1838
+ ## Validation Rules
1839
+
1840
+ ### Thing Validation
1841
+
1842
+ - `type` must be valid ThingType (implementation alias may be `EntityType`)
1843
+ - `name` cannot be empty
1844
+ - `properties` structure must match type
1845
+ - `status` must be valid status
1846
+ - `createdAt` required, `updatedAt` required
1847
+
1848
+ ### Connection Validation
1849
+
1850
+ - `fromThingId` must exist
1851
+ - `toThingId` must exist
1852
+ - `relationshipType` must be valid
1853
+ - Cannot connect a thing to itself (usually)
1854
+ - Relationship must make semantic sense
1855
+
1856
+ ### Event Validation
1857
+
1858
+ - `thingId` must exist
1859
+ - `eventType` must be valid
1860
+ - `timestamp` required
1861
+ - `actorId` must exist if provided
1862
+ - `metadata` structure must match event type
1863
+
1864
+ ### Tag Validation
1865
+
1866
+ - `name` must be unique
1867
+ - `category` must be valid TagCategory
1868
+ - `usageCount` must be >= 0
1869
+
1870
+ ---
1871
+
1872
+ ## Performance Optimization
1873
+
1874
+ ### Indexes
1875
+
1876
+ Every table has optimized indexes:
1877
+
1878
+ ```typescript
1879
+ things: -by_type(type) -
1880
+ by_status(status) -
1881
+ by_created(createdAt) -
1882
+ search_things(name, type, status);
1883
+
1884
+ connections: -from_type(fromThingId, relationshipType) -
1885
+ to_type(toThingId, relationshipType) -
1886
+ bidirectional(fromThingId, toThingId);
1887
+
1888
+ events: -thing_type_time(thingId, eventType, timestamp) -
1889
+ type_time(eventType, timestamp) -
1890
+ session(sessionId, timestamp);
1891
+
1892
+ knowledge: -by_type(knowledgeType) - by_source(sourceThingId) - by_created(createdAt);
1893
+ ```
1894
+
1895
+ ### Query Optimization
1896
+
1897
+ - Always use indexes for filters
1898
+ - Limit results with `.take(n)`
1899
+ - Paginate large result sets
1900
+ - Use `.collect()` sparingly, prefer streaming
1901
+
1902
+ ---
1903
+
1904
+ ## Event Retention & Archival
1905
+
1906
+ - Purpose: keep queries fast and costs predictable at scale.
1907
+ - Recommended windows (tune per deployment):
1908
+ - Hot (fast queries): last 30–90 days in primary `events` table, fully indexed.
1909
+ - Warm (historical analytics): 90–365 days; restrict heavy scans and rely on `type_time`/`actor_time`.
1910
+ - Cold archive: >365 days exported to warehouse/storage; query via batch jobs or precomputed aggregates.
1911
+ - Patterns:
1912
+ - Use `type_time` and `actor_time` for filters; avoid full scans.
1913
+ - Precompute aggregates into `metric` entities (daily revenue, views) to avoid wide re-reads.
1914
+ - Optional scheduled rollups to move very old events to archive and keep hot sets lean.
1915
+
1916
+ ---
1917
+
1918
+ ## Protocol Integration Examples
1919
+
1920
+ ### How Protocols Map to This Ontology
1921
+
1922
+ **Key Principle:** Our ontology is protocol-agnostic. Protocols identify themselves via `metadata.protocol`.
1923
+
1924
+ #### A2A Protocol (Agent-to-Agent)
1925
+
1926
+ ```typescript
1927
+ // Event: Agent delegates task
1928
+ {
1929
+ type: "task_delegated",
1930
+ actorId: oneAgentId,
1931
+ targetId: externalAgentId,
1932
+ timestamp: Date.now(),
1933
+ metadata: {
1934
+ protocol: "a2a",
1935
+ task: "research_market_trends",
1936
+ parameters: { industry: "fitness" }
1937
+ }
1938
+ }
1939
+
1940
+ // Connection: Agents communicate
1941
+ {
1942
+ fromThingId: oneAgentId,
1943
+ toThingId: externalAgentId,
1944
+ relationshipType: "communicates_with",
1945
+ metadata: {
1946
+ protocol: "a2a",
1947
+ platform: "elizaos",
1948
+ messagesExchanged: 42
1949
+ }
1950
+ }
1951
+ ```
1952
+
1953
+ #### ACP Protocol (Agentic Commerce)
1954
+
1955
+ ```typescript
1956
+ // Event: Purchase initiated
1957
+ {
1958
+ type: "commerce_event",
1959
+ actorId: agentId,
1960
+ targetId: transactionId,
1961
+ timestamp: Date.now(),
1962
+ metadata: {
1963
+ protocol: "acp",
1964
+ eventType: "purchase_initiated",
1965
+ agentPlatform: "chatgpt",
1966
+ productId: productId,
1967
+ amount: 99.00
1968
+ }
1969
+ }
1970
+
1971
+ // Connection: Merchant approves
1972
+ {
1973
+ fromThingId: merchantId,
1974
+ toThingId: transactionId,
1975
+ relationshipType: "approved",
1976
+ metadata: {
1977
+ protocol: "acp",
1978
+ approvalType: "transaction",
1979
+ approvedAt: Date.now()
1980
+ }
1981
+ }
1982
+ ```
1983
+
1984
+ #### AP2 Protocol (Agent Payments)
1985
+
1986
+ ```typescript
1987
+ // Event: Intent mandate created
1988
+ {
1989
+ type: "mandate_created",
1990
+ actorId: userId,
1991
+ targetId: mandateId,
1992
+ timestamp: Date.now(),
1993
+ metadata: {
1994
+ protocol: "ap2",
1995
+ mandateType: "intent",
1996
+ autoExecute: true,
1997
+ maxBudget: 1500
1998
+ }
1999
+ }
2000
+
2001
+ // Event: Price checked
2002
+ {
2003
+ type: "price_checked",
2004
+ actorId: agentId,
2005
+ targetId: intentMandateId,
2006
+ timestamp: Date.now(),
2007
+ metadata: {
2008
+ protocol: "ap2",
2009
+ productId: "prod_123",
2010
+ currentPrice: 1399,
2011
+ targetPrice: 1500,
2012
+ withinBudget: true
2013
+ }
2014
+ }
2015
+
2016
+ // Connection: Cart fulfills intent
2017
+ {
2018
+ fromThingId: intentMandateId,
2019
+ toThingId: cartMandateId,
2020
+ relationshipType: "fulfills",
2021
+ metadata: {
2022
+ protocol: "ap2",
2023
+ fulfillmentType: "intent_to_cart",
2024
+ matchScore: 0.95
2025
+ }
2026
+ }
2027
+ ```
2028
+
2029
+ #### X402 Protocol (HTTP Micropayments)
2030
+
2031
+ ```typescript
2032
+ // Event: Payment requested (402 status)
2033
+ {
2034
+ type: "payment_requested",
2035
+ actorId: apiServiceId,
2036
+ targetId: resourceId,
2037
+ timestamp: Date.now(),
2038
+ metadata: {
2039
+ protocol: "x402",
2040
+ scheme: "permit",
2041
+ network: "base",
2042
+ amount: "0.01",
2043
+ resource: "/api/agent/analyze"
2044
+ }
2045
+ }
2046
+
2047
+ // Event: Payment verified
2048
+ {
2049
+ type: "payment_verified",
2050
+ actorId: systemId,
2051
+ targetId: paymentId,
2052
+ timestamp: Date.now(),
2053
+ metadata: {
2054
+ protocol: "x402",
2055
+ network: "base",
2056
+ txHash: "0x...",
2057
+ verified: true
2058
+ }
2059
+ }
2060
+
2061
+ // Connection: Payment made
2062
+ {
2063
+ fromThingId: payerId,
2064
+ toThingId: serviceId,
2065
+ relationshipType: "transacted",
2066
+ metadata: {
2067
+ protocol: "x402",
2068
+ network: "base",
2069
+ amount: "0.01",
2070
+ txHash: "0x..."
2071
+ }
2072
+ }
2073
+ ```
2074
+
2075
+ #### AG-UI Protocol (CopilotKit Generative UI)
2076
+
2077
+ ```typescript
2078
+ // Event: UI component sent
2079
+ {
2080
+ type: "message_sent",
2081
+ actorId: agentId,
2082
+ targetId: conversationId,
2083
+ timestamp: Date.now(),
2084
+ metadata: {
2085
+ protocol: "ag-ui",
2086
+ messageType: "ui",
2087
+ component: "chart",
2088
+ data: { chartType: "line", ... }
2089
+ }
2090
+ }
2091
+
2092
+ // Connection: No connections needed (UI is stateless)
2093
+ ```
2094
+
2095
+ ### Cross-Protocol Queries
2096
+
2097
+ **All payments across all protocols:**
2098
+
2099
+ ```typescript
2100
+ const allPayments = await ctx.db
2101
+ .query('events')
2102
+ .filter((q) => q.eq(q.field('type'), 'payment_processed'))
2103
+ .collect();
2104
+ ```
2105
+
2106
+ **Only X402 blockchain payments:**
2107
+
2108
+ ```typescript
2109
+ const x402Payments = allPayments.filter((e) => e.metadata.protocol === 'x402');
2110
+ ```
2111
+
2112
+ **Total revenue by protocol:**
2113
+
2114
+ ```typescript
2115
+ const byProtocol = allPayments.reduce((acc, e) => {
2116
+ const protocol = e.metadata.protocol || 'traditional';
2117
+ acc[protocol] = (acc[protocol] || 0) + e.metadata.amount;
2118
+ return acc;
2119
+ }, {});
2120
+
2121
+ // Result: { x402: 1250, acp: 3400, ap2: 890, traditional: 5600 }
2122
+ ```
2123
+
2124
+ ---
2125
+
2126
+ ## Merged: Protocol Integration Requirements (from OntologyUpdates.md)
2127
+
2128
+ This section consolidates the proposal in `OntologyUpdates.md` into the ontology's protocol‑agnostic model. We preserve the 6‑dimension architecture (organizations, people, things, connections, events, knowledge) and use consolidated types + `metadata.protocol` for extensibility and query performance.
2129
+
2130
+ - Things
2131
+ - Keep consolidated `mandate` thing with `properties.mandateType: "intent" | "cart"` instead of separate `intent_mandate`/`cart_mandate` types. This reduces index fan‑out and simplifies queries while preserving full fidelity in `properties`.
2132
+ - Keep `product` (ACP/marketplace) and `payment` (transaction). For X402/AP2/ACP specifics, store details in `payment.properties` and event metadata (see below).
2133
+ - External integrations remain: `external_agent`, `external_workflow`, `external_connection`.
2134
+
2135
+ - Connections
2136
+ - Use existing specific types (e.g., `owns`, `member_of`, `holds_tokens`) plus consolidated types with metadata:
2137
+ - `communicated` for cross‑agent communication (A2A/ACP/AG‑UI)
2138
+ - `delegated` for task delegation/assignment
2139
+ - `approved` for approvals; `fulfilled` for fulfillment; `transacted` for financial relations
2140
+ - Protocol identity is always in `metadata.protocol`.
2141
+
2142
+ - Events (consolidated, protocol‑aware)
2143
+ - Use consolidated events already defined in this spec:
2144
+ - `payment_event` with `metadata.status: requested|verified|processed` (X402/AP2/ACP)
2145
+ - `commerce_event` with `metadata.eventType` (ACP/AP2)
2146
+ - `communication_event` with `metadata.messageType` (A2A/ACP/AG‑UI)
2147
+ - `task_event` with `metadata.action: delegated|completed|failed`
2148
+ - `mandate_event` with `metadata.mandateType: intent|cart` (AP2)
2149
+ - We map granular variants proposed in `OntologyUpdates.md` (e.g., `message_sent`, `task_delegated`, `price_checked`) to the consolidated forms for index efficiency and simpler analytics.
2150
+
2151
+ - Protocol‑specific properties (examples)
2152
+ - AP2 Mandate (stored on `mandate` thing):
2153
+ - `properties`: `{ mandateType: "intent"|"cart", intent?: {...}, items?: [...], subtotal, tax, total, status, signature, credentialHash, approvedAt?, completedAt? }`
2154
+ - X402/ACP/AP2 Payment (stored on `payment` thing and echoed in `payment_event.metadata`):
2155
+ - `properties`: `{ protocol: "x402"|"acp"|"ap2", scheme?, network?, amount, currency?, txHash?, invoiceId?, status }`
2156
+
2157
+ - Indexes (unchanged, validated)
2158
+ - `things`: `by_type`, `by_status`, `by_created`, plus `search_things(name, type, status)`
2159
+ - `connections`: `from_type`, `to_type`, `bidirectional`
2160
+ - `events`: `type_time`, `actor_time`, `thing_type_time`
2161
+ - `knowledge`: `by_type`, `by_source`, `by_created` (plus vector index when supported)
2162
+
2163
+ - Auth migration strategy (compatibility)
2164
+ - Existing auth tables (Better Auth: users, sessions, verification, resets, 2FA) remain intact.
2165
+ - Link `users` to `things` via optional `users.thingId` and backfill with an internal migration (see `OntologyUpdates.md`). This preserves zero‑downtime compatibility.
2166
+
2167
+ Rationale: Consolidation minimizes index cardinality, improves query ergonomics, and retains protocol fidelity in `metadata`/`properties`. This yields better beauty (clean mental model), completeness (coverage for all protocols), speed (lean indexes), and scalability (new protocols drop in via metadata).
2168
+
2169
+ ---
2170
+
2171
+ ## Extensibility: User-Safe Additions
2172
+
2173
+ Principle: Users can add to any type without breaking the ontology.
2174
+
2175
+ - Use `properties` for schema-free details; don’t edit core enums casually.
2176
+ - Use knowledge labels to categorize, filter, and group. Add labels freely without schema changes.
2177
+ - Use `metadata` on connections and events for protocol/workflow-specific context.
2178
+ - When a new subtype emerges (e.g., new content flavor), prefer:
2179
+ - Keep `type` stable (e.g., `video`).
2180
+ - Add `properties.kind` and labels (e.g., `format:webinar`, `topic:fitness`).
2181
+ - Introduce a new enum literal only when global indexes/constraints benefit.
2182
+ - Custom automations integrate via `external_agent`, `external_workflow`, and `external_connection` entities with `delegated`/`communicated` connections.
2183
+
2184
+ ---
2185
+
2186
+ ## Glossary (Compact)
2187
+
2188
+ - `entity` (thing): Any addressable object (creator, organization, content, product, payment, external_agent, mandate, etc.).
2189
+ - `connection` (state): Relationship between two entities (owns, member_of, transacted, fulfilled, delegated, communicated).
2190
+ - `event` (action): Time-stamped occurrence (content_changed, payment_event, communication_event, task_event, mandate_event).
2191
+ - `knowledge` (label/chunk): Classification and RAG units applied via `thingKnowledge` (labels like skill/industry/topic and chunks with embeddings).
2192
+ - `owner`: A `creator` with ownership responsibilities. Platform owner (platform_owner) or organization owner (org_owner). See `one/people/owner.md`.
2193
+ - `organization`: Multi-tenant container for users and resources. See `one/people/organisation.md`.
2194
+
2195
+ ---
2196
+
2197
+ ## Summary Statistics
2198
+
2199
+ **Dimensions:** 6 total (organizations, people, things, connections, events, knowledge)
2200
+
2201
+ **Thing Types:** 66 total
2202
+ - Core: 4 (creator, ai_clone, audience_member, organization)
2203
+ - Business Agents: 10
2204
+ - Content: 7
2205
+ - Products: 4
2206
+ - Community: 3
2207
+ - Token: 2
2208
+ - Knowledge: 2
2209
+ - Platform: 6
2210
+ - Business: 7
2211
+ - Authentication & Session: 5
2212
+ - Marketing: 6
2213
+ - External: 3
2214
+ - Protocol: 2
2215
+
2216
+ **Connection Types:** 25 total (Hybrid approach)
2217
+ - 18 specific semantic types
2218
+ - 7 consolidated types with metadata variants
2219
+ - Protocol-agnostic via metadata.protocol
2220
+ - Includes organization membership with role-based metadata
2221
+
2222
+ **Event Types:** 67 total (Hybrid approach)
2223
+ - 4 Thing lifecycle
2224
+ - 5 User events
2225
+ - 6 Authentication events
2226
+ - 5 Organization events
2227
+ - 4 Dashboard & UI events
2228
+ - 4 AI/Clone events
2229
+ - 4 Agent events
2230
+ - 7 Token events
2231
+ - 5 Course events
2232
+ - 5 Analytics events
2233
+ - 7 Inference events
2234
+ - 5 Blockchain events
2235
+ - 11 consolidated types with metadata variants
2236
+
2237
+ **Design Benefits:**
2238
+ - Six-dimension reality model
2239
+ - Multi-tenant by design
2240
+ - Clear ownership & governance
2241
+ - Protocol-agnostic core
2242
+ - Infinite protocol extensibility
2243
+ - Cross-protocol analytics
2244
+ - Type-safe
2245
+ - Future-proof
2246
+ - Scales from children to enterprise
2247
+
2248
+ ---
2249
+
2250
+ ## Knowledge Governance
2251
+
2252
+ Policy: Default is free-form, user-extensible knowledge labels for maximum flexibility and zero schema churn.
2253
+
2254
+ - Curated label prefixes (recommended): `skill:*`, `industry:*`, `topic:*`, `format:*`, `goal:*`, `audience:*`, `technology:*`, `status:*`, `capability:*`, `protocol:*`, `payment_method:*`, `network:*`.
2255
+ - Validation: Enforce label hygiene (no duplicates within scope); allow synonyms via an alias list if needed.
2256
+ - Ownership: Platform/organization owners may curate official labels; users can still apply ad‑hoc labels.
2257
+ - Hygiene: Periodically consolidate low-usage duplicates; do not delete knowledge items with active references—mark deprecated instead.
2258
+
2259
+ ---
2260
+
2261
+ ## Changelog
2262
+
2263
+ - 2025-10-07
2264
+ - Canonicalized terminology: “things” as the conceptual term; kept implementation table/fields as `entities` for compatibility.
2265
+ - Merged protocol integration requirements; clarified consolidated events/connections with `metadata.protocol`.
2266
+ - Added Event Retention & Archival guidance for scale.
2267
+ - Added Extensibility rules and a compact Glossary.
2268
+ - Added Knowledge Governance and links to `owner.md` and `organisation.md`.
2269
+
2270
+ **Thing Types:** 66 total
2271
+
2272
+ - Core: 4 (creator, ai_clone, audience_member, organization)
2273
+ - Business Agents: 10
2274
+ - Content: 7
2275
+ - Products: 4
2276
+ - Community: 3
2277
+ - Token: 2
2278
+ - Knowledge: 2
2279
+ - Platform: 6
2280
+ - Business: 7
2281
+ - Authentication & Session: 5 (session, oauth_account, verification_token, password_reset_token, ui_preferences)
2282
+ - Marketing: 6
2283
+ - External: 3
2284
+ - Protocol: 2
2285
+
2286
+ **Connection Types:** 25 total (Hybrid approach)
2287
+
2288
+ - 18 specific semantic types
2289
+ - 7 consolidated types with metadata variants
2290
+ - Protocol-agnostic via metadata.protocol
2291
+ - Includes organization membership with role-based metadata
2292
+
2293
+ **Event Types:** 63 total (Hybrid approach)
2294
+
2295
+ - 4 Thing lifecycle
2296
+ - 5 User events
2297
+ - 6 Authentication events (password_reset, email_verification, 2FA)
2298
+ - 5 Organization events (org_created, user_invited, user_joined)
2299
+ - 4 Dashboard & UI events (dashboard_viewed, theme_changed, settings_updated)
2300
+ - 4 AI/Clone events
2301
+ - 4 Agent events
2302
+ - 7 Token events
2303
+ - 5 Course events
2304
+ - 5 Analytics events
2305
+ - **7 Inference events** (NEW: inference_request, inference_completed, revenue_collected, quota_exceeded)
2306
+ - **5 Blockchain events** (NEW: nft_minted, nft_transferred, tokens_bridged, contract_deployed, treasury_withdrawal)
2307
+ - 11 consolidated types with metadata variants
2308
+ - Protocol identification via metadata.protocol + metadata.network
2309
+
2310
+ **Tag Categories:** 12 total
2311
+
2312
+ - Industry, skill, topic, format, goal, audience, technology, status
2313
+ - Plus: capability, protocol, payment_method, network
2314
+
2315
+ **Design Benefits:**
2316
+
2317
+ - ✅ Single source of truth
2318
+ - ✅ Protocol-agnostic core
2319
+ - ✅ Infinite protocol extensibility
2320
+ - ✅ Cross-protocol analytics
2321
+ - ✅ Clean, maintainable
2322
+ - ✅ Type-safe
2323
+ - ✅ Future-proof
2324
+
2325
+ ---
2326
+
2327
+ **END OF ONTOLOGY SPECIFICATION**
2328
+
2329
+ ## The Philosophy
2330
+
2331
+ **Simplicity is the ultimate sophistication.**
2332
+
2333
+ This ontology proves that you don't need hundreds of tables or complex schemas to build a complete AI-native platform. You need:
2334
+
2335
+ 1. **6 dimensions** (organizations, people, things, connections, events, knowledge)
2336
+ 2. **66 thing types** (every "thing")
2337
+ 3. **25 connection types** (every relationship)
2338
+ 4. **67 event types** (every action)
2339
+ 5. **Metadata** (for protocol identity via metadata.protocol)
2340
+
2341
+ That's it. Everything else is just data.
2342
+
2343
+ ### Why This Works
2344
+
2345
+ **Other systems:**
2346
+
2347
+ - Create new tables for every feature
2348
+ - Add protocol-specific columns
2349
+ - Pollute schema with temporary concepts
2350
+ - End up with 50+ tables, 200+ columns
2351
+ - Become unmaintainable nightmares
2352
+
2353
+ **ONE's approach:**
2354
+
2355
+ - Map every feature to 6 dimensions
2356
+ - Organizations partition the space
2357
+ - People authorize and govern
2358
+ - Things, connections, events flow from there
2359
+ - Knowledge understands it all
2360
+ - Scale infinitely without schema changes
2361
+ - Stay simple, clean, beautiful
2362
+
2363
+ ### The Result
2364
+
2365
+ A database schema that:
2366
+
2367
+ - Scales from lemonade stands to global enterprises
2368
+ - Children can understand: "I own (org), I'm the boss (person), I sell lemonade (things)"
2369
+ - Enterprises can rely on: Multi-tenant isolation, clear governance, infinite scale
2370
+ - AI agents can reason about completely
2371
+ - Never needs breaking changes
2372
+ - Grows more powerful as it grows larger
2373
+
2374
+ **This is what happens when you design for clarity first.**
2375
+
2376
+ ---
2377
+
2378
+ ## Frontend Integration Examples
2379
+
2380
+ ### How the Frontend Uses This Ontology
2381
+
2382
+ The Astro frontend (documented in `Frontend.md`) uses this ontology through:
2383
+
2384
+ 1. **Astro Content Collections** - Can load entities as typed collections
2385
+ 2. **Convex Hooks** - Real-time subscriptions to entity/connection/event data
2386
+ 3. **Hono API** - Complex mutations that create/update entities and log events
2387
+
2388
+ **Example: Multi-Tenant Dashboard**
2389
+
2390
+ ```typescript
2391
+ // Frontend Component (src/components/admin/OrganizationList.tsx)
2392
+ import { useQuery } from 'convex/react';
2393
+ import { api } from '@/convex/_generated/api';
2394
+
2395
+ export function OrganizationList() {
2396
+ // Query organizations (type: "organization")
2397
+ const orgs = useQuery(api.queries.admin.listOrganizations);
2398
+
2399
+ return (
2400
+ <div>
2401
+ {orgs?.map(org => (
2402
+ <Card key={org._id}>
2403
+ <CardHeader>
2404
+ <CardTitle>{org.name}</CardTitle>
2405
+ <Badge>{org.properties.plan}</Badge>
2406
+ </CardHeader>
2407
+ <CardContent>
2408
+ <p>{org.properties.usage.users} / {org.properties.limits.users} users</p>
2409
+ <p>Status: {org.properties.status}</p>
2410
+ </CardContent>
2411
+ </Card>
2412
+ ))}
2413
+ </div>
2414
+ );
2415
+ }
2416
+ ```
2417
+
2418
+ **Example: Authentication Flow**
2419
+
2420
+ ```typescript
2421
+ // Password reset request creates:
2422
+ // 1. Entity: password_reset_token
2423
+ // 2. Event: password_reset_requested
2424
+
2425
+ // Backend (Convex mutation)
2426
+ export const requestPasswordReset = mutation({
2427
+ handler: async (ctx, { email }) => {
2428
+ // 1. Find user entity
2429
+ const user = await ctx.db
2430
+ .query('entities')
2431
+ .filter((q) => q.eq(q.field('properties.email'), email))
2432
+ .first();
2433
+
2434
+ if (!user) return { success: true }; // Don't reveal if user exists
2435
+
2436
+ // 2. Create password_reset_token entity
2437
+ const tokenId = await ctx.db.insert('entities', {
2438
+ type: 'password_reset_token',
2439
+ name: `Reset token for ${email}`,
2440
+ properties: {
2441
+ userId: user._id,
2442
+ token: hashedToken,
2443
+ expiresAt: Date.now() + 30 * 60 * 1000,
2444
+ },
2445
+ status: 'active',
2446
+ createdAt: Date.now(),
2447
+ updatedAt: Date.now(),
2448
+ });
2449
+
2450
+ // 3. Log event
2451
+ await ctx.db.insert('events', {
2452
+ type: 'password_reset_requested',
2453
+ actorId: user._id,
2454
+ targetId: tokenId,
2455
+ timestamp: Date.now(),
2456
+ metadata: {
2457
+ email,
2458
+ ipAddress: ctx.auth.sessionId,
2459
+ expiresAt: Date.now() + 30 * 60 * 1000,
2460
+ },
2461
+ });
2462
+
2463
+ return { success: true };
2464
+ },
2465
+ });
2466
+
2467
+ // Frontend usage
2468
+ import { useMutation } from 'convex/react';
2469
+
2470
+ export function PasswordResetForm() {
2471
+ const requestReset = useMutation(api.auth.requestPasswordReset);
2472
+
2473
+ const handleSubmit = async (email: string) => {
2474
+ await requestReset({ email });
2475
+ // Show success message
2476
+ };
2477
+ }
2478
+ ```
2479
+
2480
+ **Example: Organization Membership Check**
2481
+
2482
+ ```typescript
2483
+ // Check if user is org_owner (Middleware.md pattern)
2484
+ export const checkOrgOwner = query({
2485
+ args: { userId: v.id('entities'), orgId: v.id('entities') },
2486
+ handler: async (ctx, { userId, orgId }) => {
2487
+ // Query connection with role metadata
2488
+ const membership = await ctx.db
2489
+ .query('connections')
2490
+ .withIndex('from_type', (q) =>
2491
+ q
2492
+ .eq('fromThingId', userId)
2493
+ .eq('toThingId', orgId)
2494
+ .eq('relationshipType', 'member_of')
2495
+ )
2496
+ .first();
2497
+
2498
+ return membership?.metadata?.role === 'org_owner';
2499
+ },
2500
+ });
2501
+
2502
+ // Frontend usage in middleware
2503
+ import { ConvexHttpClient } from 'convex/browser';
2504
+
2505
+ export async function checkAccess(userId: string, orgId: string) {
2506
+ const convex = new ConvexHttpClient(env.CONVEX_URL);
2507
+ const isOwner = await convex.query(api.auth.checkOrgOwner, { userId, orgId });
2508
+
2509
+ if (!isOwner) {
2510
+ throw new Error('Forbidden: Org owner access required');
2511
+ }
2512
+ }
2513
+ ```
2514
+
2515
+ **Example: Dashboard Analytics**
2516
+
2517
+ ```typescript
2518
+ // Query events for analytics (Dashboard.md pattern)
2519
+ export const getOrgAnalytics = query({
2520
+ args: { orgId: v.id('entities'), days: v.number() },
2521
+ handler: async (ctx, { orgId, days }) => {
2522
+ const since = Date.now() - days * 24 * 60 * 60 * 1000;
2523
+
2524
+ // Get all dashboard_viewed events for org users
2525
+ const orgMembers = await ctx.db
2526
+ .query('connections')
2527
+ .withIndex('to_type', (q) =>
2528
+ q.eq('toThingId', orgId).eq('relationshipType', 'member_of')
2529
+ )
2530
+ .collect();
2531
+
2532
+ const memberIds = orgMembers.map((m) => m.fromThingId);
2533
+
2534
+ const dashboardViews = await ctx.db
2535
+ .query('events')
2536
+ .withIndex('type_time', (q) =>
2537
+ q.eq('type', 'dashboard_viewed').gte('timestamp', since)
2538
+ )
2539
+ .filter((q) => memberIds.includes(q.field('actorId')))
2540
+ .collect();
2541
+
2542
+ return {
2543
+ totalViews: dashboardViews.length,
2544
+ uniqueUsers: new Set(dashboardViews.map((e) => e.actorId)).size,
2545
+ averageSessionDuration:
2546
+ dashboardViews.reduce(
2547
+ (sum, e) => sum + (e.metadata.sessionDuration || 0),
2548
+ 0
2549
+ ) / dashboardViews.length,
2550
+ };
2551
+ },
2552
+ });
2553
+ ```
2554
+
2555
+ **Example: UI Preferences Sync**
2556
+
2557
+ ```typescript
2558
+ // Update user preferences (creates ui_preferences thing if not exists)
2559
+ export const updatePreferences = mutation({
2560
+ args: {
2561
+ userId: v.id('entities'),
2562
+ theme: v.optional(
2563
+ v.union(v.literal('light'), v.literal('dark'), v.literal('system'))
2564
+ ),
2565
+ language: v.optional(v.string()),
2566
+ },
2567
+ handler: async (ctx, { userId, theme, language }) => {
2568
+ // Get or create ui_preferences entity
2569
+ let prefs = await ctx.db
2570
+ .query('entities')
2571
+ .withIndex('by_type', (q) => q.eq('type', 'ui_preferences'))
2572
+ .filter((q) => q.eq(q.field('properties.userId'), userId))
2573
+ .first();
2574
+
2575
+ if (!prefs) {
2576
+ // Create new preferences entity
2577
+ const prefsId = await ctx.db.insert('entities', {
2578
+ type: 'ui_preferences',
2579
+ name: `Preferences for user ${userId}`,
2580
+ properties: {
2581
+ userId,
2582
+ theme: theme || 'system',
2583
+ language: language || 'en',
2584
+ timezone: 'UTC',
2585
+ dashboardLayout: {
2586
+ sidebarCollapsed: false,
2587
+ defaultView: 'grid',
2588
+ itemsPerPage: 20,
2589
+ },
2590
+ notifications: { email: true, push: false, sms: false, inApp: true },
2591
+ accessibility: {
2592
+ reducedMotion: false,
2593
+ highContrast: false,
2594
+ fontSize: 'medium',
2595
+ },
2596
+ updatedAt: Date.now(),
2597
+ },
2598
+ status: 'active',
2599
+ createdAt: Date.now(),
2600
+ updatedAt: Date.now(),
2601
+ });
2602
+
2603
+ prefs = await ctx.db.get(prefsId);
2604
+ } else {
2605
+ // Update existing preferences
2606
+ await ctx.db.patch(prefs._id, {
2607
+ properties: {
2608
+ ...prefs.properties,
2609
+ theme: theme || prefs.properties.theme,
2610
+ language: language || prefs.properties.language,
2611
+ updatedAt: Date.now(),
2612
+ },
2613
+ updatedAt: Date.now(),
2614
+ });
2615
+ }
2616
+
2617
+ // Log preferences_updated event
2618
+ if (theme) {
2619
+ await ctx.db.insert('events', {
2620
+ type: 'theme_changed',
2621
+ actorId: userId,
2622
+ targetId: prefs._id,
2623
+ timestamp: Date.now(),
2624
+ metadata: {
2625
+ previousTheme: prefs.properties.theme,
2626
+ newTheme: theme,
2627
+ },
2628
+ });
2629
+ }
2630
+
2631
+ return { success: true };
2632
+ },
2633
+ });
2634
+
2635
+ // Frontend hook
2636
+ export function usePreferences(userId: string) {
2637
+ const prefs = useQuery(api.queries.preferences.get, { userId });
2638
+ const updatePrefs = useMutation(api.mutations.preferences.update);
2639
+
2640
+ return { preferences: prefs?.properties, updatePreferences: updatePrefs };
2641
+ }
2642
+ ```
2643
+
2644
+ ### Key Frontend Patterns
2645
+
2646
+ **1. Thing as Content Collection**
2647
+
2648
+ ```typescript
2649
+ // src/content/config.ts
2650
+ const agentsCollection = defineCollection({
2651
+ type: 'data',
2652
+ loader: async () => {
2653
+ const convex = new ConvexHttpClient(env.CONVEX_URL);
2654
+ const agents = await convex.query(api.queries.entities.list, {
2655
+ type: 'strategy_agent',
2656
+ });
2657
+ return agents;
2658
+ },
2659
+ });
2660
+ ```
2661
+
2662
+ **2. Real-time Dashboard Stats**
2663
+
2664
+ ```tsx
2665
+ export function DashboardStats({ orgId }) {
2666
+ // Subscribes to changes - auto-updates when events are logged!
2667
+ const stats = useQuery(api.queries.dashboard.getStats, { orgId });
2668
+
2669
+ return <StatsCards data={stats} />;
2670
+ }
2671
+ ```
2672
+
2673
+ **3. Permission-Based Rendering**
2674
+
2675
+ ```tsx
2676
+ export function AdminPanel({ userId, orgId }) {
2677
+ const membership = useQuery(api.queries.orgs.getMembership, {
2678
+ userId,
2679
+ orgId,
2680
+ });
2681
+
2682
+ if (membership?.metadata?.role !== 'org_owner') {
2683
+ return <div>Access denied</div>;
2684
+ }
2685
+
2686
+ return <AdminDashboard />;
2687
+ }
2688
+ ```
2689
+
2690
+ **4. Astro SSR with Ontology**
2691
+
2692
+ ```astro
2693
+ ---
2694
+ // src/pages/org/[orgId]/dashboard.astro
2695
+ import { ConvexHttpClient } from 'convex/browser';
2696
+ import { api } from '@/convex/_generated/api';
2697
+
2698
+ const convex = new ConvexHttpClient(import.meta.env.PUBLIC_CONVEX_URL);
2699
+
2700
+ // Fetch organization entity
2701
+ const org = await convex.query(api.queries.entities.get, {
2702
+ id: Astro.params.orgId,
2703
+ });
2704
+
2705
+ // Fetch org members (connections where relationshipType = "member_of")
2706
+ const members = await convex.query(api.queries.orgs.getMembers, {
2707
+ orgId: Astro.params.orgId,
2708
+ });
2709
+ ---
2710
+
2711
+ <Layout title={org.name}>
2712
+ <h1>{org.name} Dashboard</h1>
2713
+ <p>Plan: {org.properties.plan}</p>
2714
+ <p>Members: {members.length} / {org.properties.limits.users}</p>
2715
+
2716
+ <!-- Real-time stats component -->
2717
+ <OrgStats client:load orgId={org._id} />
2718
+ </Layout>
2719
+ ```
2720
+
2721
+ This demonstrates how the complete ontology (things, connections, events, knowledge) powers the entire frontend architecture through clean, type-safe queries and real-time subscriptions.
2722
+
2723
+ ---
2724
+
2725
+ ## For Implementers
2726
+
2727
+ **AI agents:** When implementing ANY feature, start by asking:
2728
+
2729
+ 1. What **entities** are involved?
2730
+ 2. What **connections** link them?
2731
+ 3. What **events** need to be logged?
2732
+ 4. What **knowledge labels** categorize them?
2733
+ 5. What **protocol** is this for? (add to metadata)
2734
+ 6. What **knowledge** (labels + chunks) should be linked?
2735
+
2736
+ **Humans:** Your AI agents now have a complete, unambiguous data model. They will generate consistent database operations because they understand the underlying structure.
2737
+
2738
+ **Developers:** You have a schema that will never need major refactoring. Just add new thing types as needed, use existing event types with metadata, and enjoy the simplicity.
2739
+
2740
+ **This ontology is complete. It's ready for production.**
2741
+
2742
+ ---
2743
+
2744
+ ## RAG Ingestion Strategy for `one/`
2745
+
2746
+ Objective: attach vectors to every relevant piece of content to enable high‑quality retrieval, while preserving ontology simplicity.
2747
+
2748
+ 1) Inventory sources (by thing type)
2749
+ - Text bodies: `blog_post.content`, `social_post.text`, `email.content`, `lesson.content`, `course.description`, `website.page.html (stripped)`
2750
+ - Transcripts: `video.transcript`, `podcast.transcript`, `livestream.recording.transcript`
2751
+ - Metadata: titles, summaries, captions
2752
+
2753
+ 2) Chunking standard
2754
+ - Window: ~800 tokens; overlap: ~200 tokens; language‑aware sentence boundaries when possible.
2755
+ - Store per‑chunk: `{ index, tokenCount, start, end, overlap }`.
2756
+
2757
+ 3) Embedding policy
2758
+ - Model: configurable via env (e.g., `text-embedding-3-large`). Store `embeddingModel` + `embeddingDim` per knowledge item.
2759
+ - PII/Privacy: use `knowledgeType: 'vector_only'` for sensitive texts; omit `text` and keep only embeddings + hashes.
2760
+
2761
+ 4) Ingestion pipeline
2762
+ - Mutation: `scheduleEmbeddingForThing({ thingId, fields[] })` validates and enqueues work.
2763
+ - Internal action: `embedText({ text, model })` calls provider and returns `embedding`.
2764
+ - Internal mutation: `upsertKnowledgeChunks({ thingId, chunks[] })` writes `knowledge` items and links via `thingKnowledge` with role `chunk_of`.
2765
+ - Event log: `content_changed` on source updates triggers re‑embedding (debounced) via scheduler.
2766
+
2767
+ 5) Query + retrieval
2768
+ - Vector search over `knowledge` filtered by org, creator, and content type; k‑NN approximate index when available, else provider‑side search.
2769
+ - Hybrid scoring: combine semantic similarity with lexical signals from `labels` and metadata.
2770
+
2771
+ 6) Governance + lifecycle
2772
+ - Versioning: keep `metadata.hash` of source; if unchanged, skip.
2773
+ - Retention: archive old chunks on major edits; GC orphaned knowledge items.
2774
+ - Quality: track `metadata.qualityScore` and `feedback` for active learning.
2775
+
2776
+ Example (Convex pseudo‑API)
2777
+
2778
+ ```typescript
2779
+ // internal action: embed text
2780
+ export const embedText = internalAction({
2781
+ args: { text: v.string(), model: v.optional(v.string()) },
2782
+ handler: async (ctx, { text, model }) => {
2783
+ const embedding = await callEmbedProvider(text, model);
2784
+ return { embedding, model: model || 'text-embedding-3-large', dim: embedding.length };
2785
+ },
2786
+ });
2787
+
2788
+ // mutation: schedule embedding for a thing
2789
+ export const scheduleEmbeddingForThing = mutation({
2790
+ args: { id: v.id('things'), fields: v.optional(v.array(v.string())) },
2791
+ handler: async (ctx, { id, fields }) => {
2792
+ await ctx.scheduler.runAfter(0, internal.rag.ingestThing, { id, fields });
2793
+ },
2794
+ });
2795
+
2796
+ // internal action: ingest a thing into knowledge
2797
+ export const ingestThing = internalAction({
2798
+ args: { id: v.id('things'), fields: v.optional(v.array(v.string())) },
2799
+ handler: async (ctx, { id, fields }) => {
2800
+ const thing = await ctx.runQuery(internal.entities.get, { id });
2801
+ const texts = extractTexts(thing, fields);
2802
+ let index = 0;
2803
+ for (const t of chunk(texts, { size: 800, overlap: 200 })) {
2804
+ const { embedding, model, dim } = await ctx.runAction(internal.rag.embedText, { text: t.text });
2805
+ const knowledgeId = await ctx.runMutation(internal.rag.upsertKnowledge, {
2806
+ item: {
2807
+ knowledgeType: 'chunk', text: t.text, embedding, embeddingModel: model, embeddingDim: dim,
2808
+ sourceThingId: id, sourceField: t.field, chunk: { index, tokenCount: t.tokens, overlap: 200 },
2809
+ labels: t.labels,
2810
+ },
2811
+ });
2812
+ await ctx.runMutation(internal.rag.linkThingKnowledge, { thingId: id, knowledgeId, role: 'chunk_of' });
2813
+ index++;
2814
+ }
2815
+ },
2816
+ });
2817
+ ```
2818
+
2819
+ This strategy keeps vectors first‑class without expanding primitives: knowledge absorbs both legacy tags (as labels) and semantic chunks (as embeddings).