oneie 3.5.0 → 3.6.0

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 (132) hide show
  1. package/.claude/agents/agent-director.md +902 -22
  2. package/.claude/agents/agent-onboard-example-output.md +600 -0
  3. package/.claude/agents/agent-onboard.md +576 -0
  4. package/.claude/commands/ONBOARDING_ENHANCEMENT_SUMMARY.md +266 -0
  5. package/.claude/commands/one.md +375 -5
  6. package/.claude/commands/release.md +64 -3
  7. package/CLAUDE.md +55 -69
  8. package/dist/commands/init.d.ts +5 -6
  9. package/dist/commands/init.d.ts.map +1 -1
  10. package/dist/commands/init.js +101 -101
  11. package/dist/commands/init.js.map +1 -1
  12. package/dist/index.js +6 -5
  13. package/dist/index.js.map +1 -1
  14. package/dist/utils/installation-setup.d.ts +24 -1
  15. package/dist/utils/installation-setup.d.ts.map +1 -1
  16. package/dist/utils/installation-setup.js +85 -1
  17. package/dist/utils/installation-setup.js.map +1 -1
  18. package/dist/utils/launch-claude.d.ts +6 -0
  19. package/dist/utils/launch-claude.d.ts.map +1 -0
  20. package/dist/utils/launch-claude.js +51 -0
  21. package/dist/utils/launch-claude.js.map +1 -0
  22. package/dist/utils/validation.d.ts +48 -0
  23. package/dist/utils/validation.d.ts.map +1 -0
  24. package/dist/utils/validation.js +73 -0
  25. package/dist/utils/validation.js.map +1 -0
  26. package/folders.yaml +1 -1
  27. package/one/.obsidian/core-plugins.json +33 -0
  28. package/one/.obsidian/workspace.json +20 -20
  29. package/one/connections/workflow-onboarding.md +683 -0
  30. package/one/events/CART-DRAWER-INTEGRATION-GUIDE.md +354 -0
  31. package/one/events/CRITICAL-FIXES-COMPLETE.md +504 -0
  32. package/one/events/DEPLOYMENT.md +178 -0
  33. package/one/events/ECOMMERCE-DEMO-PLAN.md +225 -0
  34. package/one/events/ECOMMERCE-LIVE-DEMO.md +363 -0
  35. package/one/events/ECOMMERCE-TEMPLATE-COMPLETE.md +735 -0
  36. package/one/events/ECOMMERCE-TEMPLATES-SUMMARY.md +923 -0
  37. package/one/events/GRADIENT-TEXT-PERMANENT-FIX.md +223 -0
  38. package/one/events/HANDOFF.md +313 -0
  39. package/one/events/IMPLEMENTATION-SUMMARY-FINAL.md +503 -0
  40. package/one/events/IMPLEMENTATION_SUMMARY.md +529 -0
  41. package/one/events/LANDING-PAGE-EXAMPLE-OUTPUT.md +666 -0
  42. package/one/events/LANDING-PAGE-IMPLEMENTATION.md +642 -0
  43. package/one/events/LANDING-PAGE-QUICKSTART.md +407 -0
  44. package/one/events/MULTI-ONTOLOGY-COMPLETE-GUIDE.md +1627 -0
  45. package/one/events/MULTI-ONTOLOGY-IMPLEMENTATION-COMPLETE.md +573 -0
  46. package/one/events/ONBOARDING-IMPLEMENTATION-COMPLETE copy.md +398 -0
  47. package/one/events/ONTOLOGY-TUTORIALS-SUMMARY.md +525 -0
  48. package/one/events/ONTOLOGY-TYPE-GENERATOR-SUMMARY.md +455 -0
  49. package/one/events/ONTOLOGY_DISCOVERY_IMPLEMENTATION.md +486 -0
  50. package/one/events/ONTOLOGY_DISCOVERY_QUICKSTART.md +203 -0
  51. package/one/events/SECURITY-AUDIT-FIXES.md +376 -0
  52. package/one/events/SECURITY-SCAN-COMPLETE.md +281 -0
  53. package/one/events/SHOP-BUILD-STATUS.md +114 -0
  54. package/one/events/SHOP-PREMIUM-UPDATE.md +149 -0
  55. package/one/events/SITE-WIDE-GRADIENT-FIX.md +299 -0
  56. package/one/events/STORE-PRODUCTION-READY-STATUS.md +359 -0
  57. package/one/events/STRIPE-PAYMENT-METHODS-GUIDE.md +429 -0
  58. package/one/events/agent-director-enhancement-summary.md +386 -0
  59. package/one/events/agent-onboard-implementation-summary.md +457 -0
  60. package/one/events/clean-agent-ontology-cleanup-report.md +353 -0
  61. package/one/events/landing-page-generator.md +458 -0
  62. package/one/events/onboarding-implementation-complete.md +505 -0
  63. package/one/events/release.md +254 -0
  64. package/one/events/separate-implementation-status.md +537 -0
  65. package/one/knowledge/100-inference-quick-reference.md +431 -0
  66. package/one/knowledge/agent-onboard-usage.md +612 -0
  67. package/one/knowledge/cli-claude-handoff.md +718 -0
  68. package/one/knowledge/ontology-blog.yaml +31 -0
  69. package/one/knowledge/ontology-cheatsheet.md +591 -0
  70. package/one/knowledge/ontology-community.yaml +42 -0
  71. package/one/knowledge/ontology-core-universal.md +722 -0
  72. package/one/knowledge/ontology-core.yaml +50 -0
  73. package/one/knowledge/ontology-courses.yaml +53 -0
  74. package/one/knowledge/ontology-creator.md +376 -0
  75. package/one/knowledge/ontology-developer-guide.md +789 -0
  76. package/one/knowledge/ontology-education.md +920 -0
  77. package/one/knowledge/ontology-index.md +354 -0
  78. package/one/knowledge/ontology-migration-guide.md +811 -0
  79. package/one/knowledge/ontology-minimal.yaml +1 -1
  80. package/one/knowledge/ontology-portfolio.yaml +31 -0
  81. package/one/knowledge/ontology-quickstart.md +576 -0
  82. package/one/knowledge/ontology-shop.yaml +121 -0
  83. package/one/knowledge/ontology-tokens.yaml +32 -0
  84. package/one/knowledge/ontology-tutorial.md +434 -0
  85. package/one/knowledge/ontology-video-script.md +890 -0
  86. package/one/things/docs/ecommerce/ARCHITECTURE-DIAGRAM.md +467 -0
  87. package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-IMPLEMENTATION.md +408 -0
  88. package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-SUMMARY.md +369 -0
  89. package/one/things/docs/ecommerce/CONVERSION-UX-IMPLEMENTATION-SUMMARY.md +396 -0
  90. package/one/things/docs/ecommerce/FEATURE-SUMMARY.md +468 -0
  91. package/one/things/docs/ecommerce/IMPLEMENTATION-NOTES.md +582 -0
  92. package/one/things/docs/ecommerce/INTEGRATION-EXAMPLE.md +449 -0
  93. package/one/things/docs/ecommerce/QUICK-START.md +368 -0
  94. package/one/things/docs/ecommerce/URGENCY-IMPLEMENTATION-SUMMARY.md +498 -0
  95. package/one/things/docs/ecommerce/URGENCY-QUICK-REFERENCE.md +237 -0
  96. package/one/things/docs/ecommerce/USAGE-EXAMPLE.astro +171 -0
  97. package/one/things/docs/ecommerce/demo.astro +309 -0
  98. package/one/things/plans/agent-director-100-inference-plans.md +410 -0
  99. package/one/things/plans/dual-website-strategy.md +612 -0
  100. package/one/things/plans/feature-based-sites.md +821 -0
  101. package/one/things/plans/multi-ontology-architecture.md +836 -0
  102. package/one/things/plans/onboarding.md +32 -0
  103. package/one/things/plans/separate.md +15 -17
  104. package/one/things/plans/start-new.md +738 -0
  105. package/package.json +2 -2
  106. package/one/things/claude/hooks/agent-hook-manager.js +0 -525
  107. package/one/things/claude/hooks/agent-load-balancer.js +0 -271
  108. package/one/things/claude/hooks/agent-request-interceptor.js +0 -70
  109. package/one/things/claude/hooks/cascade-feedback.js +0 -297
  110. package/one/things/claude/hooks/cascade-integration-hooks.js +0 -648
  111. package/one/things/claude/hooks/continuous-improvement-monitor.js +0 -510
  112. package/one/things/claude/hooks/file-organization-engine.js +0 -427
  113. package/one/things/claude/hooks/file-organization-monitor.js +0 -269
  114. package/one/things/claude/hooks/hook-config-manager.js +0 -202
  115. package/one/things/claude/hooks/hook-orchestrator.js +0 -662
  116. package/one/things/claude/hooks/hook-performance-report.js +0 -120
  117. package/one/things/claude/hooks/mcp-cascade-integration.js +0 -816
  118. package/one/things/claude/hooks/memory-optimizer.js +0 -510
  119. package/one/things/claude/hooks/ontology-compliance.js +0 -394
  120. package/one/things/claude/hooks/ontology-hook-manager.js +0 -316
  121. package/one/things/claude/hooks/ontology-validation-engine.js +0 -317
  122. package/one/things/claude/hooks/performance-monitoring-hook.js +0 -422
  123. package/one/things/claude/hooks/quality-scoring-engine.js +0 -834
  124. package/one/things/claude/hooks/simple-load-balancer.js +0 -238
  125. package/one/things/claude/hooks/startup-optimizer.js +0 -625
  126. package/one/things/claude/hooks/story-scoring-system.js +0 -445
  127. package/one/things/claude/hooks/story-validation-engine.js +0 -473
  128. package/one/things/claude/hooks/structure-synchronizer.js +0 -194
  129. package/one/things/claude/hooks/sub-agent-output-validator.js +0 -647
  130. package/one/things/claude/hooks/sub-agent-validation-hook.js +0 -343
  131. package/one/things/claude/hooks/trinity-validation-system.js +0 -392
  132. package/one/things/plans/organizations-to-groups.md +0 -705
@@ -0,0 +1,811 @@
1
+ # Multi-Ontology Architecture: Migration Guide
2
+
3
+ **Version:** 1.0.0
4
+ **Last Updated:** 2025-10-20
5
+ **Status:** Complete
6
+
7
+ ## Table of Contents
8
+
9
+ 1. [Overview](#overview)
10
+ 2. [Pre-Migration Checklist](#pre-migration-checklist)
11
+ 3. [Migration Strategy](#migration-strategy)
12
+ 4. [Step-by-Step Migration](#step-by-step-migration)
13
+ 5. [Data Migration](#data-migration)
14
+ 6. [Rollback Procedures](#rollback-procedures)
15
+ 7. [Common Pitfalls](#common-pitfalls)
16
+ 8. [Case Studies](#case-studies)
17
+
18
+ ---
19
+
20
+ ## Overview
21
+
22
+ ### What This Guide Covers
23
+
24
+ This guide helps you migrate from **hardcoded entity types** to the **multi-ontology architecture**.
25
+
26
+ **Before (Hardcoded):**
27
+
28
+ ```typescript
29
+ // backend/convex/schema.ts
30
+ export const schema = defineSchema({
31
+ entities: defineTable({
32
+ type: v.union(
33
+ v.literal('page'),
34
+ v.literal('user'),
35
+ v.literal('blog_post'),
36
+ v.literal('product'),
37
+ v.literal('course'),
38
+ // ... 50 more types hardcoded here
39
+ ),
40
+ // ...
41
+ }),
42
+ });
43
+ ```
44
+
45
+ **After (Multi-Ontology):**
46
+
47
+ ```yaml
48
+ # /one/knowledge/ontology-core.yaml
49
+ feature: core
50
+ thingTypes:
51
+ - name: page
52
+ - name: user
53
+
54
+ # /one/knowledge/ontology-blog.yaml
55
+ feature: blog
56
+ extends: core
57
+ thingTypes:
58
+ - name: blog_post
59
+
60
+ # /one/knowledge/ontology-shop.yaml
61
+ feature: shop
62
+ extends: core
63
+ thingTypes:
64
+ - name: product
65
+ ```
66
+
67
+ ```typescript
68
+ // backend/convex/schema.ts (generated)
69
+ import { THING_TYPES } from './types/ontology';
70
+
71
+ export const schema = defineSchema({
72
+ entities: defineTable({
73
+ type: v.union(...THING_TYPES.map(t => v.literal(t))),
74
+ // ...
75
+ }),
76
+ });
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Pre-Migration Checklist
82
+
83
+ Before starting migration, ensure you have:
84
+
85
+ - [ ] **Full database backup** (critical!)
86
+ - [ ] **List of all current entity types** in use
87
+ - [ ] **Feature grouping plan** (which types belong to which features)
88
+ - [ ] **Environment variables documented** (especially `PUBLIC_FEATURES`)
89
+ - [ ] **Testing environment ready** (staging/development database)
90
+ - [ ] **Rollback plan prepared** (see [Rollback Procedures](#rollback-procedures))
91
+ - [ ] **Team communication** (notify all developers of migration)
92
+
93
+ ---
94
+
95
+ ## Migration Strategy
96
+
97
+ ### Option 1: Big Bang Migration (Small Projects)
98
+
99
+ **Best for:**
100
+ - Small projects (< 10 entity types)
101
+ - Single developer
102
+ - Development/staging only (no production yet)
103
+
104
+ **Steps:**
105
+ 1. Create all ontology YAML files
106
+ 2. Generate types
107
+ 3. Update schema
108
+ 4. Deploy
109
+
110
+ **Downtime:** Yes (1-2 hours)
111
+
112
+ ---
113
+
114
+ ### Option 2: Gradual Migration (Recommended)
115
+
116
+ **Best for:**
117
+ - Medium/large projects (10+ entity types)
118
+ - Multiple developers
119
+ - Production systems
120
+
121
+ **Steps:**
122
+ 1. Create ontology YAMLs (no deployment yet)
123
+ 2. Run both systems in parallel
124
+ 3. Migrate features one by one
125
+ 4. Validate each migration
126
+ 5. Switch over when all features migrated
127
+
128
+ **Downtime:** No (zero-downtime migration)
129
+
130
+ ---
131
+
132
+ ### Option 3: Dual-Write Migration (Large Projects)
133
+
134
+ **Best for:**
135
+ - Large projects (50+ entity types)
136
+ - High-traffic production systems
137
+ - Risk-averse organizations
138
+
139
+ **Steps:**
140
+ 1. Add ontology system alongside hardcoded types
141
+ 2. Write to both systems simultaneously
142
+ 3. Validate data consistency
143
+ 4. Gradually shift reads to ontology system
144
+ 5. Remove hardcoded types when confident
145
+
146
+ **Downtime:** No (weeks of parallel operation)
147
+
148
+ ---
149
+
150
+ ## Step-by-Step Migration
151
+
152
+ ### Step 1: Inventory Your Entity Types
153
+
154
+ Create a spreadsheet of all entity types currently in use:
155
+
156
+ | Type | Feature | Usage Count | Dependencies |
157
+ |---------------|-------------|-------------|---------------------|
158
+ | page | core | 1,245 | None |
159
+ | user | core | 8,932 | None |
160
+ | blog_post | blog | 3,421 | user (author) |
161
+ | blog_category | blog | 42 | None |
162
+ | product | shop | 1,892 | user (seller) |
163
+ | order | shop | 5,234 | product, user |
164
+ | course | courses | 234 | user (instructor) |
165
+ | lesson | courses | 1,456 | course |
166
+
167
+ **Tools to help:**
168
+
169
+ ```typescript
170
+ // Count entity types in database
171
+ const typeCounts = await ctx.db
172
+ .query('entities')
173
+ .collect()
174
+ .then(entities => {
175
+ const counts = {};
176
+ entities.forEach(e => {
177
+ counts[e.type] = (counts[e.type] || 0) + 1;
178
+ });
179
+ return counts;
180
+ });
181
+
182
+ console.log(typeCounts);
183
+ // { page: 1245, user: 8932, blog_post: 3421, ... }
184
+ ```
185
+
186
+ ---
187
+
188
+ ### Step 2: Group Types into Features
189
+
190
+ Organize your types into logical features:
191
+
192
+ **Core (always enabled):**
193
+ - `page`, `user`, `file`, `link`, `note`
194
+
195
+ **Blog:**
196
+ - `blog_post`, `blog_category`, `blog_tag`
197
+
198
+ **Shop:**
199
+ - `product`, `product_variant`, `order`, `shopping_cart`, `payment`
200
+
201
+ **Courses:**
202
+ - `course`, `lesson`, `enrollment`, `certificate`
203
+
204
+ ---
205
+
206
+ ### Step 3: Create Ontology YAML Files
207
+
208
+ Create one YAML file per feature:
209
+
210
+ **`/one/knowledge/ontology-core.yaml`:**
211
+
212
+ ```yaml
213
+ feature: core
214
+ extends: null
215
+ description: Core entities always present
216
+
217
+ thingTypes:
218
+ - name: page
219
+ properties:
220
+ title: string
221
+ slug: string
222
+ content: string
223
+
224
+ - name: user
225
+ properties:
226
+ email: string
227
+ displayName: string
228
+ avatar: string
229
+
230
+ connectionTypes:
231
+ - name: created_by
232
+ fromType: '*'
233
+ toType: user
234
+
235
+ eventTypes:
236
+ - name: thing_created
237
+ thingType: '*'
238
+ ```
239
+
240
+ **`/one/knowledge/ontology-blog.yaml`:**
241
+
242
+ ```yaml
243
+ feature: blog
244
+ extends: core
245
+ description: Blog and content publishing
246
+
247
+ thingTypes:
248
+ - name: blog_post
249
+ properties:
250
+ title: string
251
+ slug: string
252
+ content: string
253
+ excerpt: string
254
+ publishedAt: number
255
+
256
+ - name: blog_category
257
+ properties:
258
+ name: string
259
+ slug: string
260
+
261
+ connectionTypes:
262
+ - name: posted_in
263
+ fromType: blog_post
264
+ toType: blog_category
265
+
266
+ - name: authored
267
+ fromType: blog_post
268
+ toType: user
269
+
270
+ eventTypes:
271
+ - name: blog_post_published
272
+ thingType: blog_post
273
+
274
+ - name: blog_post_viewed
275
+ thingType: blog_post
276
+ ```
277
+
278
+ Repeat for each feature (`shop`, `courses`, etc.).
279
+
280
+ ---
281
+
282
+ ### Step 4: Generate Types (Test First!)
283
+
284
+ Generate types in a **test environment first**:
285
+
286
+ ```bash
287
+ # Test environment
288
+ cd backend
289
+ PUBLIC_FEATURES="core,blog,shop,courses" bun run scripts/generate-ontology-types.ts
290
+ ```
291
+
292
+ **Verify output:**
293
+
294
+ ```
295
+ ✅ Loaded ontology: core (2 thing types, 1 connection type, 1 event type)
296
+ ✅ Loaded ontology: blog (2 thing types, 2 connection types, 2 event types)
297
+ ✅ Loaded ontology: shop (5 thing types, 3 connection types, 4 event types)
298
+ ✅ Loaded ontology: courses (4 thing types, 2 connection types, 3 event types)
299
+ 📦 Generated types: 13 thing types, 8 connection types, 10 event types
300
+ ```
301
+
302
+ ---
303
+
304
+ ### Step 5: Update Schema
305
+
306
+ **Before:**
307
+
308
+ ```typescript
309
+ // backend/convex/schema.ts
310
+ import { defineSchema, defineTable } from 'convex/server';
311
+ import { v } from 'convex/values';
312
+
313
+ export default defineSchema({
314
+ entities: defineTable({
315
+ type: v.union(
316
+ v.literal('page'),
317
+ v.literal('user'),
318
+ v.literal('blog_post'),
319
+ v.literal('product'),
320
+ // ... hardcoded types
321
+ ),
322
+ name: v.string(),
323
+ properties: v.any(),
324
+ status: v.string(),
325
+ createdAt: v.number(),
326
+ updatedAt: v.number(),
327
+ }),
328
+ });
329
+ ```
330
+
331
+ **After:**
332
+
333
+ ```typescript
334
+ // backend/convex/schema.ts
335
+ import { defineSchema, defineTable } from 'convex/server';
336
+ import { v } from 'convex/values';
337
+ import { THING_TYPES } from './types/ontology';
338
+
339
+ // Generate union from ontology types
340
+ const thingTypeUnion = v.union(
341
+ ...THING_TYPES.map(type => v.literal(type))
342
+ );
343
+
344
+ export default defineSchema({
345
+ entities: defineTable({
346
+ type: thingTypeUnion, // ✅ Generated from ontology
347
+ name: v.string(),
348
+ properties: v.any(),
349
+ status: v.string(),
350
+ createdAt: v.number(),
351
+ updatedAt: v.number(),
352
+ }),
353
+ });
354
+ ```
355
+
356
+ ---
357
+
358
+ ### Step 6: Update Mutations
359
+
360
+ **Before:**
361
+
362
+ ```typescript
363
+ export const createBlogPost = mutation({
364
+ handler: async (ctx, args) => {
365
+ await ctx.db.insert('entities', {
366
+ type: 'blog_post', // ❌ Hardcoded
367
+ // ...
368
+ });
369
+ },
370
+ });
371
+ ```
372
+
373
+ **After:**
374
+
375
+ ```typescript
376
+ import { isThingType } from './types/ontology';
377
+
378
+ export const createBlogPost = mutation({
379
+ handler: async (ctx, args) => {
380
+ const type = 'blog_post';
381
+
382
+ // ✅ Runtime validation
383
+ if (!isThingType(type)) {
384
+ throw new Error(`Invalid thing type: ${type}`);
385
+ }
386
+
387
+ await ctx.db.insert('entities', {
388
+ type, // ✅ Type-safe
389
+ // ...
390
+ });
391
+ },
392
+ });
393
+ ```
394
+
395
+ ---
396
+
397
+ ### Step 7: Deploy to Staging
398
+
399
+ Deploy to staging environment first:
400
+
401
+ ```bash
402
+ # Set features in staging .env.local
403
+ PUBLIC_FEATURES="core,blog,shop,courses"
404
+
405
+ # Deploy
406
+ cd backend
407
+ npx convex deploy --prod staging
408
+ ```
409
+
410
+ **Test thoroughly:**
411
+ - [ ] All existing features work
412
+ - [ ] Can create new entities
413
+ - [ ] Can query entities by type
414
+ - [ ] Events are logged correctly
415
+ - [ ] Connections work
416
+
417
+ ---
418
+
419
+ ### Step 8: Deploy to Production
420
+
421
+ Once staging tests pass:
422
+
423
+ ```bash
424
+ # Set features in production .env.local
425
+ PUBLIC_FEATURES="core,blog,shop,courses"
426
+
427
+ # Deploy
428
+ cd backend
429
+ npx convex deploy --prod production
430
+ ```
431
+
432
+ **Monitor:**
433
+ - Error rates
434
+ - Query performance
435
+ - Type validation errors
436
+
437
+ ---
438
+
439
+ ## Data Migration
440
+
441
+ ### No Data Changes Required!
442
+
443
+ **Good news:** The multi-ontology architecture doesn't change your **data structure**, only your **type definitions**.
444
+
445
+ Existing data remains valid:
446
+
447
+ ```typescript
448
+ // Before migration
449
+ {
450
+ _id: "abc123",
451
+ type: "blog_post", // ✅ Still valid
452
+ name: "My Post",
453
+ properties: { title: "Hello" },
454
+ // ...
455
+ }
456
+
457
+ // After migration
458
+ {
459
+ _id: "abc123",
460
+ type: "blog_post", // ✅ Still valid (now ontology-validated)
461
+ name: "My Post",
462
+ properties: { title: "Hello" },
463
+ // ...
464
+ }
465
+ ```
466
+
467
+ ### If You Need to Rename Types
468
+
469
+ If you want to rename a type during migration:
470
+
471
+ **Option 1: Database Update Script**
472
+
473
+ ```typescript
474
+ // scripts/migrate-types.ts
475
+ import { ConvexClient } from 'convex/browser';
476
+
477
+ const client = new ConvexClient(process.env.CONVEX_URL);
478
+
479
+ // Rename 'post' → 'blog_post'
480
+ const posts = await client.query('entities:list', { type: 'post' });
481
+
482
+ for (const post of posts) {
483
+ await client.mutation('entities:update', {
484
+ id: post._id,
485
+ type: 'blog_post', // ✅ New type name
486
+ });
487
+ }
488
+ ```
489
+
490
+ **Option 2: Type Alias**
491
+
492
+ Keep old type as alias:
493
+
494
+ ```yaml
495
+ # ontology-blog.yaml
496
+ thingTypes:
497
+ - name: blog_post
498
+ aliases: ['post'] # Support old name temporarily
499
+ ```
500
+
501
+ ---
502
+
503
+ ## Rollback Procedures
504
+
505
+ ### Emergency Rollback (Production Issues)
506
+
507
+ If you encounter critical issues after deployment:
508
+
509
+ **Step 1: Revert Code**
510
+
511
+ ```bash
512
+ # Revert to previous commit
513
+ git revert HEAD
514
+ git push origin main
515
+ ```
516
+
517
+ **Step 2: Redeploy**
518
+
519
+ ```bash
520
+ cd backend
521
+ npx convex deploy --prod production
522
+ ```
523
+
524
+ **Step 3: Verify**
525
+
526
+ Check that system is functioning normally.
527
+
528
+ ---
529
+
530
+ ### Planned Rollback (Testing Failed)
531
+
532
+ If staging tests fail:
533
+
534
+ **Step 1: Document Issues**
535
+
536
+ Create detailed issue report:
537
+ - What broke?
538
+ - Which types/features affected?
539
+ - Error messages?
540
+ - Steps to reproduce?
541
+
542
+ **Step 2: Fix Ontology YAMLs**
543
+
544
+ Correct issues in YAML files.
545
+
546
+ **Step 3: Regenerate Types**
547
+
548
+ ```bash
549
+ bun run scripts/generate-ontology-types.ts
550
+ ```
551
+
552
+ **Step 4: Retest**
553
+
554
+ Repeat testing until all issues resolved.
555
+
556
+ ---
557
+
558
+ ## Common Pitfalls
559
+
560
+ ### Pitfall 1: Missing Feature in Environment Variable
561
+
562
+ **Problem:**
563
+
564
+ ```bash
565
+ # .env.local
566
+ PUBLIC_FEATURES="core,blog" # ❌ Forgot 'shop'!
567
+ ```
568
+
569
+ **Result:** Shop types not loaded, mutations fail.
570
+
571
+ **Solution:**
572
+
573
+ ```bash
574
+ # .env.local
575
+ PUBLIC_FEATURES="core,blog,shop" # ✅ All features
576
+ ```
577
+
578
+ ---
579
+
580
+ ### Pitfall 2: Circular Dependencies
581
+
582
+ **Problem:**
583
+
584
+ ```yaml
585
+ # ontology-blog.yaml
586
+ feature: blog
587
+ extends: portfolio # ❌ Circular!
588
+
589
+ # ontology-portfolio.yaml
590
+ feature: portfolio
591
+ extends: blog # ❌ Circular!
592
+ ```
593
+
594
+ **Solution:**
595
+
596
+ ```yaml
597
+ # ontology-blog.yaml
598
+ feature: blog
599
+ extends: core # ✅ Both extend core
600
+
601
+ # ontology-portfolio.yaml
602
+ feature: portfolio
603
+ extends: core # ✅ Both extend core
604
+ ```
605
+
606
+ ---
607
+
608
+ ### Pitfall 3: Type Mismatch in Properties
609
+
610
+ **Problem:**
611
+
612
+ ```yaml
613
+ # ontology-blog.yaml
614
+ thingTypes:
615
+ - name: blog_post
616
+ properties:
617
+ publishedAt: string # ❌ Should be number!
618
+ ```
619
+
620
+ **Mutation:**
621
+
622
+ ```typescript
623
+ await ctx.db.insert('entities', {
624
+ type: 'blog_post',
625
+ properties: {
626
+ publishedAt: Date.now(), // ❌ number, not string!
627
+ },
628
+ });
629
+ ```
630
+
631
+ **Solution:**
632
+
633
+ ```yaml
634
+ # ontology-blog.yaml
635
+ thingTypes:
636
+ - name: blog_post
637
+ properties:
638
+ publishedAt: number # ✅ Correct type
639
+ ```
640
+
641
+ ---
642
+
643
+ ### Pitfall 4: Not Regenerating Types After Changes
644
+
645
+ **Problem:**
646
+
647
+ 1. Update `ontology-blog.yaml`
648
+ 2. Deploy without regenerating types
649
+ 3. TypeScript still uses old types
650
+
651
+ **Solution:**
652
+
653
+ ```bash
654
+ # Always regenerate after YAML changes
655
+ bun run scripts/generate-ontology-types.ts
656
+ ```
657
+
658
+ **Better: Add to package.json**
659
+
660
+ ```json
661
+ {
662
+ "scripts": {
663
+ "dev": "bun run scripts/generate-ontology-types.ts && npx convex dev",
664
+ "deploy": "bun run scripts/generate-ontology-types.ts && npx convex deploy"
665
+ }
666
+ }
667
+ ```
668
+
669
+ ---
670
+
671
+ ### Pitfall 5: Forgetting to Update Queries
672
+
673
+ **Problem:**
674
+
675
+ ```typescript
676
+ // Old query (hardcoded type list)
677
+ const blogPosts = await ctx.db
678
+ .query('entities')
679
+ .filter(q => q.or(
680
+ q.eq(q.field('type'), 'blog_post'),
681
+ q.eq(q.field('type'), 'article'), // ❌ Old type name
682
+ ))
683
+ .collect();
684
+ ```
685
+
686
+ **Solution:**
687
+
688
+ ```typescript
689
+ import { isThingType } from './types/ontology';
690
+
691
+ const blogPosts = await ctx.db
692
+ .query('entities')
693
+ .filter(q => q.eq(q.field('type'), 'blog_post')) // ✅ Use ontology types
694
+ .collect();
695
+ ```
696
+
697
+ ---
698
+
699
+ ## Case Studies
700
+
701
+ ### Case Study 1: Small Blog Platform
702
+
703
+ **Before:**
704
+ - 5 entity types (hardcoded)
705
+ - Single developer
706
+ - No production traffic
707
+
708
+ **Migration Approach:** Big Bang
709
+
710
+ **Steps:**
711
+ 1. Created 2 YAML files (`core`, `blog`)
712
+ 2. Generated types
713
+ 3. Updated schema
714
+ 4. Deployed to staging
715
+ 5. Deployed to production
716
+
717
+ **Timeline:** 2 hours
718
+
719
+ **Issues:** None
720
+
721
+ **Outcome:** ✅ Successful
722
+
723
+ ---
724
+
725
+ ### Case Study 2: Multi-Feature SaaS Platform
726
+
727
+ **Before:**
728
+ - 35 entity types (hardcoded)
729
+ - 5 developers
730
+ - 10,000 daily active users
731
+
732
+ **Migration Approach:** Gradual
733
+
734
+ **Steps:**
735
+ 1. Week 1: Created all YAML files
736
+ 2. Week 2: Generated types, tested in staging
737
+ 3. Week 3: Migrated `core` feature
738
+ 4. Week 4: Migrated `blog` feature
739
+ 5. Week 5: Migrated `shop` feature
740
+ 6. Week 6: Migrated remaining features
741
+ 7. Week 7: Removed hardcoded types
742
+
743
+ **Timeline:** 7 weeks
744
+
745
+ **Issues:**
746
+ - Week 3: Discovered circular dependency (`blog` ↔ `portfolio`)
747
+ - Week 5: Type mismatch in `product` properties
748
+
749
+ **Outcome:** ✅ Successful
750
+
751
+ ---
752
+
753
+ ### Case Study 3: Enterprise E-Commerce Platform
754
+
755
+ **Before:**
756
+ - 80+ entity types (hardcoded)
757
+ - 20 developers
758
+ - 500,000 daily active users
759
+
760
+ **Migration Approach:** Dual-Write
761
+
762
+ **Steps:**
763
+ 1. Month 1: Created all YAML files
764
+ 2. Month 2: Dual-write system (both hardcoded + ontology)
765
+ 3. Month 3: Data consistency validation
766
+ 4. Month 4: Shifted 25% of reads to ontology
767
+ 5. Month 5: Shifted 50% of reads to ontology
768
+ 6. Month 6: Shifted 100% of reads to ontology
769
+ 7. Month 7: Removed hardcoded types
770
+
771
+ **Timeline:** 7 months
772
+
773
+ **Issues:**
774
+ - Month 2: Performance degradation (fixed with caching)
775
+ - Month 4: Data inconsistency (1 type had wrong properties)
776
+
777
+ **Outcome:** ✅ Successful
778
+
779
+ ---
780
+
781
+ ## Summary
782
+
783
+ **Migration Checklist:**
784
+
785
+ - [ ] Inventory all entity types
786
+ - [ ] Group types into features
787
+ - [ ] Create ontology YAML files
788
+ - [ ] Generate types in test environment
789
+ - [ ] Update schema
790
+ - [ ] Update mutations/queries
791
+ - [ ] Deploy to staging
792
+ - [ ] Test thoroughly
793
+ - [ ] Deploy to production
794
+ - [ ] Monitor for issues
795
+ - [ ] Document lessons learned
796
+
797
+ **Key Takeaways:**
798
+
799
+ 1. **Backup everything** before migration
800
+ 2. **Test in staging first** (always!)
801
+ 3. **Use gradual migration** for production systems
802
+ 4. **Monitor closely** after deployment
803
+ 5. **Have a rollback plan** ready
804
+ 6. **Regenerate types** after every YAML change
805
+ 7. **Update all code** (schema, mutations, queries)
806
+
807
+ **Next Steps:**
808
+
809
+ - Read the [Quick Start Guide](./ontology-quickstart.md)
810
+ - Explore the [Developer Guide](./ontology-developer-guide.md)
811
+ - Study example ontologies in `/one/knowledge/ontology-*.yaml`