@vue-skuilder/db 0.1.23 → 0.1.24

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 (66) hide show
  1. package/dist/{contentSource-BP9hznNV.d.ts → contentSource-BotbOOfX.d.ts} +227 -3
  2. package/dist/{contentSource-DsJadoBU.d.cts → contentSource-C90LH-OH.d.cts} +227 -3
  3. package/dist/core/index.d.cts +220 -6
  4. package/dist/core/index.d.ts +220 -6
  5. package/dist/core/index.js +2052 -559
  6. package/dist/core/index.js.map +1 -1
  7. package/dist/core/index.mjs +2035 -555
  8. package/dist/core/index.mjs.map +1 -1
  9. package/dist/{dataLayerProvider-CHYrQ5pB.d.cts → dataLayerProvider-DGKp4zFB.d.cts} +1 -1
  10. package/dist/{dataLayerProvider-MDTxXq2l.d.ts → dataLayerProvider-SBpz9jQf.d.ts} +1 -1
  11. package/dist/impl/couch/index.d.cts +11 -3
  12. package/dist/impl/couch/index.d.ts +11 -3
  13. package/dist/impl/couch/index.js +1811 -574
  14. package/dist/impl/couch/index.js.map +1 -1
  15. package/dist/impl/couch/index.mjs +1792 -550
  16. package/dist/impl/couch/index.mjs.map +1 -1
  17. package/dist/impl/static/index.d.cts +4 -4
  18. package/dist/impl/static/index.d.ts +4 -4
  19. package/dist/impl/static/index.js +1797 -560
  20. package/dist/impl/static/index.js.map +1 -1
  21. package/dist/impl/static/index.mjs +1789 -547
  22. package/dist/impl/static/index.mjs.map +1 -1
  23. package/dist/{index-Dj0SEgk3.d.ts → index-BWvO-_rJ.d.ts} +1 -1
  24. package/dist/{index-B_j6u5E4.d.cts → index-Ba7hYbHj.d.cts} +1 -1
  25. package/dist/index.d.cts +36 -11
  26. package/dist/index.d.ts +36 -11
  27. package/dist/index.js +2410 -806
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +2112 -529
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/{types-DQaXnuoc.d.ts → types-CJrLM1Ew.d.ts} +1 -1
  32. package/dist/{types-Bn0itutr.d.cts → types-W8n-B6HG.d.cts} +1 -1
  33. package/dist/{types-legacy-DDY4N-Uq.d.cts → types-legacy-JXDxinpU.d.cts} +5 -1
  34. package/dist/{types-legacy-DDY4N-Uq.d.ts → types-legacy-JXDxinpU.d.ts} +5 -1
  35. package/dist/util/packer/index.d.cts +3 -3
  36. package/dist/util/packer/index.d.ts +3 -3
  37. package/docs/brainstorm-navigation-paradigm.md +40 -34
  38. package/docs/future-orchestration-vision.md +216 -0
  39. package/docs/navigators-architecture.md +188 -5
  40. package/docs/todo-strategy-authoring.md +8 -6
  41. package/package.json +3 -3
  42. package/src/core/index.ts +2 -0
  43. package/src/core/interfaces/contentSource.ts +7 -0
  44. package/src/core/interfaces/userDB.ts +6 -0
  45. package/src/core/navigators/Pipeline.ts +46 -0
  46. package/src/core/navigators/PipelineAssembler.ts +14 -1
  47. package/src/core/navigators/filters/WeightedFilter.ts +141 -0
  48. package/src/core/navigators/filters/types.ts +4 -0
  49. package/src/core/navigators/generators/CompositeGenerator.ts +61 -19
  50. package/src/core/navigators/generators/types.ts +4 -0
  51. package/src/core/navigators/index.ts +194 -13
  52. package/src/core/orchestration/gradient.ts +133 -0
  53. package/src/core/orchestration/index.ts +210 -0
  54. package/src/core/orchestration/learning.ts +250 -0
  55. package/src/core/orchestration/recording.ts +92 -0
  56. package/src/core/orchestration/signal.ts +67 -0
  57. package/src/core/types/contentNavigationStrategy.ts +38 -0
  58. package/src/core/types/learningState.ts +77 -0
  59. package/src/core/types/types-legacy.ts +4 -0
  60. package/src/core/types/userOutcome.ts +51 -0
  61. package/src/courseConfigRegistration.ts +107 -0
  62. package/src/factory.ts +6 -0
  63. package/src/impl/common/BaseUserDB.ts +16 -0
  64. package/src/study/SessionController.ts +64 -1
  65. package/tests/core/navigators/Pipeline.test.ts +2 -0
  66. package/docs/todo-evolutionary-orchestration.md +0 -310
@@ -265,6 +265,113 @@ export function registerQuestionType(
265
265
  return true;
266
266
  }
267
267
 
268
+ /**
269
+ * Remove a data shape from the course config
270
+ * @returns true if the data shape was removed, false if it wasn't found
271
+ */
272
+ export function removeDataShape(
273
+ dataShapeName: string,
274
+ courseConfig: CourseConfig
275
+ ): boolean {
276
+ const index = courseConfig.dataShapes.findIndex((ds) => ds.name === dataShapeName);
277
+
278
+ if (index === -1) {
279
+ logger.info(`DataShape '${dataShapeName}' not found in course config`);
280
+ return false;
281
+ }
282
+
283
+ // Remove the data shape
284
+ courseConfig.dataShapes.splice(index, 1);
285
+
286
+ // Also remove references from any question types
287
+ courseConfig.questionTypes.forEach((qt) => {
288
+ const dsIndex = qt.dataShapeList.indexOf(dataShapeName);
289
+ if (dsIndex !== -1) {
290
+ qt.dataShapeList.splice(dsIndex, 1);
291
+ }
292
+ });
293
+
294
+ logger.info(`Removed DataShape: ${dataShapeName}`);
295
+ return true;
296
+ }
297
+
298
+ /**
299
+ * Remove a question type from the course config
300
+ * @returns true if the question type was removed, false if it wasn't found
301
+ */
302
+ export function removeQuestionType(
303
+ questionTypeName: string,
304
+ courseConfig: CourseConfig
305
+ ): boolean {
306
+ const index = courseConfig.questionTypes.findIndex((qt) => qt.name === questionTypeName);
307
+
308
+ if (index === -1) {
309
+ logger.info(`QuestionType '${questionTypeName}' not found in course config`);
310
+ return false;
311
+ }
312
+
313
+ // Remove the question type
314
+ courseConfig.questionTypes.splice(index, 1);
315
+
316
+ // Also remove references from data shapes
317
+ courseConfig.dataShapes.forEach((ds) => {
318
+ const qtIndex = ds.questionTypes.indexOf(questionTypeName);
319
+ if (qtIndex !== -1) {
320
+ ds.questionTypes.splice(qtIndex, 1);
321
+ }
322
+ });
323
+
324
+ logger.info(`Removed QuestionType: ${questionTypeName}`);
325
+ return true;
326
+ }
327
+
328
+ /**
329
+ * Remove data shapes and question types from course config and persist to database
330
+ */
331
+ export async function removeCustomQuestionTypes(
332
+ dataShapeNames: string[],
333
+ questionTypeNames: string[],
334
+ courseConfig: CourseConfig,
335
+ courseDB: CourseDBInterface
336
+ ): Promise<{ success: boolean; removedCount: number; errorMessage?: string }> {
337
+ try {
338
+ logger.info('Beginning custom question removal');
339
+ logger.info(`Removing ${dataShapeNames.length} data shapes and ${questionTypeNames.length} question types`);
340
+
341
+ let removedCount = 0;
342
+
343
+ // Remove question types first (they reference data shapes)
344
+ for (const qtName of questionTypeNames) {
345
+ if (removeQuestionType(qtName, courseConfig)) {
346
+ removedCount++;
347
+ }
348
+ }
349
+
350
+ // Then remove data shapes
351
+ for (const dsName of dataShapeNames) {
352
+ if (removeDataShape(dsName, courseConfig)) {
353
+ removedCount++;
354
+ }
355
+ }
356
+
357
+ // Update the course config in the database
358
+ logger.info('Updating course configuration...');
359
+ const updateResult = await courseDB.updateCourseConfig(courseConfig);
360
+
361
+ if (!updateResult.ok) {
362
+ throw new Error(`Failed to update course config: ${JSON.stringify(updateResult)}`);
363
+ }
364
+
365
+ logger.info(`Custom question removal complete: ${removedCount} items removed`);
366
+
367
+ return { success: true, removedCount };
368
+ } catch (error) {
369
+ const errorMessage = error instanceof Error ? error.message : String(error);
370
+ logger.error(`Custom question removal failed: ${errorMessage}`);
371
+ return { success: false, removedCount: 0, errorMessage };
372
+ }
373
+ }
374
+
268
375
  /**
269
376
  * Register seed data for a question type
270
377
  *
package/src/factory.ts CHANGED
@@ -4,6 +4,7 @@ import { DataLayerProvider } from './core/interfaces';
4
4
  import { BaseUser } from './impl/common';
5
5
  import { logger } from './util/logger';
6
6
  import { StaticCourseManifest } from './util/packer/types';
7
+ import { initializeNavigatorRegistry } from './core/navigators';
7
8
 
8
9
  const NOT_SET = 'NOT_SET' as const;
9
10
 
@@ -50,6 +51,11 @@ export async function initializeDataLayer(config: DataLayerConfig): Promise<Data
50
51
  logger.warn('Data layer already initialized. Returning existing instance.');
51
52
  return dataLayerInstance;
52
53
  }
54
+
55
+ // Initialize the navigator registry before creating the data layer.
56
+ // This ensures all built-in navigators are available for pipeline assembly.
57
+ await initializeNavigatorRegistry();
58
+
53
59
  if (config.options.localStoragePrefix) {
54
60
  ENV.LOCAL_STORAGE_PREFIX = config.options.localStoragePrefix;
55
61
  }
@@ -20,6 +20,7 @@ import {
20
20
  } from '@db/core/types/user';
21
21
  import { DocumentUpdater } from '@db/study';
22
22
  import { CardHistory, CardRecord } from '../../core/types/types-legacy';
23
+ import { UserOutcomeRecord } from '../../core/types/userOutcome';
23
24
  import type { SyncStrategy } from './SyncStrategy';
24
25
  import {
25
26
  filterAllDocsByPrefix,
@@ -1088,6 +1089,21 @@ Currently logged-in as ${this._username}.`
1088
1089
  await this.localDB.put(doc);
1089
1090
  }
1090
1091
 
1092
+ public async putUserOutcome(record: UserOutcomeRecord): Promise<void> {
1093
+ try {
1094
+ await this.localDB.put(record);
1095
+ } catch (err: any) {
1096
+ if (err.status === 409) {
1097
+ // Overwrite if exists
1098
+ const existing = await this.localDB.get(record._id);
1099
+ (record as any)._rev = existing._rev;
1100
+ await this.localDB.put(record);
1101
+ } else {
1102
+ throw err;
1103
+ }
1104
+ }
1105
+ }
1106
+
1091
1107
  public async deleteStrategyState(courseId: string, strategyKey: string): Promise<void> {
1092
1108
  const docId = buildStrategyStateId(courseId, strategyKey);
1093
1109
  try {
@@ -12,7 +12,8 @@ import {
12
12
  StudySessionReviewItem,
13
13
  } from '@db/impl/couch';
14
14
 
15
- import { CardRecord, CardHistory, CourseRegistrationDoc } from '@db/core';
15
+ import { CardRecord, CardHistory, CourseRegistrationDoc, QuestionRecord } from '@db/core';
16
+ import { recordUserOutcome } from '@db/core/orchestration/recording';
16
17
  import { Loggable } from '@db/util';
17
18
  import { getCardOrigin } from '@db/core/navigators';
18
19
  import { SourceMixer, QuotaRoundRobinMixer, SourceBatch } from './SourceMixer';
@@ -587,4 +588,66 @@ export class SessionController<TView = unknown> extends Loggable {
587
588
  this.failedQ.dequeue((queueItem) => queueItem.cardID);
588
589
  }
589
590
  }
591
+
592
+ /**
593
+ * End the session and record learning outcomes.
594
+ *
595
+ * This method aggregates all responses from the session and records a
596
+ * UserOutcomeRecord if evolutionary orchestration is enabled.
597
+ */
598
+ public async endSession(): Promise<void> {
599
+ if (!this._sessionRecord || this._sessionRecord.length === 0) {
600
+ return;
601
+ }
602
+
603
+ const questionRecords = this._sessionRecord
604
+ .flatMap((r) => r.records)
605
+ .filter((r): r is QuestionRecord => (r as any).userAnswer !== undefined);
606
+
607
+ if (questionRecords.length === 0) {
608
+ return;
609
+ }
610
+
611
+ // We need to access the orchestration context.
612
+ // Ideally this would be passed in or available via services.
613
+ // For now, we'll try to get it from one of the content sources if possible,
614
+ // or skip if we can't access it.
615
+
616
+ // Try to find a source that supports orchestration
617
+ let orchestrationContext = null;
618
+ const strategies: string[] = [];
619
+
620
+ for (const source of this.sources) {
621
+ if (source.getOrchestrationContext) {
622
+ try {
623
+ orchestrationContext = await source.getOrchestrationContext();
624
+ // Also try to get strategy IDs if available on the source (e.g. Pipeline)
625
+ if ((source as any).getStrategyIds) {
626
+ strategies.push(...(source as any).getStrategyIds());
627
+ }
628
+ } catch (e) {
629
+ logger.warn(`[SessionController] Failed to get orchestration context: ${e}`);
630
+ }
631
+ if (orchestrationContext) break;
632
+ }
633
+ }
634
+
635
+ if (!orchestrationContext) {
636
+ logger.debug('[SessionController] No orchestration context available, skipping outcome recording');
637
+ return;
638
+ }
639
+
640
+ // Use current time as period end
641
+ const periodEnd = new Date().toISOString();
642
+ // Use session start time as period start
643
+ const periodStart = new Date(this.startTime).toISOString();
644
+
645
+ await recordUserOutcome(
646
+ orchestrationContext,
647
+ periodStart,
648
+ periodEnd,
649
+ questionRecords,
650
+ strategies
651
+ );
652
+ }
590
653
  }
@@ -90,6 +90,7 @@ function createMockContext(): { user: UserDBInterface; course: CourseDBInterface
90
90
  getCourseRegDoc: vi.fn().mockResolvedValue({
91
91
  elo: { global: { score: 1000, count: 10 }, tags: {} },
92
92
  }),
93
+ getUsername: vi.fn().mockReturnValue('test-user'),
93
94
  } as unknown as UserDBInterface;
94
95
 
95
96
  const mockCourse = {
@@ -294,6 +295,7 @@ describe('Pipeline', () => {
294
295
 
295
296
  const failingUser = {
296
297
  getCourseRegDoc: vi.fn().mockRejectedValue(new Error('Not registered')),
298
+ getUsername: vi.fn().mockReturnValue('failing-user'),
297
299
  } as unknown as UserDBInterface;
298
300
 
299
301
  let capturedElo = 0;
@@ -1,310 +0,0 @@
1
- # TODO: Evolutionary Orchestration Vision
2
-
3
- ## Status: FOUNDATIONAL WORK COMPLETE, ORCHESTRATION NOT STARTED
4
-
5
- > **Prerequisite:** `packages/db/docs/todo-naive-orchestration.md` — Pipeline assembly must be
6
- > working before evolutionary selection can be layered on top. This document describes the
7
- > "grander vision"; naive orchestration is the foundation.
8
-
9
- This document tracks progress toward the "grander vision" of dynamic orchestration with
10
- evolutionary pressures, as outlined in `u.3.strategic-nuggets.md`.
11
-
12
- ## The Vision (Summary)
13
-
14
- A self-improving courseware system where:
15
-
16
- 1. **N strategies exist** — Each a hypothesis about effective content sequencing
17
- 2. **M users exist** — Each with learning goals and measurable outcomes
18
- 3. **Multi-arm bandit selection** — Strategies are applied based on confidence in their utility
19
- 4. **Evolutionary pressure** — Effective strategies propagate, ineffective ones decay
20
- 5. **Self-healing content** — System identifies barriers and incentivizes remediation
21
-
22
- ---
23
-
24
- ## Progress Assessment
25
-
26
- ### ✅ COMPLETE: Strategy Infrastructure
27
-
28
- | Component | Status | Notes |
29
- |-----------|--------|-------|
30
- | `WeightedCard` API | ✅ Done | Unified scored candidate model |
31
- | `ContentNavigator` base class | ✅ Done | Extensible strategy framework |
32
- | Delegate pattern composition | ✅ Done | Strategies can wrap/chain |
33
- | `HierarchyDefinition` strategy | ✅ Done | Prerequisite gating |
34
- | `InterferenceMitigator` strategy | ✅ Done | Confusable concept separation |
35
- | `RelativePriority` strategy | ✅ Done | Utility-based content ordering |
36
- | `SessionController` integration | ✅ Done | `getWeightedCards()` is live |
37
- | Pipeline assembly | ❌ Not done | See `todo-naive-orchestration.md` |
38
-
39
- **What this enables:**
40
- - Multiple strategies can coexist and be configured per-course
41
- - Strategies return graded suitability scores (0-1), not just binary include/exclude
42
- - Composition allows layering strategies: `Priority(Interference(Hierarchy(ELO)))`
43
-
44
- **What's missing for basic operation:**
45
- - No pipeline configuration in CourseConfig (`navigationPipeline` field)
46
- - No assembly logic to chain configured strategies
47
- - Currently falls back to hard-coded ELO navigator
48
-
49
- ---
50
-
51
- ### 🟡 PARTIAL: Strategy State & Context
52
-
53
- | Component | Status | Notes |
54
- |-----------|--------|-------|
55
- | Read user ELO (global + per-tag) | ✅ Done | Via `CourseRegistration.elo` |
56
- | Read user history | ✅ Done | `getSeenCards()`, `getPendingReviews()` |
57
- | Write strategy-specific state | ❌ Not done | See `todo-strategy-state-storage.md` |
58
- | Temporal tracking | ❌ Not done | "When was tag X last introduced?" |
59
-
60
- **Gap for evolutionary vision:**
61
- - Strategies cannot yet persist their own learning/state
62
- - No mechanism for tracking strategy effectiveness over time
63
-
64
- ---
65
-
66
- ### ❌ NOT STARTED: Multi-Arm Bandit Selection
67
-
68
- The core orchestration logic described in the vision:
69
-
70
- ```
71
- each of N strategies divides into cohorts via some hashId collision metric
72
- eg: h(strategyHash + slowRotationSalt) xor userHash
73
- if resultant Ones are < utilityConfidence percent of total bits,
74
- then include the strategy for the user
75
- ```
76
-
77
- **What's needed:**
78
-
79
- 1. **Strategy Registry** — Central list of available strategies with metadata
80
- 2. **Utility Confidence** — Per-strategy confidence score (0-1)
81
- 3. **Cohort Assignment** — Deterministic but rotatable user-to-strategy mapping
82
- 4. **Salt Rotation** — Periodic rotation to prevent user lock-in
83
- 5. **Outcome Measurement** — Track goal achievement per cohort
84
-
85
- **Proposed architecture:**
86
-
87
- ```typescript
88
- interface StrategyRegistryEntry {
89
- strategyId: string;
90
- strategyType: string;
91
- config: unknown;
92
-
93
- // Evolutionary metadata
94
- utilityConfidence: number; // 0-1, probability of usefulness
95
- createdAt: string;
96
- lastMeasuredAt: string;
97
- cohortSalt: string; // Rotated periodically
98
-
99
- // Outcome tracking
100
- metrics: {
101
- usersExposed: number;
102
- goalAchievementRate: number;
103
- engagementScore: number;
104
- progressRate: number;
105
- };
106
- }
107
-
108
- interface Orchestrator {
109
- // Determine which strategies apply to this user for this session
110
- selectStrategies(userId: string, courseId: string): Promise<StrategyRegistryEntry[]>;
111
-
112
- // Record outcome for evolutionary learning
113
- recordOutcome(userId: string, strategyIds: string[], outcome: Outcome): Promise<void>;
114
-
115
- // Rotate cohort assignments
116
- rotateSalt(): Promise<void>;
117
-
118
- // Prune ineffective strategies
119
- pruneStrategies(minConfidence: number): Promise<void>;
120
- }
121
- ```
122
-
123
- ---
124
-
125
- ### ❌ NOT STARTED: Parameterizable / Programmable Strategies
126
-
127
- The vision describes:
128
-
129
- ```
130
- would like to extend into parameterizable / programmable strategies.
131
- eg, should be able to specify deps like:
132
- `grade-{n}` & `geometry` -> `grade-{n+1}` & `geometry`
133
- ```
134
-
135
- **What's needed:**
136
-
137
- 1. **Template syntax** — Pattern matching for tag relationships
138
- 2. **Variable binding** — Extract and apply variables in prerequisite rules
139
- 3. **Rule engine** — Evaluate parameterized rules against user state
140
-
141
- **Example:**
142
- ```typescript
143
- interface ParameterizedPrerequisite {
144
- pattern: "grade-{n} & {subject}";
145
- implies: "grade-{n+1} & {subject}";
146
- constraints: {
147
- n: { type: "number", min: 1, max: 12 },
148
- subject: { type: "tag-category", category: "academic-subject" }
149
- };
150
- }
151
- ```
152
-
153
- ---
154
-
155
- ### ❌ NOT STARTED: Self-Healing Content
156
-
157
- The meta-consideration from the vision:
158
-
159
- ```
160
- - identifying learning 'barriers' where substantive portion of cohort gets stuck or abandons
161
- - surfacing that info in a useful way
162
- - author aims to diagnose and remedy by providing intermediate content
163
- ```
164
-
165
- **What's needed:**
166
-
167
- 1. **Barrier Detection** — Identify cards/tags where many users get stuck
168
- 2. **Cohort Analysis** — Compare progress across strategy cohorts
169
- 3. **Alert System** — Surface barriers to authors
170
- 4. **Intervention Hooks** — Enable targeted content insertion
171
- 5. **Feedback Loop** — Measure intervention effectiveness
172
-
173
- **Signals for barrier detection:**
174
- - High failure rate on specific cards
175
- - Long dwell time before mastery
176
- - Drop-off (users abandon course at specific points)
177
- - ELO stagnation on specific tags
178
-
179
- ---
180
-
181
- ## Roadmap to Full Vision
182
-
183
- ### Phase A: Foundation (COMPLETE ✅)
184
-
185
- - [x] WeightedCard API
186
- - [x] ContentNavigator framework
187
- - [x] Core strategies (Hierarchy, Interference, RelativePriority)
188
- - [x] SessionController integration
189
-
190
- ### Phase B: Strategy Ecosystem (IN PROGRESS 🟡)
191
-
192
- - [ ] SRS as ContentNavigator (`todo-srs-navigator.md`)
193
- - [ ] Strategy authoring tools (`todo-strategy-authoring.md`)
194
- - [ ] Strategy state storage (`todo-strategy-state-storage.md`)
195
- - [ ] Provenance/audit trail (`todo-provenance.md`)
196
-
197
- ### Phase C: Measurement Infrastructure (NOT STARTED)
198
-
199
- - [ ] Define "learning outcome" metrics
200
- - [ ] Instrument strategy usage per user
201
- - [ ] Track outcome-to-strategy correlation
202
- - [ ] Build cohort comparison views
203
-
204
- ### Phase D: Multi-Arm Bandit Orchestrator (NOT STARTED)
205
-
206
- - [ ] Strategy registry with utility confidence
207
- - [ ] Cohort assignment algorithm
208
- - [ ] Salt rotation mechanism
209
- - [ ] Confidence update rules (Bayesian or frequentist)
210
- - [ ] Orchestrator integration with SessionController
211
-
212
- ### Phase E: Evolutionary Pressure (NOT STARTED)
213
-
214
- - [ ] Strategy creation incentives
215
- - [ ] Automatic strategy pruning
216
- - [ ] Strategy mutation/variation generation
217
- - [ ] A/B testing framework
218
-
219
- ### Phase F: Self-Healing (NOT STARTED)
220
-
221
- - [ ] Barrier detection pipeline
222
- - [ ] Author alerting system
223
- - [ ] Intervention recommendation engine
224
- - [ ] Content gap analysis
225
-
226
- ### Phase G: Programmable Strategies (NOT STARTED)
227
-
228
- - [ ] Template syntax design
229
- - [ ] Rule engine implementation
230
- - [ ] Variable binding in prerequisites
231
- - [ ] Cross-course strategy generalization
232
-
233
- ---
234
-
235
- ## Key Design Decisions Ahead
236
-
237
- ### 1. Centralized vs Decentralized Orchestration
238
-
239
- **Option A: Central Orchestrator Service**
240
- - Single service decides strategy application
241
- - Cleaner cohort tracking
242
- - Requires backend infrastructure
243
-
244
- **Option B: Client-Side Orchestration**
245
- - Each client computes its own strategy set
246
- - Works offline
247
- - Harder to track cohorts
248
-
249
- **Recommendation:** Hybrid — client computes from synced registry, outcomes reported to backend.
250
-
251
- ### 2. Confidence Update Mechanism
252
-
253
- **Option A: Frequentist (Simple)**
254
- - Track success/failure counts
255
- - Confidence = success_rate with smoothing
256
- - Easy to implement
257
-
258
- **Option B: Bayesian (Principled)**
259
- - Prior belief + observed evidence
260
- - Thompson sampling for exploration/exploitation
261
- - More complex but theoretically sound
262
-
263
- **Recommendation:** Start with frequentist, migrate to Bayesian if needed.
264
-
265
- ### 3. Strategy Granularity
266
-
267
- **Question:** What counts as "a strategy" for evolutionary purposes?
268
-
269
- - A specific `HierarchyDefinition` config? (Fine-grained)
270
- - The `HierarchyDefinition` approach in general? (Coarse-grained)
271
- - A specific prerequisite rule within a hierarchy? (Very fine-grained)
272
-
273
- **Recommendation:** Start coarse (strategy type + major config), add granularity as measurement matures.
274
-
275
- ### 4. Outcome Attribution
276
-
277
- **Question:** If a user is exposed to multiple strategies, how do we attribute outcomes?
278
-
279
- - All strategies get credit/blame equally?
280
- - Weight by score contribution?
281
- - Require isolated A/B cells?
282
-
283
- **Recommendation:** Start with equal attribution, instrument for isolated testing later.
284
-
285
- ---
286
-
287
- ## Related Documents
288
-
289
- - `u.3.strategic-nuggets.md` — Original vision statement
290
- - `todo-srs-navigator.md` — SRS migration
291
- - `todo-strategy-authoring.md` — Authoring tools
292
- - `todo-strategy-state-storage.md` — State persistence
293
- - `todo-provenance.md` — Audit trail for transparency
294
- - `a.2.plan.md` — Detailed implementation plan
295
- - `a.3.todo.md` — Task tracking
296
- - `packages/db/docs/navigators-architecture.md` — Technical architecture
297
-
298
- ---
299
-
300
- ## Summary
301
-
302
- **Where we are:** Solid foundation. Strategies exist, compose, return scores, and are integrated
303
- with SessionController. The infrastructure supports the vision.
304
-
305
- **What's next:** Build the measurement and orchestration layers. The strategies can now *exist*;
306
- we need to make them *compete* and *evolve*.
307
-
308
- **The gap:** The evolutionary pressure mechanisms (multi-arm bandit selection, outcome measurement,
309
- confidence updates, self-healing) are not yet implemented. This is where the "magic" of the
310
- vision lives, and it's entirely ahead of us.