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