oneie 3.6.7 → 3.6.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/.claude/agents/agent-backend.md +83 -0
  2. package/.claude/agents/agent-designer.md +97 -0
  3. package/.claude/agents/agent-director.md +118 -7
  4. package/.claude/agents/agent-documenter.md +93 -0
  5. package/.claude/agents/agent-frontend.md +96 -0
  6. package/.claude/agents/agent-ops.md +264 -32
  7. package/.claude/agents/agent-problem-solver.md +166 -0
  8. package/.claude/agents/agent-quality.md +127 -0
  9. package/.claude/commands/build.md +293 -0
  10. package/.claude/commands/cascade.md +231 -127
  11. package/.claude/commands/deploy.md +56 -17
  12. package/.claude/commands/mcp-toggle.md +93 -0
  13. package/.claude/commands/one.md +78 -127
  14. package/.claude/commands/plan.md +394 -80
  15. package/.claude/commands/push.md +75 -14
  16. package/.claude/commands/release.md +89 -25
  17. package/.claude/commands/server.md +2 -0
  18. package/.claude/hooks/__pycache__/todo.cpython-313.pyc +0 -0
  19. package/.claude/hooks/root-cleanup.py +75 -0
  20. package/.claude/skills/INDEX.md +523 -0
  21. package/.claude/skills/REGISTRY.md +529 -0
  22. package/.claude/skills/agent-backend-create-mutation.md +319 -0
  23. package/.claude/skills/agent-designer-create-wireframe.md +341 -0
  24. package/.claude/skills/agent-frontend-create-page.md +413 -0
  25. package/.claude/skills/agents/README.md +238 -0
  26. package/dist/clone-web.js +1 -1
  27. package/dist/clone-web.js.map +1 -1
  28. package/folders.yaml +1 -1
  29. package/one/.obsidian/workspace.json +38 -38
  30. package/one/connections/api/queries-reference.md +842 -0
  31. package/one/connections/api-reference.md +1011 -0
  32. package/one/connections/integration-examples.md +875 -0
  33. package/one/connections/integration-guide.md +869 -0
  34. package/one/connections/integration-phase2.md +736 -0
  35. package/one/events/API_ROUTES_FIXES_SUMMARY.md +262 -0
  36. package/one/events/ASTRO-INTEGRATION-EXAMPLES.md +636 -0
  37. package/one/events/BEFORE_AFTER_COMPARISON.md +960 -0
  38. package/one/events/CONNECTIONS_DEMO.md +501 -0
  39. package/one/events/DELIVERABLES.md +432 -0
  40. package/one/events/DEMO-GROUPS-PAGE.md +392 -0
  41. package/one/events/DEMO-TESTING-SUMMARY.md +518 -0
  42. package/one/events/DEMO_COMPONENTS.md +487 -0
  43. package/one/events/DEMO_HOOKS_INDEX.md +334 -0
  44. package/one/events/DEMO_INFRASTRUCTURE.md +905 -0
  45. package/one/events/DEMO_INFRASTRUCTURE_SUMMARY.md +570 -0
  46. package/one/events/DEMO_INTEGRATION_CHECKLIST.md +431 -0
  47. package/one/events/DEMO_QUICK_REFERENCE.md +441 -0
  48. package/one/events/DEMO_SETUP.md +476 -0
  49. package/one/events/EFFECT_TS_API_PATTERN.md +478 -0
  50. package/one/events/GROUPS_DEMO_IMPLEMENTATION.md +414 -0
  51. package/one/events/HOOKS-DEMO.md +441 -0
  52. package/one/events/ONTOLOGY-HOOKS-README.md +700 -0
  53. package/one/events/ONTOLOGY-INTEGRATION-MANIFEST.md +365 -0
  54. package/one/events/QA-CHECKLIST.md +674 -0
  55. package/one/events/QUICK-START-ONTOLOGY.md +408 -0
  56. package/one/events/SEARCH_DEMO_CODE_REFERENCE.md +639 -0
  57. package/one/events/SEARCH_DEMO_DELIVERY.md +415 -0
  58. package/one/events/SEARCH_DEMO_SUMMARY.md +303 -0
  59. package/one/events/SEARCH_DEMO_VISUAL_GUIDE.md +381 -0
  60. package/one/events/TEST-PLAN-INDEX.md +346 -0
  61. package/one/events/TEST-PLAN.md +1417 -0
  62. package/one/events/TESTING-DELIVERY.txt +372 -0
  63. package/one/events/TRANSITIONS-QUICK-START.md +141 -0
  64. package/one/events/TYPESCRIPT_FIXES.md +152 -0
  65. package/one/events/TYPESCRIPT_FIXES_COMPLETE.txt +412 -0
  66. package/one/events/TYPESCRIPT_FIXES_INDEX.md +341 -0
  67. package/one/events/VIEW-TRANSITIONS.md +428 -0
  68. package/one/events/backend-integration-tests.md +606 -0
  69. package/one/events/backend-structure-diagram.txt +393 -0
  70. package/one/events/backend-structure-summary.txt +269 -0
  71. package/one/events/cloudflare-pages-infrastructure-setup.md +264 -0
  72. package/one/events/convex-analysis-index.md +304 -0
  73. package/one/events/convex-structure-analysis.md +700 -0
  74. package/one/events/design-spec-complete.md +208 -0
  75. package/one/events/ontology-test-examples.md +562 -0
  76. package/one/events/phase1-backend-implementation-complete.md +518 -0
  77. package/one/events/test-dashboard.md +345 -0
  78. package/one/events/test-index.md +361 -0
  79. package/one/events/test-report-ontology.md +582 -0
  80. package/one/events/testing-summary.md +344 -0
  81. package/one/groups/features.md +2878 -0
  82. package/one/groups/strategy copy.md +869 -0
  83. package/one/knowledge/backend-api-reference.md +710 -0
  84. package/one/knowledge/documentation-summary.md +285 -0
  85. package/one/knowledge/lessons-learned.md +294 -4
  86. package/one/knowledge/ontology-visual-guide.md +360 -0
  87. package/one/knowledge/ontology.md +9 -17
  88. package/one/things/demo-accessibility-animations.md +999 -0
  89. package/one/things/demo-components.md +1304 -0
  90. package/one/things/demo-design-summary.md +629 -0
  91. package/one/things/demo-design-system.md +919 -0
  92. package/one/things/demo-page-layouts.md +989 -0
  93. package/one/things/designs/accessibility-audit.md +790 -0
  94. package/one/things/designs/component-specifications.md +757 -0
  95. package/one/things/designs/design-overview.md +318 -0
  96. package/one/things/designs/design-tokens.md +414 -0
  97. package/one/things/designs/wireframes-dashboard.md +653 -0
  98. package/one/things/docs/api-requests.md +923 -0
  99. package/one/things/features/0 All Features.md +2 -0
  100. package/one/things/implementation/backend-guide.md +412 -0
  101. package/one/things/plans/2-backend-agnostic-frontend.md +11 -8
  102. package/one/things/plans/2-sites.md +895 -0
  103. package/one/things/plans/ai-elements.md +1259 -0
  104. package/one/things/plans/ai-integration.md +947 -0
  105. package/one/things/plans/ai-sdk.md +761 -0
  106. package/one/things/plans/app.md +1 -1
  107. package/one/things/plans/architecture-summary.md +283 -0
  108. package/one/things/plans/async-ai-agents.md +215 -0
  109. package/one/things/plans/backend-agnostic-frontend.md +11 -6
  110. package/one/things/plans/backend-cleanup-quickstart.md +346 -0
  111. package/one/things/plans/backend-ontology-conformance.md +416 -0
  112. package/one/things/plans/backend-status.md +541 -0
  113. package/one/things/plans/backend-structure.md +799 -0
  114. package/one/things/plans/backend-target-structure.md +438 -0
  115. package/one/things/plans/backend.md +1133 -0
  116. package/one/things/plans/better-auth-any-backend.md +11 -11
  117. package/one/things/plans/cli-updates-required.md +280 -0
  118. package/one/things/plans/complete-step-by-step.md +1302 -0
  119. package/one/things/plans/convex-agents.md +1005 -0
  120. package/one/things/plans/deployment-architecture.md +426 -0
  121. package/one/things/plans/development-plan.md +1220 -0
  122. package/one/things/plans/effect.md +808 -48
  123. package/one/things/plans/integrate-frontend-and-backend.md +579 -0
  124. package/one/things/plans/mcp-clear-context-prompt.md +60 -0
  125. package/one/things/plans/mcp-simple.md +228 -0
  126. package/one/things/plans/one.md +8 -7
  127. package/one/things/plans/ontology-6-dimensions.md +20 -14
  128. package/one/things/plans/quick-wins.md +1273 -0
  129. package/one/things/plans/readme-backend-cleanup.md +361 -0
  130. package/one/things/plans/separate-demo.md +830 -0
  131. package/one/things/plans/separate.md +3 -3
  132. package/one/things/plans/sequence.md +1897 -0
  133. package/one/things/plans/sync-checklist.md +321 -0
  134. package/one/things/plans/unified-implementation-plan.md +3 -3
  135. package/one/things/plans/update-demos.md +513 -0
  136. package/package.json +1 -1
  137. package/.claude/agents/backend-specialist.md +0 -169
  138. package/.claude/agents/designer.md +0 -216
  139. package/.claude/agents/frontend-specialist.md +0 -236
  140. package/.claude/commands/done.md +0 -35
  141. package/.claude/commands/infer.md +0 -138
  142. package/.claude/commands/next.md +0 -53
  143. package/.claude/commands/one copy.md +0 -565
  144. package/.claude/commands/one-template.md +0 -106
  145. package/.claude/commands/one-v1.md +0 -609
  146. package/.claude/hooks/__pycache__/knowledge-post.cpython-313.pyc +0 -0
  147. package/.claude/hooks/__pycache__/knowledge-pre.cpython-313.pyc +0 -0
  148. package/one/groups/nine-padel-customers.md +0 -138
  149. package/one/groups/nine-padel-data-structure.md +0 -167
  150. package/one/groups/nine-padel-ontology-specification.md +0 -359
  151. package/one/groups/nine-padel-ontology.md +0 -143
  152. package/one/groups/nine-padel-strategy.md +0 -234
  153. package/one/groups/nine-padel.md +0 -211
  154. package/one/groups/nine-padle-contents.baked.md +0 -1252
  155. package/one/groups/nine-padle-contents.md +0 -6
  156. package/one/things/features/1-1-agent-prompts/design.md +0 -470
  157. package/one/things/features/1-1-agent-prompts/tests.md +0 -264
  158. package/one/things/features/1-2-yaml-orchestrator/design.md +0 -497
  159. package/one/things/features/1-2-yaml-orchestrator/tests.md +0 -227
  160. package/one/things/features/1-3-event-coordination/design.md +0 -544
  161. package/one/things/features/1-3-event-coordination/tests.md +0 -223
  162. package/one/things/features/1-4-knowledge-management/design.md +0 -609
  163. package/one/things/features/1-4-knowledge-management/tests.md +0 -195
  164. package/one/things/features/1-5-quality-loops/design.md +0 -797
  165. package/one/things/features/1-5-quality-loops/tests.md +0 -212
  166. package/one/things/features/1-6-numbering-structure/design.md +0 -610
  167. package/one/things/features/1-6-numbering-structure/tests.md +0 -213
  168. package/one/things/features/dataprovider-interface/1-tests.md +0 -1522
@@ -0,0 +1,842 @@
1
+ # Queries Reference - 6-Dimension Ontology API
2
+
3
+ ## Executive Summary
4
+
5
+ Complete reference documentation for all backend queries (`convex/queries/`) aligned with the ONE Platform's 6-dimension ontology. This consolidated guide covers overview, complete specifications, and practical examples.
6
+
7
+ **Status**: Complete and Production-Ready
8
+ **Total Queries**: 44 across 6 dimensions
9
+ **Documentation Levels**: Overview → Complete Reference → Practical Examples
10
+
11
+ ---
12
+
13
+ ## Table of Contents
14
+
15
+ 1. [Overview](#overview)
16
+ 2. [The 6-Dimension Reality Model](#the-6-dimension-reality-model)
17
+ 3. [Query Organization by Dimension](#query-organization-by-dimension)
18
+ 4. [Complete Query Reference](#complete-query-reference)
19
+ 5. [Query Naming Conventions](#query-naming-conventions)
20
+ 6. [Multi-Tenancy Pattern](#multi-tenancy-pattern)
21
+ 7. [Performance Optimization](#performance-optimization)
22
+ 8. [Practical Examples](#practical-examples)
23
+ 9. [Ontology Runtime Discovery](#ontology-runtime-discovery)
24
+ 10. [Adding New Queries](#adding-new-queries)
25
+
26
+ ---
27
+
28
+ ## Overview
29
+
30
+ ### The 6-Dimension Reality Model
31
+
32
+ ```
33
+ GROUPS (1)
34
+ ↓ owns/contains
35
+ PEOPLE (2)
36
+ ↓ authorize
37
+ THINGS (3)
38
+ ↓ are related via
39
+ CONNECTIONS (4)
40
+ ↓ trigger
41
+ EVENTS (5)
42
+ ↓ create
43
+ KNOWLEDGE (6)
44
+ ```
45
+
46
+ ### Query Organization
47
+
48
+ All backend queries are organized by dimension into 6 files:
49
+
50
+ ```
51
+ convex/queries/
52
+ ├── groups.ts → DIMENSION 1 (Multi-tenant isolation) [12 queries]
53
+ ├── people.ts → DIMENSION 2 (Authorization & governance) [4 queries]
54
+ ├── entities.ts → DIMENSION 3 (66+ entity types) [9 queries]
55
+ ├── connections.ts → DIMENSION 4 (25+ relationship types) [4 queries]
56
+ ├── events.ts → DIMENSION 5 (67+ event types - audit) [7 queries]
57
+ ├── knowledge.ts → DIMENSION 6 (Vectors, embeddings, RAG) [8 queries]
58
+ └── ontology.ts → Runtime feature discovery [special]
59
+
60
+ TOTAL: 44 production queries
61
+ ```
62
+
63
+ ---
64
+
65
+ ## The 6-Dimension Reality Model
66
+
67
+ ```
68
+ GROUPS (1)
69
+ ├─ Multi-tenant isolation boundary
70
+ ├─ Hierarchical nesting (groups in groups)
71
+ └─ Plans: starter, pro, enterprise
72
+
73
+ PEOPLE (2)
74
+ ├─ Authorization & governance
75
+ ├─ 4 roles: platform_owner, org_owner, org_user, customer
76
+ └─ Every action has an actor
77
+
78
+ THINGS (3)
79
+ ├─ 66+ entity types
80
+ ├─ Users, agents, content, products, courses, tokens, etc.
81
+ └─ Status: draft → active → published → archived
82
+
83
+ CONNECTIONS (4)
84
+ ├─ 25+ relationship types
85
+ ├─ Owns, follows, teaches, manages, etc.
86
+ └─ Bidirectional with metadata
87
+
88
+ EVENTS (5)
89
+ ├─ 67+ event types (audit trail)
90
+ ├─ Recorded: who did what, when
91
+ └─ Complete history for compliance
92
+
93
+ KNOWLEDGE (6)
94
+ ├─ Embeddings & vectors
95
+ ├─ Semantic search & RAG
96
+ └─ AI understanding of relationships
97
+ ```
98
+
99
+ ---
100
+
101
+ ## Query Organization by Dimension
102
+
103
+ ### Dimension 1: GROUPS (`convex/queries/groups.ts`)
104
+
105
+ **Purpose**: Multi-tenant isolation with hierarchical nesting
106
+
107
+ **Key Queries**:
108
+ - `getBySlug(slug)` - URL-based routing
109
+ - `getById(groupId)` - Direct lookup
110
+ - `getSubgroups(parentGroupId)` - Direct children
111
+ - `getHierarchy(rootGroupId)` - All descendants (recursive)
112
+ - `getGroupPath(groupId)` - Breadcrumb trail to root
113
+ - `isDescendantOf(groupId, ancestorGroupId)` - Permission checks
114
+ - `getEntitiesInHierarchy()` - All things in group tree
115
+ - `getConnectionsInHierarchy()` - All relationships in group tree
116
+ - `getEventsInHierarchy()` - All actions in group tree
117
+ - `getStats(groupId)` - Aggregate statistics
118
+ - `search(groupId, query)` - Group search
119
+ - `list(groupId)` - List all groups
120
+
121
+ **Cross-Dimension Integration**:
122
+ - Returns aggregate stats: entity count, connection count, event count, knowledge count
123
+ - Supports hierarchical queries across organization structure
124
+
125
+ ### Dimension 2: PEOPLE (`convex/queries/people.ts`)
126
+
127
+ **Purpose**: Authorization and governance
128
+
129
+ **Key Queries**:
130
+ - `list(groupId)` - List members
131
+ - `getById(personId)` - Get person details
132
+ - `getRole(personId)` - Get authorization level
133
+ - `listByRole(groupId, role)` - Filter by permission level
134
+
135
+ **Cross-Dimension Integration**:
136
+ - People are stored as entities with `type: "creator"`
137
+ - Roles determine what operations they can perform
138
+ - Referenced in events via `actorId` (who did what)
139
+
140
+ ### Dimension 3: THINGS (`convex/queries/entities.ts`)
141
+
142
+ **Purpose**: 66+ entity types (users, agents, content, tokens, courses, etc.)
143
+
144
+ **Key Queries**:
145
+ - `list(groupId, type?, status?, limit?)` - Flexible filtering
146
+ - `getById(entityId)` - Direct lookup
147
+ - `listByType(groupId, type)` - Filter by category
148
+ - `listByStatus(groupId, status)` - Filter by workflow state
149
+ - `search(groupId, query)` - Full-text search
150
+ - `listRecent(groupId, limit)` - Timeline view
151
+ - `getRelated(entityId)` - Connected entities
152
+ - `getStats(groupId)` - Count statistics
153
+ - `getProperties(entityId)` - Get entity properties
154
+
155
+ **Cross-Dimension Integration**:
156
+ - Things are the core nouns: every action affects a thing
157
+ - Connected to people via relationships (owns, member_of, etc.)
158
+ - Referenced in events via `targetId`
159
+ - Linked to knowledge via `sourceThingId`
160
+
161
+ ### Dimension 4: CONNECTIONS (`convex/queries/connections.ts`)
162
+
163
+ **Purpose**: 25+ relationship types between entities
164
+
165
+ **Key Queries**:
166
+ - `listFrom(groupId, fromEntityId)` - Outgoing edges
167
+ - `listTo(groupId, toEntityId)` - Incoming edges
168
+ - `listBetween(groupId, fromEntityId, toEntityId)` - Bidirectional
169
+ - `listByType(groupId, relationshipType)` - Filter by relationship
170
+
171
+ **Supported Relationship Types**:
172
+ - Ownership: `owns`, `member_of`, `part_of`
173
+ - Authorship: `created_by`, `authored`, `generated_by`, `published_to`
174
+ - Derivation: `clone_of`, `trained_on`, `references`
175
+ - Social: `following`, `collaborates_with`
176
+ - Financial: `holds_tokens`, `staked_in`, `earned_from`, `purchased`, `transacted`
177
+ - Educational: `enrolled_in`, `teaching`, `completed`
178
+ - Organizational: `manages`, `reports_to`, `moderates`
179
+ - Communication: `communicated`, `notified`, `referred`
180
+ - Governance: `delegated`, `approved`, `fulfilled`
181
+
182
+ **Cross-Dimension Integration**:
183
+ - Connect entities (things) to each other
184
+ - Include metadata: timestamp, actor (person), strength, validity window
185
+ - Used to compute: followers, collaborators, resource ownership, permissions
186
+
187
+ ### Dimension 5: EVENTS (`convex/queries/events.ts`)
188
+
189
+ **Purpose**: Complete audit trail (67+ event types)
190
+
191
+ **Key Queries**:
192
+ - `list(groupId, limit?)` - All events in group
193
+ - `byActor(groupId, actorId)` - Events by person
194
+ - `byTarget(groupId, targetId)` - Events affecting thing
195
+ - `byTimeRange(groupId, startTime, endTime)` - Temporal filtering
196
+ - `recent(groupId, limit)` - Most recent first
197
+ - `stats(groupId)` - Count by event type
198
+ - `getById(eventId)` - Get single event
199
+
200
+ **Event Structure**:
201
+ - `type`: Event category (entity_created, connection_established, purchase_completed, etc.)
202
+ - `actorId`: Person who caused the event
203
+ - `targetId`: Entity affected by the event
204
+ - `timestamp`: When it happened
205
+ - `metadata`: Event-specific data (amount, status transition, etc.)
206
+
207
+ **Cross-Dimension Integration**:
208
+ - Records when things change
209
+ - Links people (who) to things (what) to time (when)
210
+ - Powers activity feeds, notifications, analytics, compliance
211
+
212
+ ### Dimension 6: KNOWLEDGE (`convex/queries/knowledge.ts`)
213
+
214
+ **Purpose**: Vectors, embeddings, RAG, and semantic search
215
+
216
+ **Key Queries**:
217
+ - `list(groupId, limit?)` - All knowledge in group
218
+ - `search(groupId, query, limit?)` - Semantic search by embedding
219
+ - `bySourceThing(groupId, sourceThingId)` - Knowledge extracted from entity
220
+ - `byThing(groupId, thingId)` - Knowledge linked to entity
221
+ - `byLabel(groupId, label)` - Filter by tag/category
222
+ - `listLabels(groupId)` - Available tags
223
+ - `stats(groupId)` - Knowledge counts
224
+ - `getById(knowledgeId)` - Get single knowledge item
225
+
226
+ **Knowledge Structure**:
227
+ - `content`: Text that's been vectorized
228
+ - `embedding`: Numeric vector for similarity search
229
+ - `labels`: Tags for categorization
230
+ - `sourceThingId`: Where the knowledge came from
231
+ - `metadata`: Custom fields (confidence score, model used, etc.)
232
+
233
+ **Cross-Dimension Integration**:
234
+ - Created from entities (content extraction)
235
+ - Enables AI understanding of what exists and how it relates
236
+ - Powers semantic search, recommendations, and RAG
237
+
238
+ ---
239
+
240
+ ## Complete Query Reference
241
+
242
+ ### Summary Table: All 44 Queries
243
+
244
+ | Dimension | Name | File | Count |
245
+ |-----------|------|------|-------|
246
+ | 1 | GROUPS | groups.ts | 12 |
247
+ | 2 | PEOPLE | people.ts | 4 |
248
+ | 3 | THINGS | entities.ts | 9 |
249
+ | 4 | CONNECTIONS | connections.ts | 4 |
250
+ | 5 | EVENTS | events.ts | 7 |
251
+ | 6 | KNOWLEDGE | knowledge.ts | 8 |
252
+ | - | ONTOLOGY | ontology.ts | - |
253
+
254
+ ### DIMENSION 1: GROUPS (12)
255
+
256
+ `getBySlug` | `getById` | `list` | `getSubgroups` | `getHierarchy` | `getGroupPath` | `isDescendantOf` | `getEntitiesInHierarchy` | `getConnectionsInHierarchy` | `getEventsInHierarchy` | `getStats` | `search`
257
+
258
+ ### DIMENSION 2: PEOPLE (4)
259
+
260
+ `list` | `getById` | `getRole` | `listByRole`
261
+
262
+ ### DIMENSION 3: ENTITIES/THINGS (9)
263
+
264
+ `list` | `getById` | `listByType` | `listByStatus` | `search` | `listRecent` | `getStats` | `getRelated` | `getProperties`
265
+
266
+ ### DIMENSION 4: CONNECTIONS (4)
267
+
268
+ `listFrom` | `listTo` | `listBetween` | `listByType`
269
+
270
+ ### DIMENSION 5: EVENTS (7)
271
+
272
+ `list` | `byActor` | `byTarget` | `byTimeRange` | `stats` | `recent` | `getById`
273
+
274
+ ### DIMENSION 6: KNOWLEDGE (8)
275
+
276
+ `list` | `search` | `bySourceThing` | `byThing` | `byLabel` | `listLabels` | `stats` | `getById`
277
+
278
+ ---
279
+
280
+ ## Query Naming Conventions
281
+
282
+ All queries follow this consistent pattern:
283
+
284
+ ```
285
+ get<Singular> - Single entity by ID
286
+ getBy<Field> - Single entity by specific field
287
+ list - Multiple entities with filters
288
+ list<Plural> - Multiple entities of specific type
289
+ by<Dimension> - Filter by dimension (byActor, byTarget, byType)
290
+ <Verb> - Action queries (search, stats, isDescendantOf)
291
+ ```
292
+
293
+ ### Examples
294
+
295
+ - `getById()` - Get one entity by ID
296
+ - `getBySlug()` - Get one entity by slug field
297
+ - `list()` - Get multiple entities with optional filters
298
+ - `listByType()` - Get entities filtered by type
299
+ - `byActor()` - Get events filtered by actor
300
+ - `search()` - Full-text or semantic search
301
+ - `stats()` - Count aggregations
302
+
303
+ ---
304
+
305
+ ## Multi-Tenancy Pattern
306
+
307
+ **CRITICAL**: Every query filters by `groupId` for data isolation.
308
+
309
+ ### Standard Query Pattern
310
+
311
+ ```typescript
312
+ // All queries follow this pattern:
313
+ export const list = query({
314
+ args: {
315
+ groupId: v.id("groups"), // ← REQUIRED for isolation
316
+ type: v.optional(v.string()),
317
+ limit: v.optional(v.number()),
318
+ },
319
+ handler: async (ctx, args) => {
320
+ const results = await ctx.db
321
+ .query("entities")
322
+ .withIndex("group_type", (q) =>
323
+ q.eq("groupId", args.groupId) // ← Filter first
324
+ )
325
+ .collect();
326
+ return results;
327
+ }
328
+ });
329
+ ```
330
+
331
+ ### Why This Matters
332
+
333
+ - **Data Isolation**: Perfect separation between groups (organizations)
334
+ - **Security**: No data leaks if pattern is followed
335
+ - **Performance**: Indexes make queries fast even with millions of records
336
+ - **Multi-Tenancy**: Same schema, different data per group
337
+
338
+ ---
339
+
340
+ ## Performance Optimization
341
+
342
+ ### Indexes Used
343
+
344
+ 1. **group_type**: Filter by group + type (entities, connections, events, knowledge)
345
+ 2. **group_status**: Filter by group + status (entities, connections)
346
+ 3. **from_entity**: Outgoing relationships (connections)
347
+ 4. **to_entity**: Incoming relationships (connections)
348
+ 5. **by_created**: Activity timelines (entities, events)
349
+ 6. **by_updated**: Recent changes (entities, connections)
350
+ 7. **by_actor**: Activity by person (events)
351
+ 8. **by_target**: Activity affecting entity (events)
352
+
353
+ ### Query Tips
354
+
355
+ 1. **Always filter by groupId first** - Massive performance improvement
356
+ 2. **Use indexes** - See `withIndex()` in queries for available indexes
357
+ 3. **Limit large result sets** - Use `limit` parameter for pagination
358
+ 4. **Recurse carefully** - Use `maxDepth`/`maxIterations` to prevent infinite loops
359
+ 5. **Denormalize stats** - Pre-compute counts in mutations if possible
360
+
361
+ ### Performance Checklist
362
+
363
+ Before shipping a query:
364
+
365
+ - [ ] Filters by `groupId` first
366
+ - [ ] Uses an index (documented in comments)
367
+ - [ ] Has reasonable result limits
368
+ - [ ] Has JSDoc documentation
369
+ - [ ] Tested with different group IDs
370
+ - [ ] Performance acceptable (< 1s for most queries)
371
+
372
+ ---
373
+
374
+ ## Practical Examples
375
+
376
+ ### Example 1: Show All Followers
377
+
378
+ ```typescript
379
+ // Query DIMENSION 4 (CONNECTIONS)
380
+ const followers = await ctx.runQuery(api.queries.connections.listTo, {
381
+ groupId: groupId, // ← CRITICAL: Filter by group
382
+ toEntityId: creatorId, // Who we're finding followers of
383
+ relationshipType: "following"
384
+ });
385
+
386
+ // Returns: All entities that have "following" relationship TO this creator
387
+ ```
388
+
389
+ ### Example 2: Get Recent Activity in a Group
390
+
391
+ ```typescript
392
+ // Query DIMENSION 5 (EVENTS)
393
+ const recent = await ctx.runQuery(api.queries.events.recent, {
394
+ groupId: groupId, // ← CRITICAL: Filter by group
395
+ limit: 20
396
+ });
397
+
398
+ // Returns: Last 20 events ordered by timestamp DESC
399
+ ```
400
+
401
+ ### Example 3: Find Similar Articles
402
+
403
+ ```typescript
404
+ // Query DIMENSION 6 (KNOWLEDGE)
405
+ const similar = await ctx.runQuery(api.queries.knowledge.search, {
406
+ groupId: groupId, // ← CRITICAL: Filter by group
407
+ query: articleEmbedding,
408
+ limit: 10
409
+ });
410
+
411
+ // Returns: 10 most similar articles by semantic similarity
412
+ ```
413
+
414
+ ### Example 4: Show All Collaborators of a Creator
415
+
416
+ ```
417
+ 1. Get creator (THINGS) → entities query
418
+ 2. Find all CONNECTIONS where relationshipType = "collaborates_with"
419
+ 3. For each connection, get the other person (PEOPLE)
420
+ 4. Return list of people
421
+ ```
422
+
423
+ ### Example 5: Show Activity Feed for This User
424
+
425
+ ```
426
+ 1. Get user (PEOPLE)
427
+ 2. Query EVENTS where actorId = user._id
428
+ 3. For each event, join THINGS (targetId) for context
429
+ 4. Return timeline of what this user did
430
+ ```
431
+
432
+ ### Example 6: Find Similar Articles via Knowledge
433
+
434
+ ```
435
+ 1. Get article (THINGS)
436
+ 2. Get article's knowledge/embeddings (KNOWLEDGE)
437
+ 3. Search for similar embeddings (semantic search)
438
+ 4. Return THINGS that match similar knowledge
439
+ ```
440
+
441
+ ### React Component with Convex Hooks
442
+
443
+ ```typescript
444
+ // frontend/src/components/features/EntityList.tsx
445
+ import { useQuery } from "convex/react";
446
+ import { api } from "@/convex/_generated/api";
447
+
448
+ export function EntityList({ groupId, type }: { groupId: string; type: string }) {
449
+ const entities = useQuery(api.queries.entities.list, { groupId, type });
450
+
451
+ if (entities === undefined) return <div>Loading...</div>;
452
+
453
+ return (
454
+ <div>
455
+ {entities.map((entity) => (
456
+ <div key={entity._id}>{entity.name}</div>
457
+ ))}
458
+ </div>
459
+ );
460
+ }
461
+ ```
462
+
463
+ ### Astro Page with SSR
464
+
465
+ ```astro
466
+ ---
467
+ // frontend/src/pages/groups/[groupId]/entities/[type].astro
468
+ import { ConvexHttpClient } from "convex/browser";
469
+ import { api } from "@/convex/_generated/api";
470
+ import EntityList from "@/components/features/EntityList";
471
+
472
+ const convex = new ConvexHttpClient(import.meta.env.PUBLIC_CONVEX_URL);
473
+ const entities = await convex.query(api.queries.entities.list, {
474
+ groupId: Astro.params.groupId,
475
+ type: Astro.params.type
476
+ });
477
+ ---
478
+
479
+ <Layout>
480
+ <h1>{Astro.params.type} Entities</h1>
481
+ <EntityList
482
+ client:load
483
+ groupId={Astro.params.groupId}
484
+ type={Astro.params.type}
485
+ />
486
+ </Layout>
487
+ ```
488
+
489
+ ---
490
+
491
+ ## Ontology Runtime Discovery
492
+
493
+ ### Available Queries
494
+
495
+ The `ontology.ts` file provides runtime feature discovery for dynamic UI composition:
496
+
497
+ ```typescript
498
+ // Get complete ontology information
499
+ api.queries.ontology.getOntology()
500
+
501
+ // Get ontology metadata (counts, generation time)
502
+ api.queries.ontology.getMetadata()
503
+
504
+ // Get specific dimension types
505
+ api.queries.ontology.getThingTypes()
506
+ api.queries.ontology.getConnectionTypes()
507
+ api.queries.ontology.getEventTypes()
508
+
509
+ // Get enabled features
510
+ api.queries.ontology.getEnabledFeatures()
511
+
512
+ // Check if specific feature is enabled
513
+ api.queries.ontology.hasFeature({ feature: "blog" })
514
+
515
+ // Get detailed feature breakdown
516
+ api.queries.ontology.getFeatureBreakdown()
517
+ ```
518
+
519
+ ### Example Backend Usage
520
+
521
+ ```typescript
522
+ // In a Convex function
523
+ import { query } from "./_generated/server";
524
+ import { api } from "./_generated/api";
525
+
526
+ export const listAvailableContent = query({
527
+ args: {},
528
+ handler: async (ctx) => {
529
+ // Check if blog feature is enabled
530
+ const hasBlog = await ctx.runQuery(api.queries.ontology.hasFeature, {
531
+ feature: "blog"
532
+ });
533
+
534
+ // Get all thing types
535
+ const thingTypes = await ctx.runQuery(api.queries.ontology.getThingTypes);
536
+
537
+ return {
538
+ hasBlog,
539
+ availableContentTypes: thingTypes.filter(type =>
540
+ ["blog_post", "page", "project", "product"].includes(type)
541
+ )
542
+ };
543
+ }
544
+ });
545
+ ```
546
+
547
+ ### Frontend Feature Detection
548
+
549
+ ```tsx
550
+ import { useOntology, useHasFeature } from "@/hooks/useOntology";
551
+
552
+ function NavigationMenu() {
553
+ const { hasFeature, isLoading } = useOntology();
554
+
555
+ if (isLoading) return <div>Loading...</div>;
556
+
557
+ return (
558
+ <nav>
559
+ <a href="/">Home</a>
560
+ {hasFeature('blog') && <a href="/blog">Blog</a>}
561
+ {hasFeature('portfolio') && <a href="/portfolio">Portfolio</a>}
562
+ {hasFeature('shop') && <a href="/shop">Shop</a>}
563
+ </nav>
564
+ );
565
+ }
566
+ ```
567
+
568
+ ### Dynamic Type Selectors
569
+
570
+ ```tsx
571
+ import { useThingTypes } from "@/hooks/useOntology";
572
+
573
+ function CreateThingForm() {
574
+ const thingTypes = useThingTypes();
575
+ const [selectedType, setSelectedType] = useState("");
576
+
577
+ return (
578
+ <form>
579
+ <label>Thing Type</label>
580
+ <select value={selectedType} onChange={(e) => setSelectedType(e.target.value)}>
581
+ <option value="">Select type...</option>
582
+ {thingTypes.map(type => (
583
+ <option key={type} value={type}>
584
+ {type.replace('_', ' ').toUpperCase()}
585
+ </option>
586
+ ))}
587
+ </select>
588
+ </form>
589
+ );
590
+ }
591
+ ```
592
+
593
+ ### Astro Server-Side Usage
594
+
595
+ ```astro
596
+ ---
597
+ // src/pages/admin/ontology.astro
598
+ import { ConvexHttpClient } from "convex/browser";
599
+ import { api } from "@/convex/_generated/api";
600
+
601
+ const convex = new ConvexHttpClient(import.meta.env.PUBLIC_CONVEX_URL);
602
+ const ontology = await convex.query(api.queries.ontology.getOntology);
603
+ const breakdown = await convex.query(api.queries.ontology.getFeatureBreakdown);
604
+ ---
605
+
606
+ <Layout title="Ontology Configuration">
607
+ <h1>Ontology Composition</h1>
608
+
609
+ <section>
610
+ <h2>Enabled Features</h2>
611
+ <ul>
612
+ {ontology.features.map(feature => (
613
+ <li>{feature}</li>
614
+ ))}
615
+ </ul>
616
+ </section>
617
+
618
+ <section>
619
+ <h2>Available Types</h2>
620
+ <div>
621
+ <h3>Things ({ontology.thingTypes.length})</h3>
622
+ <p>{ontology.thingTypes.join(', ')}</p>
623
+ </div>
624
+ <div>
625
+ <h3>Connections ({ontology.connectionTypes.length})</h3>
626
+ <p>{ontology.connectionTypes.join(', ')}</p>
627
+ </div>
628
+ <div>
629
+ <h3>Events ({ontology.eventTypes.length})</h3>
630
+ <p>{ontology.eventTypes.join(', ')}</p>
631
+ </div>
632
+ </section>
633
+ </Layout>
634
+ ```
635
+
636
+ ### Advanced: Feature Breakdown
637
+
638
+ ```tsx
639
+ import { useFeatureBreakdown } from "@/hooks/useOntology";
640
+
641
+ function FeatureExplorer() {
642
+ const breakdown = useFeatureBreakdown();
643
+
644
+ if (!breakdown) return <div>Loading...</div>;
645
+
646
+ return (
647
+ <div className="feature-explorer">
648
+ {Object.entries(breakdown).map(([featureName, feature]) => {
649
+ if (!feature) return null;
650
+
651
+ return (
652
+ <div key={featureName} className="feature-card">
653
+ <h3>{featureName}</h3>
654
+ <p>{feature.description}</p>
655
+
656
+ <div className="feature-details">
657
+ <div>
658
+ <h4>Thing Types ({feature.thingTypes.length})</h4>
659
+ <ul>
660
+ {feature.thingTypes.map(type => (
661
+ <li key={type}>{type}</li>
662
+ ))}
663
+ </ul>
664
+ </div>
665
+
666
+ <div>
667
+ <h4>Connection Types ({feature.connectionTypes.length})</h4>
668
+ <ul>
669
+ {feature.connectionTypes.map(type => (
670
+ <li key={type}>{type}</li>
671
+ ))}
672
+ </ul>
673
+ </div>
674
+
675
+ <div>
676
+ <h4>Event Types ({feature.eventTypes.length})</h4>
677
+ <ul>
678
+ {feature.eventTypes.map(type => (
679
+ <li key={type}>{type}</li>
680
+ ))}
681
+ </ul>
682
+ </div>
683
+ </div>
684
+ </div>
685
+ );
686
+ })}
687
+ </div>
688
+ );
689
+ }
690
+ ```
691
+
692
+ ---
693
+
694
+ ## Adding New Queries
695
+
696
+ ### Step 1: Identify the Dimension
697
+
698
+ Which of the 6 dimensions does this query serve?
699
+
700
+ - Groups → `queries/groups.ts`
701
+ - People → `queries/people.ts`
702
+ - Things → `queries/entities.ts`
703
+ - Relationships → `queries/connections.ts`
704
+ - Audit/Timeline → `queries/events.ts`
705
+ - AI/Search → `queries/knowledge.ts`
706
+
707
+ ### Step 2: Follow the Pattern
708
+
709
+ ```typescript
710
+ /**
711
+ * Description of what this query does
712
+ *
713
+ * Use case: when/why you'd use this
714
+ * Performance: which index is used
715
+ */
716
+ export const myQuery = query({
717
+ args: {
718
+ groupId: v.id("groups"), // ← ALWAYS include
719
+ myParam: v.string(),
720
+ },
721
+ handler: async (ctx, args) => {
722
+ // Filter by groupId first (performance + security)
723
+ const results = await ctx.db
724
+ .query("myTable")
725
+ .withIndex("by_group", q => q.eq("groupId", args.groupId))
726
+ .collect();
727
+
728
+ return results;
729
+ }
730
+ });
731
+ ```
732
+
733
+ ### Step 3: Document It
734
+
735
+ 1. Add JSDoc comment (see step 2 above)
736
+ 2. Add to `queries/README.md`
737
+ 3. Add to `convex/INDEX.md`
738
+
739
+ ### Step 4: Test It
740
+
741
+ 1. Verify groupId filtering works
742
+ 2. Test index performance
743
+ 3. Ensure isolation
744
+
745
+ ### Step 5: Update This Reference
746
+
747
+ Add your query to the appropriate dimension section in this document.
748
+
749
+ ---
750
+
751
+ ## Key Principles
752
+
753
+ ### 🔒 Multi-Tenancy (CRITICAL)
754
+ - Every query filters by `groupId` first
755
+ - Perfect data isolation between groups
756
+ - No data leaks possible if pattern is followed
757
+
758
+ ### 🎯 Consistency
759
+ - All queries follow same naming convention
760
+ - All use same multi-tenancy pattern
761
+ - All have JSDoc documentation
762
+
763
+ ### 📊 Completeness
764
+ - All 6 dimensions have full query coverage
765
+ - Cross-dimension queries available
766
+ - Aggregate queries for stats and search
767
+
768
+ ### 🚀 Performance
769
+ - Indexes documented in each query
770
+ - Fast path identified for common queries
771
+ - Tips for optimizing recursive queries
772
+
773
+ ### 📚 Discoverability
774
+ - Comprehensive documentation at multiple levels
775
+ - Code examples for each pattern
776
+ - Clear naming conventions
777
+
778
+ ---
779
+
780
+ ## File Locations
781
+
782
+ - **Backend Queries**: `/Users/toc/Server/ONE/backend/convex/queries/`
783
+ - **Groups**: `/Users/toc/Server/ONE/backend/convex/queries/groups.ts`
784
+ - **People**: `/Users/toc/Server/ONE/backend/convex/queries/people.ts`
785
+ - **Entities**: `/Users/toc/Server/ONE/backend/convex/queries/entities.ts`
786
+ - **Connections**: `/Users/toc/Server/ONE/backend/convex/queries/connections.ts`
787
+ - **Events**: `/Users/toc/Server/ONE/backend/convex/queries/events.ts`
788
+ - **Knowledge**: `/Users/toc/Server/ONE/backend/convex/queries/knowledge.ts`
789
+ - **Ontology Discovery**: `/Users/toc/Server/ONE/backend/convex/queries/ontology.ts`
790
+ - **Frontend Hook**: `/Users/toc/Server/ONE/web/src/hooks/useOntology.ts`
791
+ - **Ontology Types**: `/Users/toc/Server/ONE/backend/convex/types/ontology.ts`
792
+ - **Schema**: `/Users/toc/Server/ONE/backend/convex/schema.ts`
793
+
794
+ ---
795
+
796
+ ## Quick Reference: Documentation Structure
797
+
798
+ ### For New Developers
799
+
800
+ **"I want to understand the system"**
801
+ → Start with: `convex/INDEX.md` (master reference)
802
+ → Then read: `ONTOLOGY_VISUAL_GUIDE.md` (visual flow)
803
+
804
+ **"I want to add a new query"**
805
+ → Read: This document → "Adding New Queries" section
806
+ → Copy pattern from existing query in the same dimension
807
+ → Update `queries/README.md` with new query
808
+
809
+ **"I want to understand one dimension"**
810
+ → Open the dimension file: `queries/groups.ts` (etc.)
811
+ → Read the header documentation
812
+ → Check `convex/INDEX.md` for the complete reference table
813
+
814
+ ### For Code Review
815
+
816
+ **"Is this query following the pattern?"**
817
+ - ✅ Does it filter by `groupId`?
818
+ - ✅ Does it use an index?
819
+ - ✅ Is the name following conventions?
820
+ - ✅ Does it have JSDoc?
821
+ - ✅ Is it in the right dimension file?
822
+
823
+ ---
824
+
825
+ ## Remember
826
+
827
+ **Groups partition → People authorize → Things exist → Connections relate → Events record → Knowledge understands.**
828
+
829
+ Every query should cleanly fit into one of these 6 dimensions. If it doesn't, reconsider the approach.
830
+
831
+ ---
832
+
833
+ **See Also**:
834
+ - `/one/knowledge/ontology.md` - Complete 6-dimension specification
835
+ - `convex/mutations/` - Write operations following same structure
836
+ - `convex/schema.ts` - Database schema matching this ontology
837
+ - `convex/queries/README.md` - Quick reference lookup table
838
+ - `convex/INDEX.md` - Master backend reference
839
+
840
+ ---
841
+
842
+ **Built with the 6-dimension ontology. Runtime feature discovery enables dynamic, composition-aware UIs.**