@vue-skuilder/db 0.1.17 → 0.1.20

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 (92) hide show
  1. package/dist/{userDB-BqwxtJ_7.d.mts → classroomDB-CZdMBiTU.d.ts} +427 -104
  2. package/dist/{userDB-DNa0XPtn.d.ts → classroomDB-PxDZTky3.d.cts} +427 -104
  3. package/dist/core/index.d.cts +304 -0
  4. package/dist/core/index.d.ts +237 -25
  5. package/dist/core/index.js +2246 -118
  6. package/dist/core/index.js.map +1 -1
  7. package/dist/core/index.mjs +2235 -114
  8. package/dist/core/index.mjs.map +1 -1
  9. package/dist/{dataLayerProvider-VlngD19_.d.mts → dataLayerProvider-D0MoZMjH.d.cts} +1 -1
  10. package/dist/{dataLayerProvider-BV5iZqt_.d.ts → dataLayerProvider-D8o6ZnKW.d.ts} +1 -1
  11. package/dist/impl/couch/{index.d.mts → index.d.cts} +47 -5
  12. package/dist/impl/couch/index.d.ts +46 -4
  13. package/dist/impl/couch/index.js +2250 -134
  14. package/dist/impl/couch/index.js.map +1 -1
  15. package/dist/impl/couch/index.mjs +2212 -97
  16. package/dist/impl/couch/index.mjs.map +1 -1
  17. package/dist/impl/static/{index.d.mts → index.d.cts} +6 -6
  18. package/dist/impl/static/index.d.ts +5 -5
  19. package/dist/impl/static/index.js +1950 -143
  20. package/dist/impl/static/index.js.map +1 -1
  21. package/dist/impl/static/index.mjs +1922 -117
  22. package/dist/impl/static/index.mjs.map +1 -1
  23. package/dist/{index-Bmll7Xse.d.mts → index-B_j6u5E4.d.cts} +1 -1
  24. package/dist/{index-CD8BZz2k.d.ts → index-Dj0SEgk3.d.ts} +1 -1
  25. package/dist/{index.d.mts → index.d.cts} +97 -13
  26. package/dist/index.d.ts +96 -12
  27. package/dist/index.js +2439 -180
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +2386 -135
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/pouch/index.js +3 -3
  32. package/dist/{types-Dbp5DaRR.d.mts → types-Bn0itutr.d.cts} +1 -1
  33. package/dist/{types-CewsN87z.d.ts → types-DQaXnuoc.d.ts} +1 -1
  34. package/dist/{types-legacy-6ettoclI.d.ts → types-legacy-DDY4N-Uq.d.cts} +3 -1
  35. package/dist/{types-legacy-6ettoclI.d.mts → types-legacy-DDY4N-Uq.d.ts} +3 -1
  36. package/dist/util/packer/{index.d.mts → index.d.cts} +3 -3
  37. package/dist/util/packer/index.d.ts +3 -3
  38. package/dist/util/packer/index.js.map +1 -1
  39. package/dist/util/packer/index.mjs.map +1 -1
  40. package/docs/brainstorm-navigation-paradigm.md +369 -0
  41. package/docs/navigators-architecture.md +370 -0
  42. package/docs/todo-evolutionary-orchestration.md +310 -0
  43. package/docs/todo-nominal-tag-types.md +121 -0
  44. package/docs/todo-strategy-authoring.md +401 -0
  45. package/eslint.config.mjs +1 -1
  46. package/package.json +9 -4
  47. package/src/core/index.ts +1 -0
  48. package/src/core/interfaces/contentSource.ts +88 -4
  49. package/src/core/interfaces/courseDB.ts +13 -0
  50. package/src/core/interfaces/navigationStrategyManager.ts +0 -5
  51. package/src/core/interfaces/userDB.ts +32 -0
  52. package/src/core/navigators/CompositeGenerator.ts +268 -0
  53. package/src/core/navigators/Pipeline.ts +318 -0
  54. package/src/core/navigators/PipelineAssembler.ts +194 -0
  55. package/src/core/navigators/elo.ts +104 -15
  56. package/src/core/navigators/filters/eloDistance.ts +132 -0
  57. package/src/core/navigators/filters/index.ts +9 -0
  58. package/src/core/navigators/filters/types.ts +115 -0
  59. package/src/core/navigators/filters/userTagPreference.ts +232 -0
  60. package/src/core/navigators/generators/index.ts +2 -0
  61. package/src/core/navigators/generators/types.ts +107 -0
  62. package/src/core/navigators/hardcodedOrder.ts +111 -12
  63. package/src/core/navigators/hierarchyDefinition.ts +266 -0
  64. package/src/core/navigators/index.ts +404 -3
  65. package/src/core/navigators/inferredPreference.ts +107 -0
  66. package/src/core/navigators/interferenceMitigator.ts +355 -0
  67. package/src/core/navigators/relativePriority.ts +255 -0
  68. package/src/core/navigators/srs.ts +195 -0
  69. package/src/core/navigators/userGoal.ts +136 -0
  70. package/src/core/types/strategyState.ts +84 -0
  71. package/src/core/types/types-legacy.ts +2 -0
  72. package/src/impl/common/BaseUserDB.ts +74 -7
  73. package/src/impl/couch/adminDB.ts +1 -2
  74. package/src/impl/couch/classroomDB.ts +51 -0
  75. package/src/impl/couch/courseDB.ts +147 -49
  76. package/src/impl/static/courseDB.ts +11 -4
  77. package/src/study/SessionController.ts +149 -1
  78. package/src/study/TagFilteredContentSource.ts +255 -0
  79. package/src/study/index.ts +1 -0
  80. package/src/util/dataDirectory.test.ts +51 -22
  81. package/src/util/logger.ts +0 -1
  82. package/tests/core/navigators/CompositeGenerator.test.ts +455 -0
  83. package/tests/core/navigators/Pipeline.test.ts +406 -0
  84. package/tests/core/navigators/PipelineAssembler.test.ts +351 -0
  85. package/tests/core/navigators/SRSNavigator.test.ts +344 -0
  86. package/tests/core/navigators/eloDistanceFilter.test.ts +192 -0
  87. package/tests/core/navigators/navigators.test.ts +710 -0
  88. package/tsconfig.json +1 -1
  89. package/vitest.config.ts +29 -0
  90. package/dist/core/index.d.mts +0 -92
  91. /package/dist/{SyncStrategy-CyATpyLQ.d.mts → SyncStrategy-CyATpyLQ.d.cts} +0 -0
  92. /package/dist/pouch/{index.d.mts → index.d.cts} +0 -0
@@ -0,0 +1,369 @@
1
+ # Brainstorm: Navigation Paradigm Exploration
2
+
3
+ > **Status:** Informal brainstorming. Not a design doc or TODO.
4
+
5
+ This document explores the navigation strategy paradigm: what other strategy types
6
+ might exist, where the current design shines or struggles, and what alternative
7
+ approaches could achieve similar aims.
8
+
9
+ ---
10
+
11
+ ## Potential Strategy Classes
12
+
13
+ ### Generators (Candidate Sources)
14
+
15
+ These produce candidate cards, typically with initial scores.
16
+
17
+ | Strategy | Description | Trigger/Source |
18
+ |----------|-------------|----------------|
19
+ | **ELO** (exists) | Skill-proximity matching | Always active, scores by distance |
20
+ | **SRS** (planned) | Spaced repetition scheduling | Time-based, scores by overdueness |
21
+ | **HardcodedOrder** (exists) | Fixed sequence | Index position |
22
+ | **TriggerResponse** | Activated by specific events | See below |
23
+ | **RecentFailures** | Re-surfaces cards with recent errors | Performance signal |
24
+ | **Adaptive Drill** | Intensive repetition on weak spots | Threshold-triggered |
25
+ | **Random** | Uniform random selection | Always active (baseline) |
26
+ | **CurriculumSequence** | Author-defined learning path | Progress gates |
27
+ | **SocialSignal** | Cards others struggled with | Cohort data |
28
+
29
+ ### Filters (Score Transformers)
30
+
31
+ These modify scores from upstream candidates.
32
+
33
+ | Strategy | Description | Effect |
34
+ |----------|-------------|--------|
35
+ | **HierarchyDefinition** (exists) | Prerequisite gating | Hard filter (score=0) |
36
+ | **InterferenceMitigator** (exists) | Confusable concept separation | Soft penalty |
37
+ | **RelativePriority** (exists) | Utility-based boosting | Soft boost |
38
+ | **TimeSinceTag** | Recency of tag exposure | Soft penalty/boost |
39
+ | **SessionCoherence** | Thematic consistency within session | Soft boost for related |
40
+ | **FatigueAdjuster** | Reduce difficulty as session progresses | Soft penalty for hard cards late |
41
+ | **UserPreference** | User-stated preferences/interests | Soft boost |
42
+ | **Novelty** | Freshness vs. review balance | Score adjustment |
43
+
44
+ ### Trigger-Response Generators (Your Interest)
45
+
46
+ These are **event-driven generators** that activate under specific conditions:
47
+
48
+ #### Intensive Response Intervention
49
+
50
+ ```
51
+ Trigger: User fails card C with tag T at mastery level M
52
+ AND failure count on T exceeds threshold in window
53
+
54
+ Response: Generator activates
55
+ - Surfaces remedial content for tag T
56
+ - May include prerequisite tags
57
+ - Runs for N cards or until success threshold
58
+
59
+ Exit: Deactivates when recovery criteria met
60
+ ```
61
+
62
+ #### Other Trigger Scenarios
63
+
64
+ | Trigger | Response |
65
+ |---------|----------|
66
+ | **Frustration signal** (N failures in M minutes) | Shift to easier content, motivational material |
67
+ | **Plateau detection** (no ELO movement for K sessions) | Surface challenging content, introduce new tags |
68
+ | **Mastery celebration** (tag mastery achieved) | Capstone card, related advanced content |
69
+ | **Inactivity return** (first session after gap) | Review-heavy, confidence rebuilding |
70
+ | **Learning velocity drop** | Adjust presentation cadence, check interference |
71
+ | **Specific error pattern** (e.g., always confuses X and Y) | Targeted contrast exercises |
72
+
73
+ #### Implementation Considerations
74
+
75
+ Trigger-response generators need:
76
+ 1. **Event bus / signal mechanism** — How do strategies observe events?
77
+ 2. **Activation state** — How to track "I am currently intervening on tag T"?
78
+ 3. **Priority over base generator** — When active, should it preempt or blend?
79
+ 4. **Exit criteria** — When does intervention end?
80
+
81
+ This argues for strategies having **lifecycle state**, not just stateless scoring.
82
+ See `todo-strategy-state-storage.md` for related concerns.
83
+
84
+ ---
85
+
86
+ ## Hybrid Generators
87
+
88
+ Some strategies might combine generation and filtering:
89
+
90
+ | Strategy | Behavior |
91
+ |----------|----------|
92
+ | **Contextual ELO** | ELO generator that adjusts target based on session state |
93
+ | **Pacing Controller** | Generates from pool but enforces cadence rules |
94
+ | **Multi-Objective** | Balances multiple generators (ELO + SRS + Priority) |
95
+
96
+ ---
97
+
98
+ ## Strengths of Current Paradigm
99
+
100
+ ### 1. Composability via Delegation
101
+
102
+ The delegate pattern is genuinely elegant:
103
+ ```
104
+ Priority(Interference(Hierarchy(ELO)))
105
+ ```
106
+
107
+ Each layer does one thing. Easy to reason about, test, and swap components.
108
+
109
+ ### 2. Unified Score Semantics
110
+
111
+ Everything speaks `WeightedCard`. Scores compose multiplicatively. A hard filter
112
+ (score=0) works at any layer. Soft preferences blend naturally.
113
+
114
+ ### 3. Separation of Concerns
115
+
116
+ - **Generators** know about card selection
117
+ - **Filters** know about constraints/preferences
118
+ - **SessionController** knows about time/queue management
119
+ - **No cross-cutting entanglement**
120
+
121
+ ### 4. Backward Compatibility
122
+
123
+ Legacy `getNewCards()` / `getPendingReviews()` still work. Migration is incremental.
124
+
125
+ ### 5. Extensibility
126
+
127
+ New strategies plug in via `ContentNavigator.create()` dynamic loading. No central
128
+ registry modification required.
129
+
130
+ ---
131
+
132
+ ## Weaknesses of Current Paradigm
133
+
134
+ ### 1. Stateless by Default
135
+
136
+ Strategies are instantiated per-request. No persistence of:
137
+ - "I am currently running an intervention"
138
+ - "Last time I surfaced tag X was..."
139
+ - "This user responds well to strategy Y"
140
+
141
+ **Mitigation:** `todo-strategy-state-storage.md` (not implemented)
142
+
143
+ ### 2. Pull-Only Model
144
+
145
+ Strategies are invoked via `getWeightedCards()`. They can't:
146
+ - React to events (card failure, session end)
147
+ - Proactively signal "I have urgent candidates"
148
+ - Coordinate across sessions
149
+
150
+ **Mitigation:** Would need event subscription / push mechanism
151
+
152
+ ### 3. Limited Context Passing
153
+
154
+ Strategies receive `user`, `course`, `strategyData`. They don't receive:
155
+ - Current session state (cards seen, failures)
156
+ - Temporal context (time of day, day of week)
157
+ - User's explicit goals for this session
158
+
159
+ **Mitigation:** Expand context object passed to strategies
160
+
161
+ ### 4. No Inter-Strategy Communication
162
+
163
+ Strategies can't:
164
+ - "I'm handling this, others back off"
165
+ - Share computed data (e.g., interference detection useful to multiple)
166
+ - Negotiate priority
167
+
168
+ **Mitigation:** Shared context / blackboard pattern
169
+
170
+ ### 5. Pipeline Assembly Gap
171
+
172
+ (Addressed in `todo-naive-orchestration.md`)
173
+
174
+ The delegate pattern exists but isn't wired up. Each filter creates its own
175
+ delegate internally based on `serializedData`. No central orchestration.
176
+
177
+ ### 6. Linear Pipeline Limitations
178
+
179
+ Current model is strictly linear: `A(B(C(D)))`. Some scenarios want:
180
+ - Parallel generators merged: `merge(ELO, SRS)`
181
+ - Conditional branches: `if frustrated then X else Y`
182
+ - Dynamic reconfiguration mid-session
183
+
184
+ ---
185
+
186
+ ## Alternative Mechanisms
187
+
188
+ ### 1. Blackboard Architecture
189
+
190
+ Instead of a linear pipeline, strategies write to a shared "blackboard":
191
+
192
+ ```
193
+ Blackboard {
194
+ candidates: WeightedCard[]
195
+ signals: { frustration: 0.3, velocity: 0.8, ... }
196
+ interventions: { activeTag: 'vowel-sounds', since: ... }
197
+ vetoes: Set<cardId>
198
+ }
199
+
200
+ Strategies read/write blackboard in phases:
201
+ 1. Generators add candidates
202
+ 2. Observers add signals
203
+ 3. Filters modify scores
204
+ 4. Interventions override/inject
205
+ 5. Final selection
206
+ ```
207
+
208
+ **Pros:** Richer coordination, event-driven capable
209
+ **Cons:** More complex, harder to reason about, ordering sensitive
210
+
211
+ ### 2. Reactive / Event-Driven
212
+
213
+ Replace pull model with event streams:
214
+
215
+ ```typescript
216
+ interface NavigationEventSource {
217
+ onCardResult(result: CardResult): void;
218
+ onSessionStart(session: SessionContext): void;
219
+ onSessionEnd(stats: SessionStats): void;
220
+ }
221
+
222
+ interface ReactiveCandidateSource {
223
+ candidates$: Observable<WeightedCard[]>;
224
+ priority$: Observable<number>;
225
+ }
226
+ ```
227
+
228
+ Strategies subscribe to events and emit candidates when they have something urgent.
229
+
230
+ **Pros:** Natural for trigger-response patterns
231
+ **Cons:** Complexity, backpressure, ordering
232
+
233
+ ### 3. Rule Engine
234
+
235
+ Declarative rules instead of imperative strategies:
236
+
237
+ ```yaml
238
+ rules:
239
+ - name: interference-cooldown
240
+ when:
241
+ - card.tags intersects session.recentTags
242
+ - tag.maturity < threshold
243
+ then:
244
+ - score *= 0.5
245
+
246
+ - name: frustration-intervention
247
+ when:
248
+ - session.failureRate > 0.4
249
+ - session.consecutiveFailures >= 3
250
+ then:
251
+ - activate: remedial-generator
252
+ - target: session.lastFailedTag
253
+ ```
254
+
255
+ **Pros:** Declarative, inspectable, author-configurable
256
+ **Cons:** Limited expressiveness, new DSL to maintain
257
+
258
+ ### 4. Bandit Selection (Planned)
259
+
260
+ Instead of a fixed pipeline, select among N candidate pipelines:
261
+
262
+ ```
263
+ PipelineA: ELO
264
+ PipelineB: Hierarchy(ELO)
265
+ PipelineC: Interference(Hierarchy(ELO))
266
+
267
+ Orchestrator selects pipeline per-session based on:
268
+ - User cohort
269
+ - Historical effectiveness
270
+ - Exploration/exploitation balance
271
+ ```
272
+
273
+ **Pros:** Learns what works, self-improving
274
+ **Cons:** Requires outcome measurement, cold-start problem
275
+
276
+ See `todo-evolutionary-orchestration.md`.
277
+
278
+ ### 5. LLM-Guided Selection
279
+
280
+ Use a language model to interpret learner state and select content:
281
+
282
+ ```
283
+ Given:
284
+ - User profile: { elo: 950, strugglingWith: ['vowel-sounds'], ... }
285
+ - Session context: { duration: 12min, cardsSeen: 8, recentFailures: 2 }
286
+ - Available cards: [...]
287
+
288
+ Select the next 5 cards and explain reasoning.
289
+ ```
290
+
291
+ **Pros:** Flexible, can incorporate nuance
292
+ **Cons:** Latency, cost, unpredictability, hard to debug
293
+
294
+ ### 6. Constraint Satisfaction
295
+
296
+ Frame card selection as constraint satisfaction:
297
+
298
+ ```
299
+ Constraints:
300
+ - At most 3 new tags per session
301
+ - No more than 2 cards from same tag consecutively
302
+ - Prerequisite tags must be mastered
303
+ - Session should have 60% review, 40% new
304
+
305
+ Objective: Maximize expected learning gain
306
+ ```
307
+
308
+ Solver finds valid card sequence.
309
+
310
+ **Pros:** Principled, globally optimal
311
+ **Cons:** Computational cost, hard to specify constraints
312
+
313
+ ---
314
+
315
+ ## Recommendation: Incremental Extension
316
+
317
+ Rather than wholesale paradigm shift, extend current model:
318
+
319
+ ### Near-term (compatible with naive orchestration)
320
+
321
+ 1. **Richer context** — Pass session state to strategies
322
+ 2. **Trigger-response generator** — New generator type with activation state
323
+ 3. **Session-scoped state** — Allow strategies to persist within-session
324
+
325
+ ### Medium-term (with strategy state storage)
326
+
327
+ 4. **Cross-session state** — Strategies remember past sessions
328
+ 5. **Event hooks** — Strategies can subscribe to card results
329
+ 6. **Intervention protocol** — Active intervention preempts normal generation
330
+
331
+ ### Long-term (with evolutionary orchestration)
332
+
333
+ 7. **Bandit selection** among pipelines
334
+ 8. **Outcome measurement** for strategy effectiveness
335
+ 9. **Hybrid architectures** where blackboard/reactive patterns augment pipeline
336
+
337
+ ---
338
+
339
+ ## Questions to Explore
340
+
341
+ 1. **What's the API for trigger-response generators?**
342
+ - `shouldActivate(sessionState): boolean`?
343
+ - `getInterventionCandidates(): WeightedCard[]`?
344
+ - How to represent "I am currently intervening"?
345
+
346
+ 2. **How do strategies share expensive computations?**
347
+ - E.g., tag lookups (addressed in `todo-pipeline-optimization.md`)
348
+ - E.g., user mastery state
349
+ - Shared context object? Memoization layer?
350
+
351
+ 3. **What events should be observable?**
352
+ - Card shown, card answered (correct/incorrect), session start/end
353
+ - ELO change, tag mastery change
354
+ - User-initiated actions (skip, flag, etc.)
355
+
356
+ 4. **How much state is too much?**
357
+ - Stateless is simple but limited
358
+ - Full state enables sophisticated behavior but complexity cost
359
+ - Right level of state for different strategy types?
360
+
361
+ ---
362
+
363
+ ## Related Documents
364
+
365
+ - `navigators-architecture.md` — Current architecture
366
+ - `todo-naive-orchestration.md` — Pipeline assembly (prerequisite)
367
+ - `todo-strategy-state-storage.md` — State persistence
368
+ - `todo-evolutionary-orchestration.md` — Bandit selection vision
369
+ - `todo-provenance.md` — Audit trail (transparency)