@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
@@ -1,6 +1,6 @@
1
- import { CourseConfig, ClassroomConfig, CourseElo, Status, SkuilderCourseData as SkuilderCourseData$1, DataShape } from '@vue-skuilder/common';
1
+ import { CourseConfig, ClassroomConfig, CourseElo, Status, SkuilderCourseData as SkuilderCourseData$1, DataShape, TagFilter } from '@vue-skuilder/common';
2
2
  import { Moment } from 'moment';
3
- import { S as SkuilderCourseData, b as DocTypePrefixes, D as DocType, Q as QualifiedCardID, T as TagStub, a as Tag, C as CardHistory, c as CardRecord } from './types-legacy-6ettoclI.mjs';
3
+ import { S as SkuilderCourseData, b as DocTypePrefixes, D as DocType, Q as QualifiedCardID, T as TagStub, a as Tag, C as CardHistory, c as CardRecord } from './types-legacy-DDY4N-Uq.js';
4
4
 
5
5
  /**
6
6
  * Admin functionality
@@ -104,103 +104,6 @@ interface ScheduledCard {
104
104
  schedulingAgentId: string;
105
105
  }
106
106
 
107
- type StudySessionFailedItem = StudySessionFailedNewItem | StudySessionFailedReviewItem;
108
- interface StudySessionFailedNewItem extends StudySessionItem {
109
- status: 'failed-new';
110
- }
111
- interface StudySessionFailedReviewItem extends StudySessionReviewItem {
112
- status: 'failed-review';
113
- }
114
- interface StudySessionNewItem extends StudySessionItem {
115
- status: 'new';
116
- }
117
- interface StudySessionReviewItem extends StudySessionItem {
118
- reviewID: string;
119
- status: 'review' | 'failed-review';
120
- }
121
- declare function isReview(item: StudySessionItem): item is StudySessionReviewItem;
122
- interface StudySessionItem {
123
- status: 'new' | 'review' | 'failed-new' | 'failed-review';
124
- contentSourceType: 'course' | 'classroom';
125
- contentSourceID: string;
126
- cardID: string;
127
- courseID: string;
128
- elo?: number;
129
- }
130
- interface ContentSourceID {
131
- type: 'course' | 'classroom';
132
- id: string;
133
- }
134
- interface StudyContentSource {
135
- getPendingReviews(): Promise<(StudySessionReviewItem & ScheduledCard)[]>;
136
- getNewCards(n?: number): Promise<StudySessionNewItem[]>;
137
- }
138
- declare function getStudySource(source: ContentSourceID, user: UserDBInterface): Promise<StudyContentSource>;
139
-
140
- /**
141
- * Classroom management
142
- */
143
- interface ClassroomDBInterface {
144
- /**
145
- * Get classroom config
146
- */
147
- getConfig(): ClassroomConfig;
148
- /**
149
- * Get assigned content
150
- */
151
- getAssignedContent(): Promise<AssignedContent[]>;
152
- }
153
- interface TeacherClassroomDBInterface extends ClassroomDBInterface {
154
- /**
155
- * For teacher interfaces: assign content
156
- */
157
- assignContent?(content: AssignedContent): Promise<boolean>;
158
- /**
159
- * For teacher interfaces: remove content
160
- */
161
- removeContent?(content: AssignedContent): Promise<void>;
162
- }
163
- interface StudentClassroomDBInterface extends ClassroomDBInterface {
164
- /**
165
- * For student interfaces: get pending reviews
166
- */
167
- getPendingReviews?(): Promise<(StudySessionReviewItem & ScheduledCard)[]>;
168
- /**
169
- * For student interfaces: get new cards
170
- */
171
- getNewCards?(limit?: number): Promise<StudySessionNewItem[]>;
172
- }
173
- type AssignedContent = AssignedCourse | AssignedTag | AssignedCard;
174
- interface AssignedTag extends ContentBase {
175
- type: 'tag';
176
- tagID: string;
177
- }
178
- interface AssignedCourse extends ContentBase {
179
- type: 'course';
180
- }
181
- interface AssignedCard extends ContentBase {
182
- type: 'card';
183
- cardID: string;
184
- }
185
- interface ContentBase {
186
- type: 'course' | 'tag' | 'card';
187
- /**
188
- * Username of the assigning teacher.
189
- */
190
- assignedBy: string;
191
- /**
192
- * Date the content was assigned.
193
- */
194
- assignedOn: moment.Moment;
195
- /**
196
- * A 'due' date for this assigned content, for scheduling content
197
- * in advance. Content will not be actively pushed to students until
198
- * this date.
199
- */
200
- activeOn: moment.Moment;
201
- courseID: string;
202
- }
203
-
204
107
  interface DataLayerResult {
205
108
  status: Status;
206
109
  message: string;
@@ -255,10 +158,6 @@ interface NavigationStrategyManager {
255
158
  * @returns A promise that resolves when the update is complete
256
159
  */
257
160
  updateNavigationStrategy(id: string, data: ContentNavigationStrategyData): Promise<void>;
258
- /**
259
- * @returns A content navigation strategy suitable to the current context.
260
- */
261
- surfaceNavigationStrategy(): Promise<ContentNavigationStrategyData>;
262
161
  }
263
162
 
264
163
  /**
@@ -323,6 +222,18 @@ interface CourseDBInterface extends NavigationStrategyManager {
323
222
  * Get tags for a card
324
223
  */
325
224
  getAppliedTags(cardId: string): Promise<PouchDB.Query.Response<TagStub>>;
225
+ /**
226
+ * Get tags for multiple cards in a single batch query.
227
+ * More efficient than calling getAppliedTags() for each card.
228
+ *
229
+ * This method reduces redundant database operations when multiple filters
230
+ * need tag data for the same cards. The Pipeline uses this to pre-hydrate
231
+ * tags on WeightedCard objects before filters run.
232
+ *
233
+ * @param cardIds - Array of card IDs to fetch tags for
234
+ * @returns Map from cardId to array of tag names
235
+ */
236
+ getAppliedTagsBatch(cardIds: string[]): Promise<Map<string, string[]>>;
326
237
  /**
327
238
  * Add a tag to a card
328
239
  */
@@ -424,6 +335,17 @@ interface UserDBReader {
424
335
  */
425
336
  getPendingReviews(courseId?: string): Promise<ScheduledCard[]>;
426
337
  getActivityRecords(): Promise<ActivityRecord[]>;
338
+ /**
339
+ * Get strategy-specific state for a course.
340
+ *
341
+ * Strategies use this to persist preferences, learned patterns, or temporal
342
+ * tracking data across sessions. Each strategy owns its own namespace.
343
+ *
344
+ * @param courseId - The course this state applies to
345
+ * @param strategyKey - Unique key identifying the strategy (typically class name)
346
+ * @returns The strategy's data payload, or null if no state exists
347
+ */
348
+ getStrategyState<T>(courseId: string, strategyKey: string): Promise<T | null>;
427
349
  /**
428
350
  * Get user's classroom registrations
429
351
  */
@@ -488,6 +410,24 @@ interface UserDBWriter extends DocumentUpdater {
488
410
  status: Status;
489
411
  error?: string;
490
412
  }>;
413
+ /**
414
+ * Store strategy-specific state for a course.
415
+ *
416
+ * Strategies use this to persist preferences, learned patterns, or temporal
417
+ * tracking data across sessions. Each strategy owns its own namespace.
418
+ *
419
+ * @param courseId - The course this state applies to
420
+ * @param strategyKey - Unique key identifying the strategy (typically class name)
421
+ * @param data - The strategy's data payload to store
422
+ */
423
+ putStrategyState<T>(courseId: string, strategyKey: string, data: T): Promise<void>;
424
+ /**
425
+ * Delete strategy-specific state for a course.
426
+ *
427
+ * @param courseId - The course this state applies to
428
+ * @param strategyKey - Unique key identifying the strategy (typically class name)
429
+ */
430
+ deleteStrategyState(courseId: string, strategyKey: string): Promise<void>;
491
431
  }
492
432
  /**
493
433
  * Authentication and account management operations
@@ -542,4 +482,387 @@ interface ClassroomRegistrationDoc {
542
482
  registrations: ClassroomRegistration[];
543
483
  }
544
484
 
545
- export { type AdminDBInterface as A, type ClassroomRegistrationDesignation as B, type CourseDBInterface as C, type DataLayerResult as D, type ClassroomRegistration as E, type ClassroomRegistrationDoc as F, type SessionTrackingData as G, type UserConfig as H, type ActivityRecord as I, type CourseRegistration as J, type DocumentUpdater as K, newInterval as L, type StudySessionNewItem as S, type TeacherClassroomDBInterface as T, type UserDBInterface as U, type UserDBReader as a, type CoursesDBInterface as b, type ClassroomDBInterface as c, type CourseInfo as d, type ContentNavigationStrategyData as e, type StudySessionReviewItem as f, type ScheduledCard as g, type AssignedContent as h, type StudyContentSource as i, type StudentClassroomDBInterface as j, type StudySessionItem as k, type StudySessionFailedItem as l, type StudySessionFailedNewItem as m, type StudySessionFailedReviewItem as n, isReview as o, type ContentSourceID as p, getStudySource as q, type CourseRegistrationDoc as r, type AssignedTag as s, type AssignedCourse as t, type AssignedCard as u, type UserDBWriter as v, type UserDBAuthenticator as w, type UserCourseSettings as x, type UserCourseSetting as y, type UsrCrsDataInterface as z };
485
+ /**
486
+ * Tracks a single strategy's contribution to a card's final score.
487
+ *
488
+ * Each strategy in the pipeline adds a StrategyContribution entry to the
489
+ * card's provenance array, creating an audit trail of scoring decisions.
490
+ */
491
+ interface StrategyContribution {
492
+ /**
493
+ * Strategy type (implementing class name).
494
+ * Examples: 'elo', 'hierarchyDefinition', 'interferenceMitigator'
495
+ */
496
+ strategy: string;
497
+ /**
498
+ * Human-readable name identifying this specific strategy instance.
499
+ * Extracted from ContentNavigationStrategyData.name.
500
+ * Courses may have multiple instances of the same strategy type with
501
+ * different configurations.
502
+ *
503
+ * Examples:
504
+ * - "ELO (default)"
505
+ * - "Interference: b/d/p confusion"
506
+ * - "Interference: phonetic confusables"
507
+ * - "Priority: Common letters first"
508
+ */
509
+ strategyName: string;
510
+ /**
511
+ * Unique database document ID for this strategy instance.
512
+ * Extracted from ContentNavigationStrategyData._id.
513
+ * Use this to fetch the full strategy configuration document.
514
+ *
515
+ * Examples:
516
+ * - "NAVIGATION_STRATEGY-ELO-default"
517
+ * - "NAVIGATION_STRATEGY-interference-bdp"
518
+ * - "NAVIGATION_STRATEGY-priority-common-letters"
519
+ */
520
+ strategyId: string;
521
+ /**
522
+ * What the strategy did:
523
+ * - 'generated': Strategy produced this card (generators only)
524
+ * - 'passed': Strategy evaluated but didn't change score (transparent pass-through)
525
+ * - 'boosted': Strategy increased the score
526
+ * - 'penalized': Strategy decreased the score
527
+ */
528
+ action: 'generated' | 'passed' | 'boosted' | 'penalized';
529
+ /** Score after this strategy's processing */
530
+ score: number;
531
+ /**
532
+ * Human-readable explanation of the strategy's decision.
533
+ *
534
+ * Examples:
535
+ * - "ELO distance 75, new card"
536
+ * - "Prerequisites met: letter-sounds"
537
+ * - "Interferes with immature tag 'd' (decay 0.8)"
538
+ * - "High-priority tag 's' (0.95) → boost 1.15x"
539
+ *
540
+ * Required for transparency - silent adjusters are anti-patterns.
541
+ */
542
+ reason: string;
543
+ }
544
+ /**
545
+ * A card with a suitability score and provenance trail.
546
+ *
547
+ * Scores range from 0-1:
548
+ * - 1.0 = fully suitable
549
+ * - 0.0 = hard filter (e.g., prerequisite not met)
550
+ * - 0.5 = neutral
551
+ * - Intermediate values = soft preference
552
+ *
553
+ * Provenance tracks the scoring pipeline:
554
+ * - First entry: Generator that produced the card
555
+ * - Subsequent entries: Filters that transformed the score
556
+ * - Each entry includes action and human-readable reason
557
+ */
558
+ interface WeightedCard {
559
+ cardId: string;
560
+ courseId: string;
561
+ /** Suitability score from 0-1 */
562
+ score: number;
563
+ /**
564
+ * Audit trail of strategy contributions.
565
+ * First entry is from the generator, subsequent entries from filters.
566
+ */
567
+ provenance: StrategyContribution[];
568
+ /**
569
+ * Pre-fetched tags. Populated by Pipeline before filters run.
570
+ * Filters should use this instead of querying getAppliedTags() individually.
571
+ */
572
+ tags?: string[];
573
+ }
574
+ /**
575
+ * Extract card origin from provenance trail.
576
+ *
577
+ * The first provenance entry (from the generator) indicates whether
578
+ * this is a new card, review, or failed card. We parse the reason
579
+ * string to extract this information.
580
+ *
581
+ * @param card - Card with provenance trail
582
+ * @returns Card origin ('new', 'review', or 'failed')
583
+ */
584
+ declare function getCardOrigin(card: WeightedCard): 'new' | 'review' | 'failed';
585
+ declare enum Navigators {
586
+ ELO = "elo",
587
+ SRS = "srs",
588
+ HARDCODED = "hardcodedOrder",
589
+ HIERARCHY = "hierarchyDefinition",
590
+ INTERFERENCE = "interferenceMitigator",
591
+ RELATIVE_PRIORITY = "relativePriority",
592
+ USER_TAG_PREFERENCE = "userTagPreference"
593
+ }
594
+ /**
595
+ * Role classification for navigation strategies.
596
+ *
597
+ * - GENERATOR: Produces candidate cards with initial scores
598
+ * - FILTER: Transforms cards with score multipliers
599
+ */
600
+ declare enum NavigatorRole {
601
+ GENERATOR = "generator",
602
+ FILTER = "filter"
603
+ }
604
+ /**
605
+ * Registry mapping navigator implementations to their roles.
606
+ */
607
+ declare const NavigatorRoles: Record<Navigators, NavigatorRole>;
608
+ /**
609
+ * Check if a navigator implementation is a generator.
610
+ *
611
+ * @param impl - Navigator implementation name (e.g., 'elo', 'hierarchyDefinition')
612
+ * @returns true if the navigator is a generator, false otherwise
613
+ */
614
+ declare function isGenerator(impl: string): boolean;
615
+ /**
616
+ * Check if a navigator implementation is a filter.
617
+ *
618
+ * @param impl - Navigator implementation name (e.g., 'elo', 'hierarchyDefinition')
619
+ * @returns true if the navigator is a filter, false otherwise
620
+ */
621
+ declare function isFilter(impl: string): boolean;
622
+ /**
623
+ * Abstract base class for navigation strategies.
624
+ *
625
+ * This class exists primarily for backward compatibility with legacy code.
626
+ * New code should use CardGenerator or CardFilter interfaces directly.
627
+ *
628
+ * The class implements StudyContentSource for compatibility with SessionController.
629
+ * Once SessionController migrates to use getWeightedCards() exclusively,
630
+ * the legacy methods can be removed.
631
+ */
632
+ declare abstract class ContentNavigator implements StudyContentSource {
633
+ /** User interface for this navigation session */
634
+ protected user?: UserDBInterface;
635
+ /** Course interface for this navigation session */
636
+ protected course?: CourseDBInterface;
637
+ /** Human-readable name for this strategy instance (from ContentNavigationStrategyData.name) */
638
+ protected strategyName?: string;
639
+ /** Unique document ID for this strategy instance (from ContentNavigationStrategyData._id) */
640
+ protected strategyId?: string;
641
+ /**
642
+ * Constructor for standard navigators.
643
+ * Call this from subclass constructors to initialize common fields.
644
+ *
645
+ * Note: CompositeGenerator doesn't use this pattern and should call super() without args.
646
+ */
647
+ constructor(user?: UserDBInterface, course?: CourseDBInterface, strategyData?: ContentNavigationStrategyData);
648
+ /**
649
+ * Unique key identifying this strategy for state storage.
650
+ *
651
+ * Defaults to the constructor name (e.g., "UserTagPreferenceFilter").
652
+ * Override in subclasses if multiple instances of the same strategy type
653
+ * need separate state storage.
654
+ */
655
+ protected get strategyKey(): string;
656
+ /**
657
+ * Get this strategy's persisted state for the current course.
658
+ *
659
+ * @returns The strategy's data payload, or null if no state exists
660
+ * @throws Error if user or course is not initialized
661
+ */
662
+ protected getStrategyState<T>(): Promise<T | null>;
663
+ /**
664
+ * Persist this strategy's state for the current course.
665
+ *
666
+ * @param data - The strategy's data payload to store
667
+ * @throws Error if user or course is not initialized
668
+ */
669
+ protected putStrategyState<T>(data: T): Promise<void>;
670
+ /**
671
+ * Factory method to create navigator instances dynamically.
672
+ *
673
+ * @param user - User interface
674
+ * @param course - Course interface
675
+ * @param strategyData - Strategy configuration document
676
+ * @returns the runtime object used to steer a study session.
677
+ */
678
+ static create(user: UserDBInterface, course: CourseDBInterface, strategyData: ContentNavigationStrategyData): Promise<ContentNavigator>;
679
+ /**
680
+ * Get cards scheduled for review.
681
+ *
682
+ * @deprecated This method is part of the legacy StudyContentSource interface.
683
+ * New strategies should focus on implementing CardGenerator.getWeightedCards() instead.
684
+ */
685
+ abstract getPendingReviews(): Promise<(StudySessionReviewItem & ScheduledCard)[]>;
686
+ /**
687
+ * Get new cards for introduction.
688
+ *
689
+ * @deprecated This method is part of the legacy StudyContentSource interface.
690
+ * New strategies should focus on implementing CardGenerator.getWeightedCards() instead.
691
+ *
692
+ * @param n - Maximum number of new cards to return
693
+ */
694
+ abstract getNewCards(n?: number): Promise<StudySessionNewItem[]>;
695
+ /**
696
+ * Get cards with suitability scores and provenance trails.
697
+ *
698
+ * **This is the PRIMARY API for navigation strategies.**
699
+ *
700
+ * Returns cards ranked by suitability score (0-1). Higher scores indicate
701
+ * better candidates for presentation. Each card includes a provenance trail
702
+ * documenting how strategies contributed to the final score.
703
+ *
704
+ * ## For Generators
705
+ * Override this method to generate candidates and compute scores based on
706
+ * your strategy's logic (e.g., ELO proximity, review urgency). Create the
707
+ * initial provenance entry with action='generated'.
708
+ *
709
+ * ## Default Implementation
710
+ * The base class provides a backward-compatible default that:
711
+ * 1. Calls legacy getNewCards() and getPendingReviews()
712
+ * 2. Assigns score=1.0 to all cards
713
+ * 3. Creates minimal provenance from legacy methods
714
+ * 4. Returns combined results up to limit
715
+ *
716
+ * This allows existing strategies to work without modification while
717
+ * new strategies can override with proper scoring and provenance.
718
+ *
719
+ * @param limit - Maximum cards to return
720
+ * @returns Cards sorted by score descending, with provenance trails
721
+ */
722
+ getWeightedCards(limit: number): Promise<WeightedCard[]>;
723
+ }
724
+
725
+ type StudySessionFailedItem = StudySessionFailedNewItem | StudySessionFailedReviewItem;
726
+ interface StudySessionFailedNewItem extends StudySessionItem {
727
+ status: 'failed-new';
728
+ }
729
+ interface StudySessionFailedReviewItem extends StudySessionReviewItem {
730
+ status: 'failed-review';
731
+ }
732
+ interface StudySessionNewItem extends StudySessionItem {
733
+ status: 'new';
734
+ }
735
+ interface StudySessionReviewItem extends StudySessionItem {
736
+ reviewID: string;
737
+ status: 'review' | 'failed-review';
738
+ }
739
+ declare function isReview(item: StudySessionItem): item is StudySessionReviewItem;
740
+ interface StudySessionItem {
741
+ status: 'new' | 'review' | 'failed-new' | 'failed-review';
742
+ contentSourceType: 'course' | 'classroom';
743
+ contentSourceID: string;
744
+ cardID: string;
745
+ courseID: string;
746
+ elo?: number;
747
+ }
748
+ interface ContentSourceID {
749
+ type: 'course' | 'classroom';
750
+ id: string;
751
+ /**
752
+ * Optional tag filter for scoped study sessions.
753
+ * When present, creates a TagFilteredContentSource instead of a regular course source.
754
+ */
755
+ tagFilter?: TagFilter;
756
+ }
757
+ /**
758
+ * Interface for sources that provide study content to SessionController.
759
+ *
760
+ * @deprecated This interface will be superseded by ContentNavigator.getWeightedCards().
761
+ * The getNewCards/getPendingReviews split was an artifact of hard-coded ELO and SRS
762
+ * strategies. The new API returns unified WeightedCard[] with scores.
763
+ *
764
+ * MIGRATION:
765
+ * - Implement ContentNavigator instead of StudyContentSource directly
766
+ * - Override getWeightedCards() as the primary method
767
+ * - Legacy methods can delegate to getWeightedCards() or be left as-is
768
+ *
769
+ * See: packages/db/src/core/navigators/ARCHITECTURE.md
770
+ */
771
+ interface StudyContentSource {
772
+ /**
773
+ * Get cards scheduled for review based on SRS algorithm.
774
+ *
775
+ * @deprecated Will be replaced by getWeightedCards() which returns scored candidates.
776
+ * Review urgency will be expressed as a score rather than a separate method.
777
+ */
778
+ getPendingReviews(): Promise<(StudySessionReviewItem & ScheduledCard)[]>;
779
+ /**
780
+ * Get new cards for introduction, typically ordered by ELO proximity.
781
+ *
782
+ * @deprecated Will be replaced by getWeightedCards() which returns scored candidates.
783
+ * New card selection and scoring will be unified with review scoring.
784
+ *
785
+ * @param n - Maximum number of new cards to return
786
+ */
787
+ getNewCards(n?: number): Promise<StudySessionNewItem[]>;
788
+ /**
789
+ * Get cards with suitability scores for presentation.
790
+ *
791
+ * This is the PRIMARY API for content sources going forward. Returns unified
792
+ * scored candidates that can be sorted and selected by SessionController.
793
+ *
794
+ * The `source` field on WeightedCard indicates origin ('new' | 'review' | 'failed')
795
+ * for queue routing purposes during the migration period.
796
+ *
797
+ * @param limit - Maximum number of cards to return
798
+ * @returns Cards sorted by score descending
799
+ */
800
+ getWeightedCards?(limit: number): Promise<WeightedCard[]>;
801
+ }
802
+ declare function getStudySource(source: ContentSourceID, user: UserDBInterface): Promise<StudyContentSource>;
803
+
804
+ /**
805
+ * Classroom management
806
+ */
807
+ interface ClassroomDBInterface {
808
+ /**
809
+ * Get classroom config
810
+ */
811
+ getConfig(): ClassroomConfig;
812
+ /**
813
+ * Get assigned content
814
+ */
815
+ getAssignedContent(): Promise<AssignedContent[]>;
816
+ }
817
+ interface TeacherClassroomDBInterface extends ClassroomDBInterface {
818
+ /**
819
+ * For teacher interfaces: assign content
820
+ */
821
+ assignContent?(content: AssignedContent): Promise<boolean>;
822
+ /**
823
+ * For teacher interfaces: remove content
824
+ */
825
+ removeContent?(content: AssignedContent): Promise<void>;
826
+ }
827
+ interface StudentClassroomDBInterface extends ClassroomDBInterface {
828
+ /**
829
+ * For student interfaces: get pending reviews
830
+ */
831
+ getPendingReviews?(): Promise<(StudySessionReviewItem & ScheduledCard)[]>;
832
+ /**
833
+ * For student interfaces: get new cards
834
+ */
835
+ getNewCards?(limit?: number): Promise<StudySessionNewItem[]>;
836
+ }
837
+ type AssignedContent = AssignedCourse | AssignedTag | AssignedCard;
838
+ interface AssignedTag extends ContentBase {
839
+ type: 'tag';
840
+ tagID: string;
841
+ }
842
+ interface AssignedCourse extends ContentBase {
843
+ type: 'course';
844
+ }
845
+ interface AssignedCard extends ContentBase {
846
+ type: 'card';
847
+ cardID: string;
848
+ }
849
+ interface ContentBase {
850
+ type: 'course' | 'tag' | 'card';
851
+ /**
852
+ * Username of the assigning teacher.
853
+ */
854
+ assignedBy: string;
855
+ /**
856
+ * Date the content was assigned.
857
+ */
858
+ assignedOn: moment.Moment;
859
+ /**
860
+ * A 'due' date for this assigned content, for scheduling content
861
+ * in advance. Content will not be actively pushed to students until
862
+ * this date.
863
+ */
864
+ activeOn: moment.Moment;
865
+ courseID: string;
866
+ }
867
+
868
+ export { type AdminDBInterface as A, type UsrCrsDataInterface as B, type CourseDBInterface as C, type DataLayerResult as D, type ClassroomRegistrationDesignation as E, type ClassroomRegistration as F, type ClassroomRegistrationDoc as G, type SessionTrackingData as H, type UserConfig as I, type ActivityRecord as J, type CourseRegistration as K, type StrategyContribution as L, getCardOrigin as M, Navigators as N, NavigatorRole as O, NavigatorRoles as P, isGenerator as Q, isFilter as R, type StudySessionNewItem as S, type TeacherClassroomDBInterface as T, type UserDBInterface as U, type DocumentUpdater as V, type WeightedCard as W, newInterval as X, type UserDBReader as a, type CoursesDBInterface as b, type ClassroomDBInterface as c, type CourseInfo as d, type ContentNavigationStrategyData as e, type StudySessionReviewItem as f, type ScheduledCard as g, type AssignedContent as h, type StudyContentSource as i, type StudentClassroomDBInterface as j, ContentNavigator as k, type StudySessionItem as l, type StudySessionFailedItem as m, type StudySessionFailedNewItem as n, type StudySessionFailedReviewItem as o, isReview as p, type ContentSourceID as q, getStudySource as r, type CourseRegistrationDoc as s, type AssignedTag as t, type AssignedCourse as u, type AssignedCard as v, type UserDBWriter as w, type UserDBAuthenticator as x, type UserCourseSettings as y, type UserCourseSetting as z };