oneie 3.4.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/one.md +28 -5
- package/folders.yaml +1 -1
- package/one/events/contact-page-complete.md +298 -0
- package/one/events/session-summary-2025-10-18.md +348 -0
- package/one/events/skills-complete.md +333 -0
- package/one/events/skills-infer-6-10-summary.md +52 -0
- package/one/events/skills-phase1-complete.md +263 -0
- package/one/knowledge/lessons-website-building-focus.md +364 -0
- package/one/things/plans/improve-codebase.md +1734 -0
- package/one/things/plans/skills.md +606 -0
- package/one/things/plans/unified-implementation-plan.md +852 -0
- package/package.json +1 -1
|
@@ -0,0 +1,852 @@
|
|
|
1
|
+
# Unified Implementation Plan: Backend-Agnostic + Complete Ontology
|
|
2
|
+
|
|
3
|
+
**Status:** ✅ Phases 1-2 Complete | 🚧 Phases 3-7 In Progress
|
|
4
|
+
**Version:** 2.1.0
|
|
5
|
+
**Date Updated:** 2025-10-18
|
|
6
|
+
**Goal:** Achieve complete ontology implementation with backend-agnostic architecture
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 🎯 Current Status Summary
|
|
11
|
+
|
|
12
|
+
### ✅ COMPLETED (Phases 1-2: 4 weeks)
|
|
13
|
+
|
|
14
|
+
**Phase 1: Foundation** ✅
|
|
15
|
+
- DataProvider interface (6 dimensions) - `/web/src/providers/DataProvider.ts`
|
|
16
|
+
- ConvexProvider implementation
|
|
17
|
+
- Typed errors (ThingNotFoundError, etc.)
|
|
18
|
+
- Backend swapping with ONE line change
|
|
19
|
+
|
|
20
|
+
**Phase 2: Service Layer** ✅
|
|
21
|
+
- ThingService (handles all 66 types generically) - `/web/src/services/ThingService.ts`
|
|
22
|
+
- ConnectionService (all 25 types) - `/web/src/services/ConnectionService.ts`
|
|
23
|
+
- EventService (all 67 events) - `/web/src/services/EventService.ts`
|
|
24
|
+
- KnowledgeService (RAG foundation) - `/web/src/services/KnowledgeService.ts`
|
|
25
|
+
- OrganizationService (groups) - `/web/src/services/OrganizationService.ts`
|
|
26
|
+
- PeopleService - `/web/src/services/PeopleService.ts`
|
|
27
|
+
- React hooks (useEffectRunner) - `/web/src/hooks/`
|
|
28
|
+
- Typed errors throughout
|
|
29
|
+
- Dependency injection via Effect.ts
|
|
30
|
+
|
|
31
|
+
**Backend Schema** ✅
|
|
32
|
+
- 6-dimension ontology complete - `/backend/convex/schema.ts`
|
|
33
|
+
- groups table (hierarchical nesting)
|
|
34
|
+
- entities table (66+ thing types via generic `type` field)
|
|
35
|
+
- connections table (25+ relationship types)
|
|
36
|
+
- events table (67+ event types)
|
|
37
|
+
- knowledge table (RAG + vectors)
|
|
38
|
+
- thingKnowledge junction table
|
|
39
|
+
|
|
40
|
+
### 🚧 REMAINING (Phases 3-7: 7 weeks)
|
|
41
|
+
|
|
42
|
+
**Phase 3: Backend Implementation** (Weeks 5-8) - 🔴 NOT STARTED
|
|
43
|
+
- [ ] Implement CRUD mutations for all 66 thing types
|
|
44
|
+
- [ ] Add event logging to all mutations
|
|
45
|
+
- [ ] Enforce group scoping
|
|
46
|
+
- [ ] Add rate limiting
|
|
47
|
+
- [ ] Write unit tests
|
|
48
|
+
|
|
49
|
+
**Phase 4: Frontend Integration** (Weeks 9-10) - 🔴 NOT STARTED
|
|
50
|
+
- [ ] Multi-tenant dashboard
|
|
51
|
+
- [ ] Entity management UI (all 66 types)
|
|
52
|
+
- [ ] Connection visualization
|
|
53
|
+
- [ ] Real-time event timeline
|
|
54
|
+
- [ ] Real-time stats
|
|
55
|
+
|
|
56
|
+
**Phase 5: RAG & Knowledge** (Week 10) - 🔴 NOT STARTED
|
|
57
|
+
- [ ] Chunking service (800 tokens, 200 overlap)
|
|
58
|
+
- [ ] Embedding service (OpenAI integration)
|
|
59
|
+
- [ ] RAG ingestion pipeline
|
|
60
|
+
- [ ] Vector search
|
|
61
|
+
- [ ] Knowledge labels
|
|
62
|
+
|
|
63
|
+
**Phase 6: Testing** (Week 10) - 🟡 PARTIAL
|
|
64
|
+
- [x] Auth tests (50+ test cases) - `/test/auth/`
|
|
65
|
+
- [ ] Backend service coverage (90%)
|
|
66
|
+
- [ ] Frontend coverage (70%)
|
|
67
|
+
- [ ] Multi-backend tests
|
|
68
|
+
- [ ] CI/CD pipeline
|
|
69
|
+
|
|
70
|
+
**Phase 7: Multi-Backend** (Week 11) - 🔴 NOT STARTED (Optional)
|
|
71
|
+
- [ ] WordPressProvider
|
|
72
|
+
- [ ] SupabaseProvider
|
|
73
|
+
- [ ] CompositeProvider (multi-backend routing)
|
|
74
|
+
|
|
75
|
+
### 📊 Progress Metrics
|
|
76
|
+
|
|
77
|
+
| Metric | Target | Current | Status |
|
|
78
|
+
|--------|--------|---------|--------|
|
|
79
|
+
| **Architecture Complete** | 100% | 100% | ✅ |
|
|
80
|
+
| **Service Layer Complete** | 100% | 100% | ✅ |
|
|
81
|
+
| **Backend CRUD Operations** | 100% | 10% | 🔴 |
|
|
82
|
+
| **Frontend UI Complete** | 100% | 20% | 🔴 |
|
|
83
|
+
| **RAG Implementation** | 100% | 0% | 🔴 |
|
|
84
|
+
| **Test Coverage** | 90% | 50% | 🟡 |
|
|
85
|
+
| **Multi-Backend Support** | 2+ providers | 1 (Convex) | 🟡 |
|
|
86
|
+
|
|
87
|
+
**Overall: 36% Complete** (4 of 11 weeks)
|
|
88
|
+
|
|
89
|
+
### 🎯 Next Inference (Infer 101)
|
|
90
|
+
|
|
91
|
+
**Start Phase 3: Backend Implementation - Week 5**
|
|
92
|
+
|
|
93
|
+
Task: Implement CRUD mutations for Priority 1 entity types (core entities)
|
|
94
|
+
- Create mutations using ThingService (backend-agnostic)
|
|
95
|
+
- Add event logging automatically
|
|
96
|
+
- Enforce group scoping
|
|
97
|
+
- Add rate limiting
|
|
98
|
+
|
|
99
|
+
Entity types to implement:
|
|
100
|
+
1. creator
|
|
101
|
+
2. ai_clone
|
|
102
|
+
3. audience_member
|
|
103
|
+
4. organization
|
|
104
|
+
|
|
105
|
+
**Estimated Time:** 3-4 days
|
|
106
|
+
**Risk:** Low (pattern is clear, just replication)
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Executive Summary: Two Plans, One Vision
|
|
111
|
+
|
|
112
|
+
After analyzing both `separate.md` (backend-agnostic architecture) and `improve-codebase.md` (complete ontology implementation), the answer is clear:
|
|
113
|
+
|
|
114
|
+
**✅ YES - Both plans improve the codebase AND must be implemented together.**
|
|
115
|
+
|
|
116
|
+
### Why Both Plans Are Essential
|
|
117
|
+
|
|
118
|
+
**Problem if you implement `improve-codebase.md` alone:**
|
|
119
|
+
- You build 66 thing types tightly coupled to Convex
|
|
120
|
+
- No backend flexibility
|
|
121
|
+
- Organizations locked into Convex
|
|
122
|
+
- Future migration becomes 10x harder
|
|
123
|
+
|
|
124
|
+
**Problem if you implement `separate.md` alone:**
|
|
125
|
+
- You have a beautiful architecture with no features
|
|
126
|
+
- DataProvider wraps incomplete backend
|
|
127
|
+
- Can't demonstrate multi-backend capability
|
|
128
|
+
- No production value
|
|
129
|
+
|
|
130
|
+
**Solution: Unified Implementation**
|
|
131
|
+
- Implement DataProvider architecture FIRST (separate.md)
|
|
132
|
+
- Build all 66 thing types USING DataProvider (improve-codebase.md)
|
|
133
|
+
- Result: Complete ontology + Backend flexibility
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## The Critical Insight
|
|
138
|
+
|
|
139
|
+
### ❌ Wrong Sequence (What NOT to Do)
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
Week 1-4: Implement 66 thing types in Convex mutations
|
|
143
|
+
Week 5-6: Add Effect.ts glue layer
|
|
144
|
+
Week 7-10: Migrate to DataProvider architecture
|
|
145
|
+
|
|
146
|
+
Result: Wasted 6 weeks building tightly-coupled code, then refactoring it
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### ✅ Right Sequence (The Unified Plan)
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
Week 1-2: Implement DataProvider interface + ConvexProvider
|
|
153
|
+
Week 3-4: Create Effect.ts services using DataProvider
|
|
154
|
+
Week 5-8: Implement all 66 thing types through services
|
|
155
|
+
Week 9-10: Add multi-tenant UI and RAG
|
|
156
|
+
Week 11: Add alternative backend (prove flexibility)
|
|
157
|
+
|
|
158
|
+
Result: Everything built right the first time
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Unified Architecture
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
167
|
+
│ FRONTEND (Astro + React) │
|
|
168
|
+
│ │
|
|
169
|
+
│ ┌──────────────────────────────────────────────────────────┐ │
|
|
170
|
+
│ │ Multi-Tenant UI (improve-codebase.md) │ │
|
|
171
|
+
│ │ - Group hierarchy navigation │ │
|
|
172
|
+
│ │ - Entity management for all 66 types │ │
|
|
173
|
+
│ │ - Connection visualization │ │
|
|
174
|
+
│ │ - Real-time event timeline │ │
|
|
175
|
+
│ └──────────────────────────────────────────────────────────┘ │
|
|
176
|
+
│ ↓ │
|
|
177
|
+
│ ┌──────────────────────────────────────────────────────────┐ │
|
|
178
|
+
│ │ Effect.ts Services (both plans) │ │
|
|
179
|
+
│ │ - ThingService (all 66 types) │ │
|
|
180
|
+
│ │ - ConnectionService (all 25 types) │ │
|
|
181
|
+
│ │ - EventService (all 67 events) │ │
|
|
182
|
+
│ │ - KnowledgeService (RAG + embeddings) │ │
|
|
183
|
+
│ └──────────────────────────────────────────────────────────┘ │
|
|
184
|
+
│ ↓ │
|
|
185
|
+
│ ┌──────────────────────────────────────────────────────────┐ │
|
|
186
|
+
│ │ DataProvider Interface (separate.md) │ │
|
|
187
|
+
│ │ - Backend-agnostic API │ │
|
|
188
|
+
│ │ - groups, people, things, connections, events, knowledge│ │
|
|
189
|
+
│ └──────────────────────────────────────────────────────────┘ │
|
|
190
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
191
|
+
↓
|
|
192
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
193
|
+
│ BACKEND PROVIDERS (separate.md) │
|
|
194
|
+
│ │
|
|
195
|
+
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
|
|
196
|
+
│ │ Convex │ │ WordPress │ │ Supabase │ │
|
|
197
|
+
│ │ (default) │ │ (blog) │ │ (analytics) │ │
|
|
198
|
+
│ └──────────────┘ └──────────────┘ └──────────────┘ │
|
|
199
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
200
|
+
↓
|
|
201
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
202
|
+
│ ACTUAL BACKEND DATABASES (improve-codebase.md) │
|
|
203
|
+
│ │
|
|
204
|
+
│ Convex: 6 tables with complete CRUD for all types │
|
|
205
|
+
│ - groups, entities, connections, events, knowledge │
|
|
206
|
+
│ - All 66 thing types supported │
|
|
207
|
+
│ - All 25 connection types supported │
|
|
208
|
+
│ - All 67 event types logged │
|
|
209
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Phase-by-Phase Implementation (11 Weeks)
|
|
215
|
+
|
|
216
|
+
### Phase 1: Foundation (Weeks 1-2) ✅ COMPLETE
|
|
217
|
+
**Goal:** Backend-agnostic architecture in place
|
|
218
|
+
|
|
219
|
+
**From separate.md:**
|
|
220
|
+
- [x] Create DataProvider interface (6 dimensions) ✅ DONE
|
|
221
|
+
- [x] Implement ConvexProvider (wraps existing backend) ✅ DONE
|
|
222
|
+
- [x] Add typed errors (ThingNotFoundError, etc.) ✅ DONE
|
|
223
|
+
- [x] Configure in astro.config.ts ✅ DONE
|
|
224
|
+
|
|
225
|
+
**Acceptance Criteria:**
|
|
226
|
+
- [x] DataProvider interface complete with TypeScript types ✅
|
|
227
|
+
- [x] ConvexProvider implements all methods ✅
|
|
228
|
+
- [x] Existing auth tests pass unchanged ✅
|
|
229
|
+
- [x] Can swap backends by changing ONE line ✅
|
|
230
|
+
|
|
231
|
+
**Actual Effort:** 16 hours (2 days)
|
|
232
|
+
**Actual Risk:** Low (completed without issues)
|
|
233
|
+
|
|
234
|
+
**Location:** `/web/src/providers/DataProvider.ts`
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
### Phase 2: Service Layer (Weeks 3-4) ✅ COMPLETE
|
|
239
|
+
**Goal:** Effect.ts services using DataProvider
|
|
240
|
+
|
|
241
|
+
**From both plans:**
|
|
242
|
+
- [x] Create Effect.ts services for all 6 dimensions ✅ DONE
|
|
243
|
+
- [x] ThingService (handles all 66 types generically) ✅ DONE
|
|
244
|
+
- [x] ConnectionService (all 25 types) ✅ DONE
|
|
245
|
+
- [x] EventService (all 67 events) ✅ DONE
|
|
246
|
+
- [x] KnowledgeService (RAG foundation) ✅ DONE
|
|
247
|
+
- [x] Create useEffectRunner hook for React ✅ DONE
|
|
248
|
+
|
|
249
|
+
**From improve-codebase.md:**
|
|
250
|
+
- [x] Implement typed errors (tagged unions) ✅ DONE
|
|
251
|
+
- [x] Service composition via Layer.mergeAll ✅ DONE
|
|
252
|
+
- [x] Dependency injection ✅ DONE
|
|
253
|
+
- [x] Error handling without try/catch ✅ DONE
|
|
254
|
+
|
|
255
|
+
**Example:**
|
|
256
|
+
```typescript
|
|
257
|
+
// Backend-agnostic ThingService
|
|
258
|
+
export class ThingService extends Effect.Service<ThingService>()({
|
|
259
|
+
effect: Effect.gen(function* () {
|
|
260
|
+
const provider = yield* DataProvider // Works with ANY backend!
|
|
261
|
+
|
|
262
|
+
return {
|
|
263
|
+
create: (type: ThingType, input: any) =>
|
|
264
|
+
Effect.gen(function* () {
|
|
265
|
+
// 1. Validate (same for all backends)
|
|
266
|
+
yield* validateThingInput(type, input)
|
|
267
|
+
|
|
268
|
+
// 2. Create via provider (backend-specific)
|
|
269
|
+
const thingId = yield* provider.things.create({
|
|
270
|
+
type,
|
|
271
|
+
name: input.name,
|
|
272
|
+
groupId: input.groupId,
|
|
273
|
+
properties: input.properties
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
// 3. Log event (via provider)
|
|
277
|
+
yield* provider.events.log({
|
|
278
|
+
type: "entity_created",
|
|
279
|
+
actorId: input.actorId,
|
|
280
|
+
targetId: thingId,
|
|
281
|
+
groupId: input.groupId,
|
|
282
|
+
metadata: { thingType: type }
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
return thingId
|
|
286
|
+
})
|
|
287
|
+
}
|
|
288
|
+
}),
|
|
289
|
+
dependencies: [DataProvider]
|
|
290
|
+
})
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**Acceptance Criteria:**
|
|
294
|
+
- [x] All services use DataProvider (no direct backend calls) ✅
|
|
295
|
+
- [x] Services work with any backend that implements DataProvider ✅
|
|
296
|
+
- [x] Typed errors throughout ✅
|
|
297
|
+
- [ ] 90% test coverage with mocked providers ⚠️ PARTIAL
|
|
298
|
+
|
|
299
|
+
**Actual Effort:** 32 hours (4 days)
|
|
300
|
+
**Actual Risk:** Low (completed successfully)
|
|
301
|
+
|
|
302
|
+
**Location:** `/web/src/services/`
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
### Phase 3: Backend Implementation (Weeks 5-8)
|
|
307
|
+
**Goal:** Complete CRUD for all 66 thing types
|
|
308
|
+
|
|
309
|
+
**From improve-codebase.md (but using DataProvider!):**
|
|
310
|
+
|
|
311
|
+
**Week 5: Core Entities (Priority 1)**
|
|
312
|
+
- [ ] Creator, AI Clone, Audience Member, Organization
|
|
313
|
+
- [ ] Convex mutations use services (thin wrappers)
|
|
314
|
+
- [ ] Event logging automatic
|
|
315
|
+
- [ ] Group scoping enforced
|
|
316
|
+
|
|
317
|
+
**Week 6: Content & Products (Priority 2)**
|
|
318
|
+
- [ ] Blog posts, courses, lessons, videos, podcasts
|
|
319
|
+
- [ ] Products, memberships, digital goods
|
|
320
|
+
- [ ] Content lifecycle (draft → published → archived)
|
|
321
|
+
|
|
322
|
+
**Week 7: Tokens, Agents & AI (Priority 3 & 4)**
|
|
323
|
+
- [ ] Tokens, token contracts
|
|
324
|
+
- [ ] 10 business agents (strategy, marketing, sales, etc.)
|
|
325
|
+
- [ ] External agents, workflows
|
|
326
|
+
|
|
327
|
+
**Week 8: Auth, Knowledge & Remaining (Priority 5)**
|
|
328
|
+
- [ ] Sessions, OAuth accounts, verification tokens
|
|
329
|
+
- [ ] Knowledge items, embeddings
|
|
330
|
+
- [ ] Metrics, insights, predictions
|
|
331
|
+
- [ ] Notifications, campaigns
|
|
332
|
+
|
|
333
|
+
**Key Difference from improve-codebase.md:**
|
|
334
|
+
```typescript
|
|
335
|
+
// ❌ OLD WAY (improve-codebase.md alone - tightly coupled)
|
|
336
|
+
export const createCourse = mutation({
|
|
337
|
+
handler: async (ctx, args) => {
|
|
338
|
+
// Direct Convex DB calls
|
|
339
|
+
const courseId = await ctx.db.insert("entities", { ... })
|
|
340
|
+
await ctx.db.insert("events", { ... })
|
|
341
|
+
return courseId
|
|
342
|
+
}
|
|
343
|
+
})
|
|
344
|
+
|
|
345
|
+
// ✅ NEW WAY (unified plan - backend-agnostic)
|
|
346
|
+
export const createCourse = mutation({
|
|
347
|
+
handler: async (ctx, args) => {
|
|
348
|
+
// Use service via DataProvider
|
|
349
|
+
const program = Effect.gen(function* () {
|
|
350
|
+
const courseService = yield* CourseService
|
|
351
|
+
return yield* courseService.create(args)
|
|
352
|
+
})
|
|
353
|
+
|
|
354
|
+
return await Effect.runPromise(
|
|
355
|
+
program.pipe(Effect.provide(ServicesLayer))
|
|
356
|
+
)
|
|
357
|
+
}
|
|
358
|
+
})
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
**Acceptance Criteria:**
|
|
362
|
+
- [ ] All 66 thing types have CRUD operations
|
|
363
|
+
- [ ] All mutations use services (not direct DB)
|
|
364
|
+
- [ ] All operations log events
|
|
365
|
+
- [ ] Group scoping enforced
|
|
366
|
+
- [ ] Works with ConvexProvider
|
|
367
|
+
|
|
368
|
+
**Effort:** 120 hours (15 days across 4 weeks)
|
|
369
|
+
**Risk:** Low (following established patterns)
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
### Phase 4: Frontend Integration (Weeks 9-10)
|
|
374
|
+
**Goal:** Multi-tenant UI for complete ontology
|
|
375
|
+
|
|
376
|
+
**From improve-codebase.md:**
|
|
377
|
+
- [ ] Multi-tenant dashboard with group hierarchy
|
|
378
|
+
- [ ] Entity management UI (all 66 types)
|
|
379
|
+
- [ ] Connection visualization (graph view)
|
|
380
|
+
- [ ] Real-time event timeline
|
|
381
|
+
- [ ] Real-time stats and analytics
|
|
382
|
+
|
|
383
|
+
**Using DataProvider (from separate.md):**
|
|
384
|
+
```tsx
|
|
385
|
+
// Frontend components are backend-agnostic!
|
|
386
|
+
export function CreateCourseForm() {
|
|
387
|
+
const { run, loading } = useEffectRunner()
|
|
388
|
+
|
|
389
|
+
const handleSubmit = async (data: CourseData) => {
|
|
390
|
+
const program = Effect.gen(function* () {
|
|
391
|
+
const courseService = yield* CourseService
|
|
392
|
+
// This works with ANY backend (Convex, WordPress, etc.)
|
|
393
|
+
return yield* courseService.create("course", data)
|
|
394
|
+
})
|
|
395
|
+
|
|
396
|
+
const courseId = await run(program)
|
|
397
|
+
navigate(`/courses/${courseId}`)
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
return <form onSubmit={handleSubmit}>...</form>
|
|
401
|
+
}
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
**Acceptance Criteria:**
|
|
405
|
+
- [ ] Group selector with full hierarchy
|
|
406
|
+
- [ ] Entity forms for all 66 types
|
|
407
|
+
- [ ] Real-time updates via subscriptions
|
|
408
|
+
- [ ] Connection graph visualization
|
|
409
|
+
- [ ] Event timeline with filtering
|
|
410
|
+
- [ ] Role-based access control
|
|
411
|
+
|
|
412
|
+
**Effort:** 64 hours (8 days)
|
|
413
|
+
**Risk:** Medium (complex UI)
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
### Phase 5: RAG & Knowledge (Week 10)
|
|
418
|
+
**Goal:** Complete knowledge implementation
|
|
419
|
+
|
|
420
|
+
**From improve-codebase.md:**
|
|
421
|
+
- [ ] Chunking service (800 tokens, 200 overlap)
|
|
422
|
+
- [ ] Embedding service (OpenAI integration)
|
|
423
|
+
- [ ] RAG ingestion pipeline
|
|
424
|
+
- [ ] Vector search
|
|
425
|
+
- [ ] Knowledge labels
|
|
426
|
+
|
|
427
|
+
**Using DataProvider:**
|
|
428
|
+
```typescript
|
|
429
|
+
// RAG works with any backend that supports vector storage
|
|
430
|
+
export const ingestThing = (thingId: string) =>
|
|
431
|
+
Effect.gen(function* () {
|
|
432
|
+
const provider = yield* DataProvider
|
|
433
|
+
const chunking = yield* ChunkingService
|
|
434
|
+
const embedding = yield* EmbeddingService
|
|
435
|
+
|
|
436
|
+
// Get thing (from any backend)
|
|
437
|
+
const thing = yield* provider.things.get(thingId)
|
|
438
|
+
|
|
439
|
+
// Extract and chunk text
|
|
440
|
+
const chunks = yield* chunking.chunk(thing.properties.content)
|
|
441
|
+
|
|
442
|
+
// Embed chunks
|
|
443
|
+
const embeddings = yield* embedding.embedBatch(chunks.map(c => c.text))
|
|
444
|
+
|
|
445
|
+
// Store via provider (backend-agnostic!)
|
|
446
|
+
for (let i = 0; i < chunks.length; i++) {
|
|
447
|
+
yield* provider.knowledge.create({
|
|
448
|
+
groupId: thing.groupId,
|
|
449
|
+
knowledgeType: "chunk",
|
|
450
|
+
text: chunks[i].text,
|
|
451
|
+
embedding: embeddings[i].embedding,
|
|
452
|
+
sourceThingId: thingId
|
|
453
|
+
})
|
|
454
|
+
}
|
|
455
|
+
})
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
**Acceptance Criteria:**
|
|
459
|
+
- [ ] Chunking handles 66 thing types
|
|
460
|
+
- [ ] Embeddings work via provider
|
|
461
|
+
- [ ] Vector search returns relevant results
|
|
462
|
+
- [ ] Knowledge labels for categorization
|
|
463
|
+
|
|
464
|
+
**Effort:** 32 hours (4 days)
|
|
465
|
+
**Risk:** Medium (OpenAI API integration)
|
|
466
|
+
|
|
467
|
+
---
|
|
468
|
+
|
|
469
|
+
### Phase 6: Testing (Week 10)
|
|
470
|
+
**Goal:** Comprehensive test coverage
|
|
471
|
+
|
|
472
|
+
**From improve-codebase.md:**
|
|
473
|
+
- [ ] 90% backend service coverage
|
|
474
|
+
- [ ] All 66 thing types tested
|
|
475
|
+
- [ ] All 25 connection types tested
|
|
476
|
+
- [ ] All 67 event types verified
|
|
477
|
+
|
|
478
|
+
**From separate.md:**
|
|
479
|
+
- [ ] Mock providers for testing
|
|
480
|
+
- [ ] Provider swapping tests
|
|
481
|
+
- [ ] Multi-backend tests
|
|
482
|
+
- [ ] Auth tests pass (critical!)
|
|
483
|
+
|
|
484
|
+
**Example:**
|
|
485
|
+
```typescript
|
|
486
|
+
// Test with multiple providers!
|
|
487
|
+
describe("ThingService", () => {
|
|
488
|
+
const testWithProvider = (providerName: string, provider: Layer<DataProvider>) => {
|
|
489
|
+
it(`should create thing via ${providerName}`, async () => {
|
|
490
|
+
const program = Effect.gen(function* () {
|
|
491
|
+
const thingService = yield* ThingService
|
|
492
|
+
const thingId = yield* thingService.create("course", { ... })
|
|
493
|
+
expect(thingId).toBeDefined()
|
|
494
|
+
})
|
|
495
|
+
|
|
496
|
+
await Effect.runPromise(
|
|
497
|
+
program.pipe(Effect.provide(provider))
|
|
498
|
+
)
|
|
499
|
+
})
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
testWithProvider("Convex", ConvexProviderMock)
|
|
503
|
+
testWithProvider("Supabase", SupabaseProviderMock)
|
|
504
|
+
testWithProvider("WordPress", WordPressProviderMock)
|
|
505
|
+
})
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
**Acceptance Criteria:**
|
|
509
|
+
- [ ] 90% backend coverage
|
|
510
|
+
- [ ] 70% frontend coverage
|
|
511
|
+
- [ ] Tests pass with multiple providers
|
|
512
|
+
- [ ] All auth tests pass
|
|
513
|
+
- [ ] CI/CD pipeline green
|
|
514
|
+
|
|
515
|
+
**Effort:** 40 hours (5 days)
|
|
516
|
+
**Risk:** Low (testing infrastructure exists)
|
|
517
|
+
|
|
518
|
+
---
|
|
519
|
+
|
|
520
|
+
### Phase 7: Multi-Backend (Week 11 - Optional)
|
|
521
|
+
**Goal:** Prove true backend flexibility
|
|
522
|
+
|
|
523
|
+
**From separate.md:**
|
|
524
|
+
- [ ] Implement WordPressProvider
|
|
525
|
+
- [ ] Implement SupabaseProvider
|
|
526
|
+
- [ ] Implement CompositeProvider (multi-backend)
|
|
527
|
+
|
|
528
|
+
**Real-World Example:**
|
|
529
|
+
```typescript
|
|
530
|
+
// astro.config.ts - Mix and match backends!
|
|
531
|
+
export default defineConfig({
|
|
532
|
+
integrations: [
|
|
533
|
+
one({
|
|
534
|
+
provider: compositeProvider({
|
|
535
|
+
default: convexProvider({ url: env.PUBLIC_CONVEX_URL }),
|
|
536
|
+
routes: {
|
|
537
|
+
// Blog from WordPress
|
|
538
|
+
blog_post: wordpressProvider({
|
|
539
|
+
url: "https://blog.yoursite.com",
|
|
540
|
+
apiKey: env.WP_API_KEY
|
|
541
|
+
}),
|
|
542
|
+
|
|
543
|
+
// Products from Shopify
|
|
544
|
+
product: shopifyProvider({
|
|
545
|
+
store: "yourstore.myshopify.com",
|
|
546
|
+
token: env.SHOPIFY_TOKEN
|
|
547
|
+
}),
|
|
548
|
+
|
|
549
|
+
// Analytics from Supabase
|
|
550
|
+
metric: supabaseProvider({
|
|
551
|
+
url: env.SUPABASE_URL,
|
|
552
|
+
key: env.SUPABASE_KEY
|
|
553
|
+
})
|
|
554
|
+
}
|
|
555
|
+
})
|
|
556
|
+
})
|
|
557
|
+
]
|
|
558
|
+
})
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
**Acceptance Criteria:**
|
|
562
|
+
- [ ] At least 2 alternative providers working
|
|
563
|
+
- [ ] CompositeProvider routes correctly
|
|
564
|
+
- [ ] Frontend works unchanged
|
|
565
|
+
- [ ] Can swap backends with ONE line
|
|
566
|
+
|
|
567
|
+
**Effort:** 40 hours (5 days)
|
|
568
|
+
**Risk:** Low (proves concept, not critical path)
|
|
569
|
+
|
|
570
|
+
---
|
|
571
|
+
|
|
572
|
+
## Comparison: Separate vs Unified Plans
|
|
573
|
+
|
|
574
|
+
| Aspect | improve-codebase.md alone | separate.md alone | Unified Plan |
|
|
575
|
+
|--------|---------------------------|-------------------|--------------|
|
|
576
|
+
| **Timeline** | 14 weeks | 6 weeks | 11 weeks |
|
|
577
|
+
| **Backend Flexibility** | ❌ None (Convex only) | ✅ Full (any backend) | ✅ Full (any backend) |
|
|
578
|
+
| **Ontology Coverage** | ✅ Complete (66 types) | ⚠️ Partial (demo only) | ✅ Complete (66 types) |
|
|
579
|
+
| **Effect.ts Services** | ✅ Full | ✅ Full | ✅ Full |
|
|
580
|
+
| **Multi-Tenant UI** | ✅ Complete | ❌ Missing | ✅ Complete |
|
|
581
|
+
| **RAG Implementation** | ✅ Complete | ❌ Missing | ✅ Complete |
|
|
582
|
+
| **Future Refactoring** | ❌ 6 weeks to add flexibility | ✅ None needed | ✅ None needed |
|
|
583
|
+
| **Risk** | Medium (tight coupling) | Low (architecture only) | Low (build right first time) |
|
|
584
|
+
| **Production Value** | ✅ High | ⚠️ Low (no features) | ✅ Very High |
|
|
585
|
+
|
|
586
|
+
**Winner:** Unified Plan
|
|
587
|
+
- Faster than improve-codebase.md alone (11 weeks vs 14 weeks)
|
|
588
|
+
- More valuable than separate.md alone (complete features)
|
|
589
|
+
- No future refactoring needed
|
|
590
|
+
- Built right the first time
|
|
591
|
+
|
|
592
|
+
---
|
|
593
|
+
|
|
594
|
+
## Critical Success Factors
|
|
595
|
+
|
|
596
|
+
### 1. Architecture First (Week 1-2)
|
|
597
|
+
**DO NOT SKIP:** Implement DataProvider before building features
|
|
598
|
+
|
|
599
|
+
```typescript
|
|
600
|
+
// ❌ WRONG - Build features first, refactor later
|
|
601
|
+
Week 1: Build createCourse mutation directly in Convex
|
|
602
|
+
Week 8: Try to wrap in DataProvider → painful refactoring
|
|
603
|
+
|
|
604
|
+
// ✅ RIGHT - Architecture first
|
|
605
|
+
Week 1: Create DataProvider interface
|
|
606
|
+
Week 2: Implement ConvexProvider
|
|
607
|
+
Week 3: Build createCourse using ThingService + DataProvider
|
|
608
|
+
Week 8: Add WordPressProvider → just works, no refactoring
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
### 2. Test at Every Phase
|
|
612
|
+
**From separate.md:** Auth tests MUST pass after each phase
|
|
613
|
+
|
|
614
|
+
```bash
|
|
615
|
+
# After Phase 1 (DataProvider)
|
|
616
|
+
npm test frontend/tests/auth/
|
|
617
|
+
# All tests should pass
|
|
618
|
+
|
|
619
|
+
# After Phase 2 (Services)
|
|
620
|
+
npm test frontend/tests/auth/
|
|
621
|
+
# All tests should pass
|
|
622
|
+
|
|
623
|
+
# After Phase 5 (Frontend migration)
|
|
624
|
+
npm test frontend/tests/auth/
|
|
625
|
+
# All tests should pass
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
### 3. Services Use DataProvider (Not Direct Backend)
|
|
629
|
+
**From improve-codebase.md:** Effect.ts services with typed errors
|
|
630
|
+
**From separate.md:** Services use DataProvider interface
|
|
631
|
+
|
|
632
|
+
```typescript
|
|
633
|
+
// ✅ RIGHT - Service uses DataProvider
|
|
634
|
+
export class ThingService {
|
|
635
|
+
create = (type, input) =>
|
|
636
|
+
Effect.gen(function* () {
|
|
637
|
+
const provider = yield* DataProvider // Backend-agnostic!
|
|
638
|
+
return yield* provider.things.create({ type, ...input })
|
|
639
|
+
})
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
// ❌ WRONG - Service calls Convex directly
|
|
643
|
+
export class ThingService {
|
|
644
|
+
create = (type, input) =>
|
|
645
|
+
Effect.gen(function* () {
|
|
646
|
+
const ctx = yield* ConvexContext // Tightly coupled!
|
|
647
|
+
return yield* Effect.tryPromise(() =>
|
|
648
|
+
ctx.db.insert("entities", { type, ...input })
|
|
649
|
+
)
|
|
650
|
+
})
|
|
651
|
+
}
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
---
|
|
655
|
+
|
|
656
|
+
## Migration from Current State
|
|
657
|
+
|
|
658
|
+
### Current State Analysis
|
|
659
|
+
```
|
|
660
|
+
✅ Working:
|
|
661
|
+
- Groups CRUD (mutations + queries)
|
|
662
|
+
- Connections CRUD (mutations + queries)
|
|
663
|
+
- Auth (Better Auth + tests passing)
|
|
664
|
+
- Schema (6-dimension ontology defined)
|
|
665
|
+
|
|
666
|
+
⚠️ Partial:
|
|
667
|
+
- Only 2 of 66 thing types implemented
|
|
668
|
+
- No Effect.ts layer
|
|
669
|
+
- No DataProvider abstraction
|
|
670
|
+
- Frontend tightly coupled to Convex
|
|
671
|
+
|
|
672
|
+
❌ Missing:
|
|
673
|
+
- 64 thing types
|
|
674
|
+
- RAG implementation
|
|
675
|
+
- Multi-tenant UI
|
|
676
|
+
- Protocol integration
|
|
677
|
+
- Alternative backends
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
### Migration Path
|
|
681
|
+
```
|
|
682
|
+
Phase 1-2: Add abstraction layer (DataProvider + Services)
|
|
683
|
+
└─> Wraps existing groups/connections
|
|
684
|
+
└─> Auth tests still pass
|
|
685
|
+
└─> Zero functionality lost
|
|
686
|
+
|
|
687
|
+
Phase 3-4: Fill in missing 64 thing types
|
|
688
|
+
└─> Use DataProvider (not direct Convex)
|
|
689
|
+
└─> Built right the first time
|
|
690
|
+
|
|
691
|
+
Phase 5-6: Add UI and RAG
|
|
692
|
+
└─> Uses services (backend-agnostic)
|
|
693
|
+
|
|
694
|
+
Phase 7: Prove flexibility with alternative backend
|
|
695
|
+
└─> Demonstrates the value of architecture
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
---
|
|
699
|
+
|
|
700
|
+
## Effort Summary
|
|
701
|
+
|
|
702
|
+
| Phase | Weeks | Hours | From Plan | Risk |
|
|
703
|
+
|-------|-------|-------|-----------|------|
|
|
704
|
+
| 1. DataProvider | 2 | 16 | separate.md | Low |
|
|
705
|
+
| 2. Services | 2 | 32 | both | Medium |
|
|
706
|
+
| 3. Backend (66 types) | 4 | 120 | improve-codebase.md | Low |
|
|
707
|
+
| 4. Frontend UI | 2 | 64 | improve-codebase.md | Medium |
|
|
708
|
+
| 5. RAG + Testing | 1 | 72 | improve-codebase.md | Medium |
|
|
709
|
+
| 6. Multi-Backend | 1 | 40 | separate.md | Low |
|
|
710
|
+
| **TOTAL** | **11** | **344** | **Unified** | **Low-Medium** |
|
|
711
|
+
|
|
712
|
+
**Comparison:**
|
|
713
|
+
- improve-codebase.md alone: 14 weeks, 592 hours, tight coupling
|
|
714
|
+
- separate.md alone: 6 weeks, no features
|
|
715
|
+
- **Unified plan: 11 weeks, 344 hours, complete + flexible**
|
|
716
|
+
|
|
717
|
+
**Savings:**
|
|
718
|
+
- 3 weeks faster than improve-codebase.md
|
|
719
|
+
- Zero refactoring needed later
|
|
720
|
+
- Built right the first time
|
|
721
|
+
|
|
722
|
+
---
|
|
723
|
+
|
|
724
|
+
## Decision Matrix
|
|
725
|
+
|
|
726
|
+
### Should You Implement This?
|
|
727
|
+
|
|
728
|
+
**Implement Unified Plan If:**
|
|
729
|
+
- ✅ You need backend flexibility for customer acquisition
|
|
730
|
+
- ✅ You want complete ontology implementation (66 types)
|
|
731
|
+
- ✅ You can dedicate 11 weeks to strategic work
|
|
732
|
+
- ✅ You want to avoid future refactoring
|
|
733
|
+
- ✅ You want multi-backend support (Convex + WordPress + Supabase)
|
|
734
|
+
|
|
735
|
+
**Wait If:**
|
|
736
|
+
- ⚠️ You have urgent features to ship (< 4 weeks deadline)
|
|
737
|
+
- ⚠️ Current Convex-only setup meets all needs
|
|
738
|
+
- ⚠️ No customers requesting alternative backends
|
|
739
|
+
- ⚠️ Team unfamiliar with Effect.ts (need training first)
|
|
740
|
+
|
|
741
|
+
**Never Do (Anti-Patterns):**
|
|
742
|
+
- ❌ Implement improve-codebase.md without DataProvider
|
|
743
|
+
- ❌ Skip Phase 1-2 and build features directly in Convex
|
|
744
|
+
- ❌ Mix backend-specific code in services
|
|
745
|
+
- ❌ Build UI before services exist
|
|
746
|
+
|
|
747
|
+
---
|
|
748
|
+
|
|
749
|
+
## Success Metrics
|
|
750
|
+
|
|
751
|
+
**Technical Completeness:**
|
|
752
|
+
- [ ] 66/66 thing types implemented
|
|
753
|
+
- [ ] 25/25 connection types implemented
|
|
754
|
+
- [ ] 67/67 event types logged
|
|
755
|
+
- [ ] DataProvider interface complete
|
|
756
|
+
- [ ] 2+ backend providers working
|
|
757
|
+
- [ ] 90% test coverage
|
|
758
|
+
|
|
759
|
+
**Architecture Quality:**
|
|
760
|
+
- [ ] Services use DataProvider (no direct backend)
|
|
761
|
+
- [ ] Can swap backends with ONE line change
|
|
762
|
+
- [ ] Effect.ts services have typed errors
|
|
763
|
+
- [ ] Zero try/catch in business logic
|
|
764
|
+
- [ ] Clear separation: frontend → services → provider → backend
|
|
765
|
+
|
|
766
|
+
**Production Readiness:**
|
|
767
|
+
- [ ] Multi-tenant UI complete
|
|
768
|
+
- [ ] RAG pipeline working
|
|
769
|
+
- [ ] Auth tests passing
|
|
770
|
+
- [ ] Real-time subscriptions working
|
|
771
|
+
- [ ] Group hierarchy navigation
|
|
772
|
+
- [ ] Role-based access control
|
|
773
|
+
|
|
774
|
+
**Business Value:**
|
|
775
|
+
- [ ] Can onboard WordPress customers
|
|
776
|
+
- [ ] Can onboard Supabase customers
|
|
777
|
+
- [ ] Can support hybrid backends
|
|
778
|
+
- [ ] Platform-agnostic (frontend works with any backend)
|
|
779
|
+
- [ ] Zero vendor lock-in
|
|
780
|
+
|
|
781
|
+
---
|
|
782
|
+
|
|
783
|
+
## Conclusion
|
|
784
|
+
|
|
785
|
+
### The Answer to Your Question
|
|
786
|
+
|
|
787
|
+
**"Does improve-codebase.md match separate.md? Do they improve both?"**
|
|
788
|
+
|
|
789
|
+
**YES and NO:**
|
|
790
|
+
|
|
791
|
+
✅ **YES, they complement each other perfectly:**
|
|
792
|
+
- separate.md provides the architecture (DataProvider)
|
|
793
|
+
- improve-codebase.md provides the features (66 types)
|
|
794
|
+
- Together they create a complete, flexible platform
|
|
795
|
+
|
|
796
|
+
❌ **NO, they don't match in isolation:**
|
|
797
|
+
- improve-codebase.md alone = complete but inflexible
|
|
798
|
+
- separate.md alone = flexible but incomplete
|
|
799
|
+
- You need BOTH to achieve the vision
|
|
800
|
+
|
|
801
|
+
### The Unified Plan is the Answer
|
|
802
|
+
|
|
803
|
+
**What it gives you:**
|
|
804
|
+
1. **Complete Ontology** (from improve-codebase.md)
|
|
805
|
+
- All 66 thing types
|
|
806
|
+
- All 25 connection types
|
|
807
|
+
- All 67 event types
|
|
808
|
+
- Full RAG implementation
|
|
809
|
+
- Multi-tenant UI
|
|
810
|
+
|
|
811
|
+
2. **Backend Flexibility** (from separate.md)
|
|
812
|
+
- DataProvider interface
|
|
813
|
+
- Support ANY backend
|
|
814
|
+
- Multi-backend federation
|
|
815
|
+
- Zero vendor lock-in
|
|
816
|
+
- Progressive migration path
|
|
817
|
+
|
|
818
|
+
3. **Best Practices** (from both)
|
|
819
|
+
- Effect.ts services
|
|
820
|
+
- Typed errors
|
|
821
|
+
- Service composition
|
|
822
|
+
- Dependency injection
|
|
823
|
+
- Comprehensive testing
|
|
824
|
+
|
|
825
|
+
**Timeline:** 11 weeks (faster than either plan alone)
|
|
826
|
+
|
|
827
|
+
**Effort:** 344 hours (less than improve-codebase.md alone)
|
|
828
|
+
|
|
829
|
+
**Risk:** Low-Medium (architecture first, build right once)
|
|
830
|
+
|
|
831
|
+
**Value:** Complete + Flexible (the best of both plans)
|
|
832
|
+
|
|
833
|
+
---
|
|
834
|
+
|
|
835
|
+
## Next Steps
|
|
836
|
+
|
|
837
|
+
1. **Review this unified plan** with team
|
|
838
|
+
2. **Commit to architecture-first** approach (Phases 1-2)
|
|
839
|
+
3. **Allocate 11 weeks** for implementation
|
|
840
|
+
4. **Start Phase 1** immediately: DataProvider interface
|
|
841
|
+
5. **Do NOT build features** before DataProvider exists
|
|
842
|
+
|
|
843
|
+
**Golden Rule:**
|
|
844
|
+
```
|
|
845
|
+
Build the architecture right.
|
|
846
|
+
Build features once.
|
|
847
|
+
Never refactor for flexibility.
|
|
848
|
+
```
|
|
849
|
+
|
|
850
|
+
The unified plan achieves all goals from both source plans while being faster and less risky than either one alone.
|
|
851
|
+
|
|
852
|
+
**This is the way.**
|