@vue-skuilder/db 0.1.18 → 0.1.21

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 (87) hide show
  1. package/CLAUDE.md +2 -2
  2. package/dist/{classroomDB-BgfrVb8d.d.ts → contentSource-BP9hznNV.d.ts} +220 -197
  3. package/dist/{classroomDB-CTOenngH.d.cts → contentSource-DsJadoBU.d.cts} +220 -197
  4. package/dist/core/index.d.cts +80 -6
  5. package/dist/core/index.d.ts +80 -6
  6. package/dist/core/index.js +735 -1560
  7. package/dist/core/index.js.map +1 -1
  8. package/dist/core/index.mjs +708 -1539
  9. package/dist/core/index.mjs.map +1 -1
  10. package/dist/{dataLayerProvider-D6PoCwS6.d.cts → dataLayerProvider-CHYrQ5pB.d.cts} +1 -1
  11. package/dist/{dataLayerProvider-CZxC9GtB.d.ts → dataLayerProvider-MDTxXq2l.d.ts} +1 -1
  12. package/dist/impl/couch/index.d.cts +8 -23
  13. package/dist/impl/couch/index.d.ts +8 -23
  14. package/dist/impl/couch/index.js +723 -1578
  15. package/dist/impl/couch/index.js.map +1 -1
  16. package/dist/impl/couch/index.mjs +692 -1552
  17. package/dist/impl/couch/index.mjs.map +1 -1
  18. package/dist/impl/static/index.d.cts +25 -8
  19. package/dist/impl/static/index.d.ts +25 -8
  20. package/dist/impl/static/index.js +700 -1400
  21. package/dist/impl/static/index.js.map +1 -1
  22. package/dist/impl/static/index.mjs +688 -1393
  23. package/dist/impl/static/index.mjs.map +1 -1
  24. package/dist/{index-D-Fa4Smt.d.cts → index-B_j6u5E4.d.cts} +1 -1
  25. package/dist/{index-CD8BZz2k.d.ts → index-Dj0SEgk3.d.ts} +1 -1
  26. package/dist/index.d.cts +71 -63
  27. package/dist/index.d.ts +71 -63
  28. package/dist/index.js +1162 -1996
  29. package/dist/index.js.map +1 -1
  30. package/dist/index.mjs +1124 -1955
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/pouch/index.js +3 -0
  33. package/dist/pouch/index.js.map +1 -1
  34. package/dist/pouch/index.mjs +3 -0
  35. package/dist/pouch/index.mjs.map +1 -1
  36. package/dist/{types-CzPDLAK6.d.cts → types-Bn0itutr.d.cts} +1 -1
  37. package/dist/{types-CewsN87z.d.ts → types-DQaXnuoc.d.ts} +1 -1
  38. package/dist/{types-legacy-6ettoclI.d.cts → types-legacy-DDY4N-Uq.d.cts} +3 -1
  39. package/dist/{types-legacy-6ettoclI.d.ts → types-legacy-DDY4N-Uq.d.ts} +3 -1
  40. package/dist/util/packer/index.d.cts +3 -3
  41. package/dist/util/packer/index.d.ts +3 -3
  42. package/docs/navigators-architecture.md +115 -17
  43. package/package.json +4 -4
  44. package/src/core/index.ts +1 -0
  45. package/src/core/interfaces/classroomDB.ts +5 -13
  46. package/src/core/interfaces/contentSource.ts +6 -66
  47. package/src/core/interfaces/courseDB.ts +15 -7
  48. package/src/core/interfaces/userDB.ts +32 -0
  49. package/src/core/navigators/Pipeline.ts +136 -52
  50. package/src/core/navigators/PipelineAssembler.ts +1 -1
  51. package/src/core/navigators/defaults.ts +84 -0
  52. package/src/core/navigators/{hierarchyDefinition.ts → filters/hierarchyDefinition.ts} +15 -29
  53. package/src/core/navigators/filters/index.ts +3 -0
  54. package/src/core/navigators/filters/inferredPreferenceStub.ts +107 -0
  55. package/src/core/navigators/{interferenceMitigator.ts → filters/interferenceMitigator.ts} +11 -37
  56. package/src/core/navigators/{relativePriority.ts → filters/relativePriority.ts} +12 -38
  57. package/src/core/navigators/filters/userGoalStub.ts +136 -0
  58. package/src/core/navigators/filters/userTagPreference.ts +217 -0
  59. package/src/core/navigators/{CompositeGenerator.ts → generators/CompositeGenerator.ts} +15 -64
  60. package/src/core/navigators/{elo.ts → generators/elo.ts} +13 -63
  61. package/src/core/navigators/{srs.ts → generators/srs.ts} +11 -40
  62. package/src/core/navigators/generators/types.ts +1 -1
  63. package/src/core/navigators/index.ts +95 -91
  64. package/src/core/types/strategyState.ts +84 -0
  65. package/src/core/types/types-legacy.ts +2 -0
  66. package/src/impl/common/BaseUserDB.ts +74 -7
  67. package/src/impl/couch/adminDB.ts +1 -2
  68. package/src/impl/couch/classroomDB.ts +100 -103
  69. package/src/impl/couch/courseDB.ts +35 -91
  70. package/src/impl/couch/pouchdb-setup.ts +7 -0
  71. package/src/impl/static/StaticDataUnpacker.ts +50 -1
  72. package/src/impl/static/courseDB.ts +87 -37
  73. package/src/study/SessionController.ts +122 -202
  74. package/src/study/SourceMixer.ts +65 -0
  75. package/src/study/TagFilteredContentSource.ts +49 -92
  76. package/src/study/index.ts +1 -0
  77. package/src/study/services/CardHydrationService.ts +165 -81
  78. package/src/util/dataDirectory.ts +1 -1
  79. package/src/util/index.ts +0 -1
  80. package/tests/core/navigators/CompositeGenerator.test.ts +44 -168
  81. package/tests/core/navigators/Pipeline.test.ts +6 -72
  82. package/tests/core/navigators/PipelineAssembler.test.ts +8 -58
  83. package/tests/core/navigators/navigators.test.ts +118 -151
  84. package/docs/todo-pipeline-optimization.md +0 -117
  85. package/docs/todo-strategy-state-storage.md +0 -278
  86. package/src/core/navigators/hardcodedOrder.ts +0 -163
  87. package/src/util/tuiLogger.ts +0 -139
@@ -5,11 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __glob = (map) => (path2) => {
9
- var fn = map[path2];
10
- if (fn) return fn();
11
- throw new Error("Module not found in bundle: " + path2);
12
- };
13
8
  var __esm = (fn, res) => function __init() {
14
9
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
15
10
  };
@@ -122,6 +117,7 @@ var init_types_legacy = __esm({
122
117
  DocType2["SCHEDULED_CARD"] = "SCHEDULED_CARD";
123
118
  DocType2["TAG"] = "TAG";
124
119
  DocType2["NAVIGATION_STRATEGY"] = "NAVIGATION_STRATEGY";
120
+ DocType2["STRATEGY_STATE"] = "STRATEGY_STATE";
125
121
  return DocType2;
126
122
  })(DocType || {});
127
123
  DocTypePrefixes = {
@@ -135,7 +131,8 @@ var init_types_legacy = __esm({
135
131
  ["QUESTION" /* QUESTIONTYPE */]: "QUESTION",
136
132
  ["VIEW" /* VIEW */]: "VIEW",
137
133
  ["PEDAGOGY" /* PEDAGOGY */]: "PEDAGOGY",
138
- ["NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */]: "NAVIGATION_STRATEGY"
134
+ ["NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */]: "NAVIGATION_STRATEGY",
135
+ ["STRATEGY_STATE" /* STRATEGY_STATE */]: "STRATEGY_STATE"
139
136
  };
140
137
  }
141
138
  });
@@ -186,6 +183,9 @@ var init_pouchdb_setup = __esm({
186
183
  import_pouchdb_authentication = __toESM(require("@nilock2/pouchdb-authentication"), 1);
187
184
  import_pouchdb.default.plugin(import_pouchdb_find.default);
188
185
  import_pouchdb.default.plugin(import_pouchdb_authentication.default);
186
+ if (typeof import_pouchdb.default.debug !== "undefined") {
187
+ import_pouchdb.default.debug.disable();
188
+ }
189
189
  import_pouchdb.default.defaults({
190
190
  // ajax: {
191
191
  // timeout: 60000,
@@ -195,14 +195,6 @@ var init_pouchdb_setup = __esm({
195
195
  }
196
196
  });
197
197
 
198
- // src/util/tuiLogger.ts
199
- var init_tuiLogger = __esm({
200
- "src/util/tuiLogger.ts"() {
201
- "use strict";
202
- init_dataDirectory();
203
- }
204
- });
205
-
206
198
  // src/util/dataDirectory.ts
207
199
  function getAppDataDirectory() {
208
200
  if (ENV.LOCAL_STORAGE_PREFIX) {
@@ -220,7 +212,7 @@ var init_dataDirectory = __esm({
220
212
  "use strict";
221
213
  path = __toESM(require("path"), 1);
222
214
  os = __toESM(require("os"), 1);
223
- init_tuiLogger();
215
+ init_logger();
224
216
  init_factory();
225
217
  }
226
218
  });
@@ -709,24 +701,359 @@ var init_courseLookupDB = __esm({
709
701
  }
710
702
  });
711
703
 
712
- // src/core/navigators/CompositeGenerator.ts
713
- var CompositeGenerator_exports = {};
714
- __export(CompositeGenerator_exports, {
715
- AggregationMode: () => AggregationMode,
716
- default: () => CompositeGenerator
704
+ // src/core/navigators/index.ts
705
+ function getCardOrigin(card) {
706
+ if (card.provenance.length === 0) {
707
+ throw new Error("Card has no provenance - cannot determine origin");
708
+ }
709
+ const firstEntry = card.provenance[0];
710
+ const reason = firstEntry.reason.toLowerCase();
711
+ if (reason.includes("failed")) {
712
+ return "failed";
713
+ }
714
+ if (reason.includes("review")) {
715
+ return "review";
716
+ }
717
+ return "new";
718
+ }
719
+ function isGenerator(impl) {
720
+ return NavigatorRoles[impl] === "generator" /* GENERATOR */;
721
+ }
722
+ function isFilter(impl) {
723
+ return NavigatorRoles[impl] === "filter" /* FILTER */;
724
+ }
725
+ var Navigators, NavigatorRole, NavigatorRoles, ContentNavigator;
726
+ var init_navigators = __esm({
727
+ "src/core/navigators/index.ts"() {
728
+ "use strict";
729
+ init_logger();
730
+ Navigators = /* @__PURE__ */ ((Navigators2) => {
731
+ Navigators2["ELO"] = "elo";
732
+ Navigators2["SRS"] = "srs";
733
+ Navigators2["HIERARCHY"] = "hierarchyDefinition";
734
+ Navigators2["INTERFERENCE"] = "interferenceMitigator";
735
+ Navigators2["RELATIVE_PRIORITY"] = "relativePriority";
736
+ Navigators2["USER_TAG_PREFERENCE"] = "userTagPreference";
737
+ return Navigators2;
738
+ })(Navigators || {});
739
+ NavigatorRole = /* @__PURE__ */ ((NavigatorRole2) => {
740
+ NavigatorRole2["GENERATOR"] = "generator";
741
+ NavigatorRole2["FILTER"] = "filter";
742
+ return NavigatorRole2;
743
+ })(NavigatorRole || {});
744
+ NavigatorRoles = {
745
+ ["elo" /* ELO */]: "generator" /* GENERATOR */,
746
+ ["srs" /* SRS */]: "generator" /* GENERATOR */,
747
+ ["hierarchyDefinition" /* HIERARCHY */]: "filter" /* FILTER */,
748
+ ["interferenceMitigator" /* INTERFERENCE */]: "filter" /* FILTER */,
749
+ ["relativePriority" /* RELATIVE_PRIORITY */]: "filter" /* FILTER */,
750
+ ["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER */
751
+ };
752
+ ContentNavigator = class {
753
+ /** User interface for this navigation session */
754
+ user;
755
+ /** Course interface for this navigation session */
756
+ course;
757
+ /** Human-readable name for this strategy instance (from ContentNavigationStrategyData.name) */
758
+ strategyName;
759
+ /** Unique document ID for this strategy instance (from ContentNavigationStrategyData._id) */
760
+ strategyId;
761
+ /**
762
+ * Constructor for standard navigators.
763
+ * Call this from subclass constructors to initialize common fields.
764
+ *
765
+ * Note: CompositeGenerator and Pipeline call super() without args, then set
766
+ * user/course fields directly if needed.
767
+ */
768
+ constructor(user, course, strategyData) {
769
+ this.user = user;
770
+ this.course = course;
771
+ if (strategyData) {
772
+ this.strategyName = strategyData.name;
773
+ this.strategyId = strategyData._id;
774
+ }
775
+ }
776
+ // ============================================================================
777
+ // STRATEGY STATE HELPERS
778
+ // ============================================================================
779
+ //
780
+ // These methods allow strategies to persist their own state (user preferences,
781
+ // learned patterns, temporal tracking) in the user database.
782
+ //
783
+ // ============================================================================
784
+ /**
785
+ * Unique key identifying this strategy for state storage.
786
+ *
787
+ * Defaults to the constructor name (e.g., "UserTagPreferenceFilter").
788
+ * Override in subclasses if multiple instances of the same strategy type
789
+ * need separate state storage.
790
+ */
791
+ get strategyKey() {
792
+ return this.constructor.name;
793
+ }
794
+ /**
795
+ * Get this strategy's persisted state for the current course.
796
+ *
797
+ * @returns The strategy's data payload, or null if no state exists
798
+ * @throws Error if user or course is not initialized
799
+ */
800
+ async getStrategyState() {
801
+ if (!this.user || !this.course) {
802
+ throw new Error(
803
+ `Cannot get strategy state: navigator not properly initialized. Ensure user and course are provided to constructor.`
804
+ );
805
+ }
806
+ return this.user.getStrategyState(this.course.getCourseID(), this.strategyKey);
807
+ }
808
+ /**
809
+ * Persist this strategy's state for the current course.
810
+ *
811
+ * @param data - The strategy's data payload to store
812
+ * @throws Error if user or course is not initialized
813
+ */
814
+ async putStrategyState(data) {
815
+ if (!this.user || !this.course) {
816
+ throw new Error(
817
+ `Cannot put strategy state: navigator not properly initialized. Ensure user and course are provided to constructor.`
818
+ );
819
+ }
820
+ return this.user.putStrategyState(this.course.getCourseID(), this.strategyKey, data);
821
+ }
822
+ /**
823
+ * Factory method to create navigator instances dynamically.
824
+ *
825
+ * @param user - User interface
826
+ * @param course - Course interface
827
+ * @param strategyData - Strategy configuration document
828
+ * @returns the runtime object used to steer a study session.
829
+ */
830
+ static async create(user, course, strategyData) {
831
+ const implementingClass = strategyData.implementingClass;
832
+ let NavigatorImpl;
833
+ const variations = [".ts", ".js", ""];
834
+ const dirs = ["filters", "generators"];
835
+ for (const ext of variations) {
836
+ for (const dir of dirs) {
837
+ const loadFrom = `./${dir}/${implementingClass}${ext}`;
838
+ try {
839
+ const module2 = await import(loadFrom);
840
+ NavigatorImpl = module2.default;
841
+ break;
842
+ } catch (e) {
843
+ logger.debug(`Failed to load extension from ${loadFrom}:`, e);
844
+ }
845
+ }
846
+ }
847
+ if (!NavigatorImpl) {
848
+ throw new Error(`Could not load navigator implementation for: ${implementingClass}`);
849
+ }
850
+ return new NavigatorImpl(user, course, strategyData);
851
+ }
852
+ /**
853
+ * Get cards with suitability scores and provenance trails.
854
+ *
855
+ * **This is the PRIMARY API for navigation strategies.**
856
+ *
857
+ * Returns cards ranked by suitability score (0-1). Higher scores indicate
858
+ * better candidates for presentation. Each card includes a provenance trail
859
+ * documenting how strategies contributed to the final score.
860
+ *
861
+ * ## Implementation Required
862
+ * All navigation strategies MUST override this method. The base class does
863
+ * not provide a default implementation.
864
+ *
865
+ * ## For Generators
866
+ * Override this method to generate candidates and compute scores based on
867
+ * your strategy's logic (e.g., ELO proximity, review urgency). Create the
868
+ * initial provenance entry with action='generated'.
869
+ *
870
+ * ## For Filters
871
+ * Filters should implement the CardFilter interface instead and be composed
872
+ * via Pipeline. Filters do not directly implement getWeightedCards().
873
+ *
874
+ * @param limit - Maximum cards to return
875
+ * @returns Cards sorted by score descending, with provenance trails
876
+ */
877
+ async getWeightedCards(_limit) {
878
+ throw new Error(`${this.constructor.name} must implement getWeightedCards(). `);
879
+ }
880
+ };
881
+ }
882
+ });
883
+
884
+ // src/core/navigators/Pipeline.ts
885
+ function logPipelineConfig(generator, filters) {
886
+ const filterList = filters.length > 0 ? "\n - " + filters.map((f) => f.name).join("\n - ") : " none";
887
+ logger.info(
888
+ `[Pipeline] Configuration:
889
+ Generator: ${generator.name}
890
+ Filters:${filterList}`
891
+ );
892
+ }
893
+ function logTagHydration(cards, tagsByCard) {
894
+ const totalTags = Array.from(tagsByCard.values()).reduce((sum, tags) => sum + tags.length, 0);
895
+ const cardsWithTags = Array.from(tagsByCard.values()).filter((tags) => tags.length > 0).length;
896
+ logger.debug(
897
+ `[Pipeline] Tag hydration: ${cards.length} cards, ${cardsWithTags} have tags (${totalTags} total tags) - single batch query`
898
+ );
899
+ }
900
+ function logExecutionSummary(generatorName, generatedCount, filterCount, finalCount, topScores) {
901
+ const scoreDisplay = topScores.length > 0 ? topScores.map((s) => s.toFixed(2)).join(", ") : "none";
902
+ logger.info(
903
+ `[Pipeline] Execution: ${generatorName} produced ${generatedCount} \u2192 ${filterCount} filters \u2192 ${finalCount} results (top scores: ${scoreDisplay})`
904
+ );
905
+ }
906
+ function logCardProvenance(cards, maxCards = 3) {
907
+ const cardsToLog = cards.slice(0, maxCards);
908
+ logger.debug(`[Pipeline] Provenance for top ${cardsToLog.length} cards:`);
909
+ for (const card of cardsToLog) {
910
+ logger.debug(`[Pipeline] ${card.cardId} (final score: ${card.score.toFixed(3)}):`);
911
+ for (const entry of card.provenance) {
912
+ const scoreChange = entry.score.toFixed(3);
913
+ const action = entry.action.padEnd(9);
914
+ logger.debug(
915
+ `[Pipeline] ${action} ${scoreChange} - ${entry.strategyName}: ${entry.reason}`
916
+ );
917
+ }
918
+ }
919
+ }
920
+ var import_common5, Pipeline;
921
+ var init_Pipeline = __esm({
922
+ "src/core/navigators/Pipeline.ts"() {
923
+ "use strict";
924
+ import_common5 = require("@vue-skuilder/common");
925
+ init_navigators();
926
+ init_logger();
927
+ Pipeline = class extends ContentNavigator {
928
+ generator;
929
+ filters;
930
+ /**
931
+ * Create a new pipeline.
932
+ *
933
+ * @param generator - The generator (or CompositeGenerator) that produces candidates
934
+ * @param filters - Filters to apply sequentially (order doesn't matter for multipliers)
935
+ * @param user - User database interface
936
+ * @param course - Course database interface
937
+ */
938
+ constructor(generator, filters, user, course) {
939
+ super();
940
+ this.generator = generator;
941
+ this.filters = filters;
942
+ this.user = user;
943
+ this.course = course;
944
+ course.getCourseConfig().then((cfg) => {
945
+ logger.debug(`[pipeline] Crated pipeline for ${cfg.name}`);
946
+ }).catch((e) => {
947
+ logger.error(`[pipeline] Failed to lookup courseCfg: ${e}`);
948
+ });
949
+ logPipelineConfig(generator, filters);
950
+ }
951
+ /**
952
+ * Get weighted cards by running generator and applying filters.
953
+ *
954
+ * 1. Build shared context (user ELO, etc.)
955
+ * 2. Get candidates from generator (passing context)
956
+ * 3. Batch hydrate tags for all candidates
957
+ * 4. Apply each filter sequentially
958
+ * 5. Remove zero-score cards
959
+ * 6. Sort by score descending
960
+ * 7. Return top N
961
+ *
962
+ * @param limit - Maximum number of cards to return
963
+ * @returns Cards sorted by score descending
964
+ */
965
+ async getWeightedCards(limit) {
966
+ const context = await this.buildContext();
967
+ const overFetchMultiplier = 2 + this.filters.length * 0.5;
968
+ const fetchLimit = Math.ceil(limit * overFetchMultiplier);
969
+ logger.debug(
970
+ `[Pipeline] Fetching ${fetchLimit} candidates from generator '${this.generator.name}'`
971
+ );
972
+ let cards = await this.generator.getWeightedCards(fetchLimit, context);
973
+ const generatedCount = cards.length;
974
+ logger.debug(`[Pipeline] Generator returned ${generatedCount} candidates`);
975
+ cards = await this.hydrateTags(cards);
976
+ for (const filter of this.filters) {
977
+ const beforeCount = cards.length;
978
+ cards = await filter.transform(cards, context);
979
+ logger.debug(`[Pipeline] Filter '${filter.name}': ${beforeCount} \u2192 ${cards.length} cards`);
980
+ }
981
+ cards = cards.filter((c) => c.score > 0);
982
+ cards.sort((a, b) => b.score - a.score);
983
+ const result = cards.slice(0, limit);
984
+ const topScores = result.slice(0, 3).map((c) => c.score);
985
+ logExecutionSummary(
986
+ this.generator.name,
987
+ generatedCount,
988
+ this.filters.length,
989
+ result.length,
990
+ topScores
991
+ );
992
+ logCardProvenance(result, 3);
993
+ return result;
994
+ }
995
+ /**
996
+ * Batch hydrate tags for all cards.
997
+ *
998
+ * Fetches tags for all cards in a single database query and attaches them
999
+ * to the WeightedCard objects. Filters can then use card.tags instead of
1000
+ * making individual getAppliedTags() calls.
1001
+ *
1002
+ * @param cards - Cards to hydrate
1003
+ * @returns Cards with tags populated
1004
+ */
1005
+ async hydrateTags(cards) {
1006
+ if (cards.length === 0) {
1007
+ return cards;
1008
+ }
1009
+ const cardIds = cards.map((c) => c.cardId);
1010
+ const tagsByCard = await this.course.getAppliedTagsBatch(cardIds);
1011
+ logTagHydration(cards, tagsByCard);
1012
+ return cards.map((card) => ({
1013
+ ...card,
1014
+ tags: tagsByCard.get(card.cardId) ?? []
1015
+ }));
1016
+ }
1017
+ /**
1018
+ * Build shared context for generator and filters.
1019
+ *
1020
+ * Called once per getWeightedCards() invocation.
1021
+ * Contains data that the generator and multiple filters might need.
1022
+ *
1023
+ * The context satisfies both GeneratorContext and FilterContext interfaces.
1024
+ */
1025
+ async buildContext() {
1026
+ let userElo = 1e3;
1027
+ try {
1028
+ const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
1029
+ const courseElo = (0, import_common5.toCourseElo)(courseReg.elo);
1030
+ userElo = courseElo.global.score;
1031
+ } catch (e) {
1032
+ logger.debug(`[Pipeline] Could not get user ELO, using default: ${e}`);
1033
+ }
1034
+ return {
1035
+ user: this.user,
1036
+ course: this.course,
1037
+ userElo
1038
+ };
1039
+ }
1040
+ /**
1041
+ * Get the course ID for this pipeline.
1042
+ */
1043
+ getCourseID() {
1044
+ return this.course.getCourseID();
1045
+ }
1046
+ };
1047
+ }
717
1048
  });
718
- var AggregationMode, DEFAULT_AGGREGATION_MODE, FREQUENCY_BOOST_FACTOR, CompositeGenerator;
1049
+
1050
+ // src/core/navigators/generators/CompositeGenerator.ts
1051
+ var DEFAULT_AGGREGATION_MODE, FREQUENCY_BOOST_FACTOR, CompositeGenerator;
719
1052
  var init_CompositeGenerator = __esm({
720
- "src/core/navigators/CompositeGenerator.ts"() {
1053
+ "src/core/navigators/generators/CompositeGenerator.ts"() {
721
1054
  "use strict";
722
1055
  init_navigators();
723
1056
  init_logger();
724
- AggregationMode = /* @__PURE__ */ ((AggregationMode2) => {
725
- AggregationMode2["MAX"] = "max";
726
- AggregationMode2["AVERAGE"] = "average";
727
- AggregationMode2["FREQUENCY_BOOST"] = "frequencyBoost";
728
- return AggregationMode2;
729
- })(AggregationMode || {});
730
1057
  DEFAULT_AGGREGATION_MODE = "frequencyBoost" /* FREQUENCY_BOOST */;
731
1058
  FREQUENCY_BOOST_FACTOR = 0.1;
732
1059
  CompositeGenerator = class _CompositeGenerator extends ContentNavigator {
@@ -766,9 +1093,14 @@ var init_CompositeGenerator = __esm({
766
1093
  * CardGenerator interface signature (limit, context).
767
1094
  *
768
1095
  * @param limit - Maximum number of cards to return
769
- * @param context - Optional GeneratorContext passed to child generators
1096
+ * @param context - GeneratorContext passed to child generators (required when called via Pipeline)
770
1097
  */
771
1098
  async getWeightedCards(limit, context) {
1099
+ if (!context) {
1100
+ throw new Error(
1101
+ "CompositeGenerator.getWeightedCards requires a GeneratorContext. It should be called via Pipeline, not directly."
1102
+ );
1103
+ }
772
1104
  const results = await Promise.all(
773
1105
  this.generators.map((g) => g.getWeightedCards(limit, context))
774
1106
  );
@@ -849,183 +1181,11 @@ var init_CompositeGenerator = __esm({
849
1181
  return scores[0];
850
1182
  }
851
1183
  }
852
- /**
853
- * Get new cards from all generators, merged and deduplicated.
854
- */
855
- async getNewCards(n) {
856
- const legacyGenerators = this.generators.filter(
857
- (g) => g instanceof ContentNavigator
858
- );
859
- const results = await Promise.all(legacyGenerators.map((g) => g.getNewCards(n)));
860
- const seen = /* @__PURE__ */ new Set();
861
- const merged = [];
862
- for (const cards of results) {
863
- for (const card of cards) {
864
- if (!seen.has(card.cardID)) {
865
- seen.add(card.cardID);
866
- merged.push(card);
867
- }
868
- }
869
- }
870
- return n ? merged.slice(0, n) : merged;
871
- }
872
- /**
873
- * Get pending reviews from all generators, merged and deduplicated.
874
- */
875
- async getPendingReviews() {
876
- const legacyGenerators = this.generators.filter(
877
- (g) => g instanceof ContentNavigator
878
- );
879
- const results = await Promise.all(legacyGenerators.map((g) => g.getPendingReviews()));
880
- const seen = /* @__PURE__ */ new Set();
881
- const merged = [];
882
- for (const reviews of results) {
883
- for (const review of reviews) {
884
- if (!seen.has(review.cardID)) {
885
- seen.add(review.cardID);
886
- merged.push(review);
887
- }
888
- }
889
- }
890
- return merged;
891
- }
892
- };
893
- }
894
- });
895
-
896
- // src/core/navigators/Pipeline.ts
897
- var Pipeline_exports = {};
898
- __export(Pipeline_exports, {
899
- Pipeline: () => Pipeline
900
- });
901
- var import_common5, Pipeline;
902
- var init_Pipeline = __esm({
903
- "src/core/navigators/Pipeline.ts"() {
904
- "use strict";
905
- import_common5 = require("@vue-skuilder/common");
906
- init_navigators();
907
- init_logger();
908
- Pipeline = class extends ContentNavigator {
909
- generator;
910
- filters;
911
- /**
912
- * Create a new pipeline.
913
- *
914
- * @param generator - The generator (or CompositeGenerator) that produces candidates
915
- * @param filters - Filters to apply sequentially (order doesn't matter for multipliers)
916
- * @param user - User database interface
917
- * @param course - Course database interface
918
- */
919
- constructor(generator, filters, user, course) {
920
- super();
921
- this.generator = generator;
922
- this.filters = filters;
923
- this.user = user;
924
- this.course = course;
925
- logger.debug(
926
- `[Pipeline] Created with generator '${generator.name}' and ${filters.length} filters: ${filters.map((f) => f.name).join(", ")}`
927
- );
928
- }
929
- /**
930
- * Get weighted cards by running generator and applying filters.
931
- *
932
- * 1. Build shared context (user ELO, etc.)
933
- * 2. Get candidates from generator (passing context)
934
- * 3. Apply each filter sequentially
935
- * 4. Remove zero-score cards
936
- * 5. Sort by score descending
937
- * 6. Return top N
938
- *
939
- * @param limit - Maximum number of cards to return
940
- * @returns Cards sorted by score descending
941
- */
942
- async getWeightedCards(limit) {
943
- const context = await this.buildContext();
944
- const overFetchMultiplier = 2 + this.filters.length * 0.5;
945
- const fetchLimit = Math.ceil(limit * overFetchMultiplier);
946
- logger.debug(
947
- `[Pipeline] Fetching ${fetchLimit} candidates from generator '${this.generator.name}'`
948
- );
949
- let cards = await this.generator.getWeightedCards(fetchLimit, context);
950
- logger.debug(`[Pipeline] Generator returned ${cards.length} candidates`);
951
- for (const filter of this.filters) {
952
- const beforeCount = cards.length;
953
- cards = await filter.transform(cards, context);
954
- logger.debug(`[Pipeline] Filter '${filter.name}': ${beforeCount} \u2192 ${cards.length} cards`);
955
- }
956
- cards = cards.filter((c) => c.score > 0);
957
- cards.sort((a, b) => b.score - a.score);
958
- const result = cards.slice(0, limit);
959
- logger.debug(
960
- `[Pipeline] Returning ${result.length} cards (top scores: ${result.slice(0, 3).map((c) => c.score.toFixed(2)).join(", ")}...)`
961
- );
962
- return result;
963
- }
964
- /**
965
- * Build shared context for generator and filters.
966
- *
967
- * Called once per getWeightedCards() invocation.
968
- * Contains data that the generator and multiple filters might need.
969
- *
970
- * The context satisfies both GeneratorContext and FilterContext interfaces.
971
- */
972
- async buildContext() {
973
- let userElo = 1e3;
974
- try {
975
- const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
976
- const courseElo = (0, import_common5.toCourseElo)(courseReg.elo);
977
- userElo = courseElo.global.score;
978
- } catch (e) {
979
- logger.debug(`[Pipeline] Could not get user ELO, using default: ${e}`);
980
- }
981
- return {
982
- user: this.user,
983
- course: this.course,
984
- userElo
985
- };
986
- }
987
- // ===========================================================================
988
- // Legacy StudyContentSource methods
989
- // ===========================================================================
990
- //
991
- // These delegate to the generator for backward compatibility.
992
- // Eventually SessionController will use getWeightedCards() exclusively.
993
- //
994
- /**
995
- * Get new cards via legacy API.
996
- * Delegates to the generator if it supports the legacy interface.
997
- */
998
- async getNewCards(n) {
999
- if ("getNewCards" in this.generator && typeof this.generator.getNewCards === "function") {
1000
- return this.generator.getNewCards(n);
1001
- }
1002
- return [];
1003
- }
1004
- /**
1005
- * Get pending reviews via legacy API.
1006
- * Delegates to the generator if it supports the legacy interface.
1007
- */
1008
- async getPendingReviews() {
1009
- if ("getPendingReviews" in this.generator && typeof this.generator.getPendingReviews === "function") {
1010
- return this.generator.getPendingReviews();
1011
- }
1012
- return [];
1013
- }
1014
- /**
1015
- * Get the course ID for this pipeline.
1016
- */
1017
- getCourseID() {
1018
- return this.course.getCourseID();
1019
- }
1020
1184
  };
1021
1185
  }
1022
1186
  });
1023
1187
 
1024
1188
  // src/core/navigators/PipelineAssembler.ts
1025
- var PipelineAssembler_exports = {};
1026
- __export(PipelineAssembler_exports, {
1027
- PipelineAssembler: () => PipelineAssembler
1028
- });
1029
1189
  var PipelineAssembler;
1030
1190
  var init_PipelineAssembler = __esm({
1031
1191
  "src/core/navigators/PipelineAssembler.ts"() {
@@ -1146,14 +1306,10 @@ var init_PipelineAssembler = __esm({
1146
1306
  }
1147
1307
  });
1148
1308
 
1149
- // src/core/navigators/elo.ts
1150
- var elo_exports = {};
1151
- __export(elo_exports, {
1152
- default: () => ELONavigator
1153
- });
1309
+ // src/core/navigators/generators/elo.ts
1154
1310
  var import_common6, ELONavigator;
1155
1311
  var init_elo = __esm({
1156
- "src/core/navigators/elo.ts"() {
1312
+ "src/core/navigators/generators/elo.ts"() {
1157
1313
  "use strict";
1158
1314
  init_navigators();
1159
1315
  import_common6 = require("@vue-skuilder/common");
@@ -1164,50 +1320,6 @@ var init_elo = __esm({
1164
1320
  super(user, course, strategyData);
1165
1321
  this.name = strategyData?.name || "ELO";
1166
1322
  }
1167
- async getPendingReviews() {
1168
- const reviews = await this.user.getPendingReviews(this.course.getCourseID());
1169
- const elo = await this.course.getCardEloData(reviews.map((r) => r.cardId));
1170
- const ratedReviews = reviews.map((r, i) => {
1171
- const ratedR = {
1172
- ...r,
1173
- ...elo[i]
1174
- };
1175
- return ratedR;
1176
- });
1177
- ratedReviews.sort((a, b) => {
1178
- return a.global.score - b.global.score;
1179
- });
1180
- return ratedReviews.map((r) => {
1181
- return {
1182
- ...r,
1183
- contentSourceType: "course",
1184
- contentSourceID: this.course.getCourseID(),
1185
- cardID: r.cardId,
1186
- courseID: r.courseId,
1187
- qualifiedID: `${r.courseId}-${r.cardId}`,
1188
- reviewID: r._id,
1189
- status: "review"
1190
- };
1191
- });
1192
- }
1193
- async getNewCards(limit = 99) {
1194
- const activeCards = await this.user.getActiveCards();
1195
- return (await this.course.getCardsCenteredAtELO(
1196
- { limit, elo: "user" },
1197
- (c) => {
1198
- if (activeCards.some((ac) => c.cardID === ac.cardID)) {
1199
- return false;
1200
- } else {
1201
- return true;
1202
- }
1203
- }
1204
- )).map((c) => {
1205
- return {
1206
- ...c,
1207
- status: "new"
1208
- };
1209
- });
1210
- }
1211
1323
  /**
1212
1324
  * Get new cards with suitability scores based on ELO distance.
1213
1325
  *
@@ -1232,7 +1344,11 @@ var init_elo = __esm({
1232
1344
  const userElo = (0, import_common6.toCourseElo)(courseReg.elo);
1233
1345
  userGlobalElo = userElo.global.score;
1234
1346
  }
1235
- const newCards = await this.getNewCards(limit);
1347
+ const activeCards = await this.user.getActiveCards();
1348
+ const newCards = (await this.course.getCardsCenteredAtELO(
1349
+ { limit, elo: "user" },
1350
+ (c) => !activeCards.some((ac) => c.cardID === ac.cardID)
1351
+ )).map((c) => ({ ...c, status: "new" }));
1236
1352
  const cardIds = newCards.map((c) => c.cardID);
1237
1353
  const cardEloData = await this.course.getCardEloData(cardIds);
1238
1354
  const scored = newCards.map((c, i) => {
@@ -1262,160 +1378,29 @@ var init_elo = __esm({
1262
1378
  }
1263
1379
  });
1264
1380
 
1265
- // src/core/navigators/filters/eloDistance.ts
1266
- var eloDistance_exports = {};
1267
- __export(eloDistance_exports, {
1268
- DEFAULT_HALF_LIFE: () => DEFAULT_HALF_LIFE,
1269
- DEFAULT_MAX_MULTIPLIER: () => DEFAULT_MAX_MULTIPLIER,
1270
- DEFAULT_MIN_MULTIPLIER: () => DEFAULT_MIN_MULTIPLIER,
1271
- createEloDistanceFilter: () => createEloDistanceFilter
1272
- });
1273
- function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
1274
- const normalizedDistance = distance / halfLife;
1275
- const decay = Math.exp(-(normalizedDistance * normalizedDistance));
1276
- return minMultiplier + (maxMultiplier - minMultiplier) * decay;
1277
- }
1278
- function createEloDistanceFilter(config) {
1279
- const halfLife = config?.halfLife ?? DEFAULT_HALF_LIFE;
1280
- const minMultiplier = config?.minMultiplier ?? DEFAULT_MIN_MULTIPLIER;
1281
- const maxMultiplier = config?.maxMultiplier ?? DEFAULT_MAX_MULTIPLIER;
1282
- return {
1283
- name: "ELO Distance Filter",
1284
- async transform(cards, context) {
1285
- const { course, userElo } = context;
1286
- const cardIds = cards.map((c) => c.cardId);
1287
- const cardElos = await course.getCardEloData(cardIds);
1288
- return cards.map((card, i) => {
1289
- const cardElo = cardElos[i]?.global?.score ?? 1e3;
1290
- const distance = Math.abs(cardElo - userElo);
1291
- const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
1292
- const newScore = card.score * multiplier;
1293
- const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
1294
- return {
1295
- ...card,
1296
- score: newScore,
1297
- provenance: [
1298
- ...card.provenance,
1299
- {
1300
- strategy: "eloDistance",
1301
- strategyName: "ELO Distance Filter",
1302
- strategyId: "ELO_DISTANCE_FILTER",
1303
- action,
1304
- score: newScore,
1305
- reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)}) \u2192 ${multiplier.toFixed(2)}x`
1306
- }
1307
- ]
1308
- };
1309
- });
1310
- }
1311
- };
1312
- }
1313
- var DEFAULT_HALF_LIFE, DEFAULT_MIN_MULTIPLIER, DEFAULT_MAX_MULTIPLIER;
1314
- var init_eloDistance = __esm({
1315
- "src/core/navigators/filters/eloDistance.ts"() {
1316
- "use strict";
1317
- DEFAULT_HALF_LIFE = 200;
1318
- DEFAULT_MIN_MULTIPLIER = 0.3;
1319
- DEFAULT_MAX_MULTIPLIER = 1;
1320
- }
1321
- });
1322
-
1323
- // src/core/navigators/filters/index.ts
1324
- var filters_exports = {};
1325
- __export(filters_exports, {
1326
- createEloDistanceFilter: () => createEloDistanceFilter
1327
- });
1328
- var init_filters = __esm({
1329
- "src/core/navigators/filters/index.ts"() {
1330
- "use strict";
1331
- init_eloDistance();
1332
- }
1333
- });
1334
-
1335
- // src/core/navigators/filters/types.ts
1336
- var types_exports = {};
1337
- var init_types = __esm({
1338
- "src/core/navigators/filters/types.ts"() {
1339
- "use strict";
1340
- }
1341
- });
1342
-
1343
- // src/core/navigators/generators/index.ts
1344
- var generators_exports = {};
1345
- var init_generators = __esm({
1346
- "src/core/navigators/generators/index.ts"() {
1347
- "use strict";
1348
- }
1349
- });
1350
-
1351
- // src/core/navigators/generators/types.ts
1352
- var types_exports2 = {};
1353
- var init_types2 = __esm({
1354
- "src/core/navigators/generators/types.ts"() {
1355
- "use strict";
1356
- }
1357
- });
1358
-
1359
- // src/core/navigators/hardcodedOrder.ts
1360
- var hardcodedOrder_exports = {};
1361
- __export(hardcodedOrder_exports, {
1362
- default: () => HardcodedOrderNavigator
1363
- });
1364
- var HardcodedOrderNavigator;
1365
- var init_hardcodedOrder = __esm({
1366
- "src/core/navigators/hardcodedOrder.ts"() {
1381
+ // src/core/navigators/generators/srs.ts
1382
+ var import_moment3, SRSNavigator;
1383
+ var init_srs = __esm({
1384
+ "src/core/navigators/generators/srs.ts"() {
1367
1385
  "use strict";
1386
+ import_moment3 = __toESM(require("moment"), 1);
1368
1387
  init_navigators();
1369
1388
  init_logger();
1370
- HardcodedOrderNavigator = class extends ContentNavigator {
1389
+ SRSNavigator = class extends ContentNavigator {
1371
1390
  /** Human-readable name for CardGenerator interface */
1372
1391
  name;
1373
- orderedCardIds = [];
1374
1392
  constructor(user, course, strategyData) {
1375
1393
  super(user, course, strategyData);
1376
- this.name = strategyData.name || "Hardcoded Order";
1377
- if (strategyData.serializedData) {
1378
- try {
1379
- this.orderedCardIds = JSON.parse(strategyData.serializedData);
1380
- } catch (e) {
1381
- logger.error("Failed to parse serializedData for HardcodedOrderNavigator", e);
1382
- }
1383
- }
1384
- }
1385
- async getPendingReviews() {
1386
- const reviews = await this.user.getPendingReviews(this.course.getCourseID());
1387
- return reviews.map((r) => {
1388
- return {
1389
- ...r,
1390
- contentSourceType: "course",
1391
- contentSourceID: this.course.getCourseID(),
1392
- cardID: r.cardId,
1393
- courseID: r.courseId,
1394
- reviewID: r._id,
1395
- status: "review"
1396
- };
1397
- });
1398
- }
1399
- async getNewCards(limit = 99) {
1400
- const activeCardIds = (await this.user.getActiveCards()).map((c) => c.cardID);
1401
- const newCardIds = this.orderedCardIds.filter((cardId) => !activeCardIds.includes(cardId));
1402
- const cardsToReturn = newCardIds.slice(0, limit);
1403
- return cardsToReturn.map((cardId) => {
1404
- return {
1405
- cardID: cardId,
1406
- courseID: this.course.getCourseID(),
1407
- contentSourceType: "course",
1408
- contentSourceID: this.course.getCourseID(),
1409
- status: "new"
1410
- };
1411
- });
1394
+ this.name = strategyData?.name || "SRS";
1412
1395
  }
1413
1396
  /**
1414
- * Get cards in hardcoded order with scores based on position.
1397
+ * Get review cards scored by urgency.
1398
+ *
1399
+ * Score formula combines:
1400
+ * - Relative overdueness: hoursOverdue / intervalHours
1401
+ * - Interval recency: exponential decay favoring shorter intervals
1415
1402
  *
1416
- * Earlier cards in the sequence get higher scores.
1417
- * Score formula: 1.0 - (position / totalCards) * 0.5
1418
- * This ensures scores range from 1.0 (first card) to 0.5+ (last card).
1403
+ * Cards not yet due are excluded (not scored as 0).
1419
1404
  *
1420
1405
  * This method supports both the legacy signature (limit only) and the
1421
1406
  * CardGenerator interface signature (limit, context).
@@ -1424,684 +1409,24 @@ var init_hardcodedOrder = __esm({
1424
1409
  * @param _context - Optional GeneratorContext (currently unused, but required for interface)
1425
1410
  */
1426
1411
  async getWeightedCards(limit, _context) {
1427
- const activeCardIds = (await this.user.getActiveCards()).map((c) => c.cardID);
1428
- const reviews = await this.getPendingReviews();
1429
- const newCardIds = this.orderedCardIds.filter((cardId) => !activeCardIds.includes(cardId));
1430
- const totalCards = newCardIds.length;
1431
- const scoredNew = newCardIds.slice(0, limit).map((cardId, index) => {
1432
- const position = index + 1;
1433
- const score = Math.max(0.5, 1 - index / totalCards * 0.5);
1412
+ if (!this.user || !this.course) {
1413
+ throw new Error("SRSNavigator requires user and course to be set");
1414
+ }
1415
+ const reviews = await this.user.getPendingReviews(this.course.getCourseID());
1416
+ const now = import_moment3.default.utc();
1417
+ const dueReviews = reviews.filter((r) => now.isAfter(import_moment3.default.utc(r.reviewTime)));
1418
+ const scored = dueReviews.map((review) => {
1419
+ const { score, reason } = this.computeUrgencyScore(review, now);
1434
1420
  return {
1435
- cardId,
1436
- courseId: this.course.getCourseID(),
1421
+ cardId: review.cardId,
1422
+ courseId: review.courseId,
1437
1423
  score,
1424
+ reviewID: review._id,
1438
1425
  provenance: [
1439
1426
  {
1440
- strategy: "hardcodedOrder",
1427
+ strategy: "srs",
1441
1428
  strategyName: this.strategyName || this.name,
1442
- strategyId: this.strategyId || "NAVIGATION_STRATEGY-hardcoded",
1443
- action: "generated",
1444
- score,
1445
- reason: `Position ${position} of ${totalCards} in fixed sequence, new card`
1446
- }
1447
- ]
1448
- };
1449
- });
1450
- const scoredReviews = reviews.map((r) => ({
1451
- cardId: r.cardID,
1452
- courseId: r.courseID,
1453
- score: 1,
1454
- provenance: [
1455
- {
1456
- strategy: "hardcodedOrder",
1457
- strategyName: this.strategyName || this.name,
1458
- strategyId: this.strategyId || "NAVIGATION_STRATEGY-hardcoded",
1459
- action: "generated",
1460
- score: 1,
1461
- reason: "Scheduled review, highest priority"
1462
- }
1463
- ]
1464
- }));
1465
- const all = [...scoredReviews, ...scoredNew];
1466
- all.sort((a, b) => b.score - a.score);
1467
- return all.slice(0, limit);
1468
- }
1469
- };
1470
- }
1471
- });
1472
-
1473
- // src/core/navigators/hierarchyDefinition.ts
1474
- var hierarchyDefinition_exports = {};
1475
- __export(hierarchyDefinition_exports, {
1476
- default: () => HierarchyDefinitionNavigator
1477
- });
1478
- var import_common7, DEFAULT_MIN_COUNT, HierarchyDefinitionNavigator;
1479
- var init_hierarchyDefinition = __esm({
1480
- "src/core/navigators/hierarchyDefinition.ts"() {
1481
- "use strict";
1482
- init_navigators();
1483
- import_common7 = require("@vue-skuilder/common");
1484
- DEFAULT_MIN_COUNT = 3;
1485
- HierarchyDefinitionNavigator = class extends ContentNavigator {
1486
- config;
1487
- _strategyData;
1488
- /** Human-readable name for CardFilter interface */
1489
- name;
1490
- constructor(user, course, _strategyData) {
1491
- super(user, course, _strategyData);
1492
- this._strategyData = _strategyData;
1493
- this.config = this.parseConfig(_strategyData.serializedData);
1494
- this.name = _strategyData.name || "Hierarchy Definition";
1495
- }
1496
- parseConfig(serializedData) {
1497
- try {
1498
- const parsed = JSON.parse(serializedData);
1499
- return {
1500
- prerequisites: parsed.prerequisites || {}
1501
- };
1502
- } catch {
1503
- return {
1504
- prerequisites: {}
1505
- };
1506
- }
1507
- }
1508
- /**
1509
- * Check if a specific prerequisite is satisfied
1510
- */
1511
- isPrerequisiteMet(prereq, userTagElo, userGlobalElo) {
1512
- if (!userTagElo) return false;
1513
- const minCount = prereq.masteryThreshold?.minCount ?? DEFAULT_MIN_COUNT;
1514
- if (userTagElo.count < minCount) return false;
1515
- if (prereq.masteryThreshold?.minElo !== void 0) {
1516
- return userTagElo.score >= prereq.masteryThreshold.minElo;
1517
- } else {
1518
- return userTagElo.score >= userGlobalElo;
1519
- }
1520
- }
1521
- /**
1522
- * Get the set of tags the user has mastered.
1523
- * A tag is "mastered" if it appears as a prerequisite somewhere and meets its threshold.
1524
- */
1525
- async getMasteredTags(context) {
1526
- const mastered = /* @__PURE__ */ new Set();
1527
- try {
1528
- const courseReg = await context.user.getCourseRegDoc(context.course.getCourseID());
1529
- const userElo = (0, import_common7.toCourseElo)(courseReg.elo);
1530
- for (const prereqs of Object.values(this.config.prerequisites)) {
1531
- for (const prereq of prereqs) {
1532
- const tagElo = userElo.tags[prereq.tag];
1533
- if (this.isPrerequisiteMet(prereq, tagElo, userElo.global.score)) {
1534
- mastered.add(prereq.tag);
1535
- }
1536
- }
1537
- }
1538
- } catch {
1539
- }
1540
- return mastered;
1541
- }
1542
- /**
1543
- * Get the set of tags that are unlocked (prerequisites met)
1544
- */
1545
- getUnlockedTags(masteredTags) {
1546
- const unlocked = /* @__PURE__ */ new Set();
1547
- for (const [tagId, prereqs] of Object.entries(this.config.prerequisites)) {
1548
- const allPrereqsMet = prereqs.every((prereq) => masteredTags.has(prereq.tag));
1549
- if (allPrereqsMet) {
1550
- unlocked.add(tagId);
1551
- }
1552
- }
1553
- return unlocked;
1554
- }
1555
- /**
1556
- * Check if a tag has prerequisites defined in config
1557
- */
1558
- hasPrerequisites(tagId) {
1559
- return tagId in this.config.prerequisites;
1560
- }
1561
- /**
1562
- * Check if a card is unlocked and generate reason.
1563
- */
1564
- async checkCardUnlock(cardId, course, unlockedTags, masteredTags) {
1565
- try {
1566
- const tagResponse = await course.getAppliedTags(cardId);
1567
- const cardTags = tagResponse.rows.map((row) => row.value?.name || row.key);
1568
- const lockedTags = cardTags.filter(
1569
- (tag) => this.hasPrerequisites(tag) && !unlockedTags.has(tag)
1570
- );
1571
- if (lockedTags.length === 0) {
1572
- const tagList = cardTags.length > 0 ? cardTags.join(", ") : "none";
1573
- return {
1574
- isUnlocked: true,
1575
- reason: `Prerequisites met, tags: ${tagList}`
1576
- };
1577
- }
1578
- const missingPrereqs = lockedTags.flatMap((tag) => {
1579
- const prereqs = this.config.prerequisites[tag] || [];
1580
- return prereqs.filter((p) => !masteredTags.has(p.tag)).map((p) => p.tag);
1581
- });
1582
- return {
1583
- isUnlocked: false,
1584
- reason: `Blocked: missing prerequisites ${missingPrereqs.join(", ")} for tags ${lockedTags.join(", ")}`
1585
- };
1586
- } catch {
1587
- return {
1588
- isUnlocked: true,
1589
- reason: "Prerequisites check skipped (tag lookup failed)"
1590
- };
1591
- }
1592
- }
1593
- /**
1594
- * CardFilter.transform implementation.
1595
- *
1596
- * Apply prerequisite gating to cards. Cards with locked tags receive score: 0.
1597
- */
1598
- async transform(cards, context) {
1599
- const masteredTags = await this.getMasteredTags(context);
1600
- const unlockedTags = this.getUnlockedTags(masteredTags);
1601
- const gated = [];
1602
- for (const card of cards) {
1603
- const { isUnlocked, reason } = await this.checkCardUnlock(
1604
- card.cardId,
1605
- context.course,
1606
- unlockedTags,
1607
- masteredTags
1608
- );
1609
- const finalScore = isUnlocked ? card.score : 0;
1610
- const action = isUnlocked ? "passed" : "penalized";
1611
- gated.push({
1612
- ...card,
1613
- score: finalScore,
1614
- provenance: [
1615
- ...card.provenance,
1616
- {
1617
- strategy: "hierarchyDefinition",
1618
- strategyName: this.strategyName || this.name,
1619
- strategyId: this.strategyId || "NAVIGATION_STRATEGY-hierarchy",
1620
- action,
1621
- score: finalScore,
1622
- reason
1623
- }
1624
- ]
1625
- });
1626
- }
1627
- return gated;
1628
- }
1629
- /**
1630
- * Legacy getWeightedCards - now throws as filters should not be used as generators.
1631
- *
1632
- * Use transform() via Pipeline instead.
1633
- */
1634
- async getWeightedCards(_limit) {
1635
- throw new Error(
1636
- "HierarchyDefinitionNavigator is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
1637
- );
1638
- }
1639
- // Legacy methods - stub implementations since filters don't generate cards
1640
- async getNewCards(_n) {
1641
- return [];
1642
- }
1643
- async getPendingReviews() {
1644
- return [];
1645
- }
1646
- };
1647
- }
1648
- });
1649
-
1650
- // src/core/navigators/interferenceMitigator.ts
1651
- var interferenceMitigator_exports = {};
1652
- __export(interferenceMitigator_exports, {
1653
- default: () => InterferenceMitigatorNavigator
1654
- });
1655
- var import_common8, DEFAULT_MIN_COUNT2, DEFAULT_MIN_ELAPSED_DAYS, DEFAULT_INTERFERENCE_DECAY, InterferenceMitigatorNavigator;
1656
- var init_interferenceMitigator = __esm({
1657
- "src/core/navigators/interferenceMitigator.ts"() {
1658
- "use strict";
1659
- init_navigators();
1660
- import_common8 = require("@vue-skuilder/common");
1661
- DEFAULT_MIN_COUNT2 = 10;
1662
- DEFAULT_MIN_ELAPSED_DAYS = 3;
1663
- DEFAULT_INTERFERENCE_DECAY = 0.8;
1664
- InterferenceMitigatorNavigator = class extends ContentNavigator {
1665
- config;
1666
- _strategyData;
1667
- /** Human-readable name for CardFilter interface */
1668
- name;
1669
- /** Precomputed map: tag -> set of { partner, decay } it interferes with */
1670
- interferenceMap;
1671
- constructor(user, course, _strategyData) {
1672
- super(user, course, _strategyData);
1673
- this._strategyData = _strategyData;
1674
- this.config = this.parseConfig(_strategyData.serializedData);
1675
- this.interferenceMap = this.buildInterferenceMap();
1676
- this.name = _strategyData.name || "Interference Mitigator";
1677
- }
1678
- parseConfig(serializedData) {
1679
- try {
1680
- const parsed = JSON.parse(serializedData);
1681
- let sets = parsed.interferenceSets || [];
1682
- if (sets.length > 0 && Array.isArray(sets[0])) {
1683
- sets = sets.map((tags) => ({ tags }));
1684
- }
1685
- return {
1686
- interferenceSets: sets,
1687
- maturityThreshold: {
1688
- minCount: parsed.maturityThreshold?.minCount ?? DEFAULT_MIN_COUNT2,
1689
- minElo: parsed.maturityThreshold?.minElo,
1690
- minElapsedDays: parsed.maturityThreshold?.minElapsedDays ?? DEFAULT_MIN_ELAPSED_DAYS
1691
- },
1692
- defaultDecay: parsed.defaultDecay ?? DEFAULT_INTERFERENCE_DECAY
1693
- };
1694
- } catch {
1695
- return {
1696
- interferenceSets: [],
1697
- maturityThreshold: {
1698
- minCount: DEFAULT_MIN_COUNT2,
1699
- minElapsedDays: DEFAULT_MIN_ELAPSED_DAYS
1700
- },
1701
- defaultDecay: DEFAULT_INTERFERENCE_DECAY
1702
- };
1703
- }
1704
- }
1705
- /**
1706
- * Build a map from each tag to its interference partners with decay coefficients.
1707
- * If tags A, B, C are in an interference group with decay 0.8, then:
1708
- * - A interferes with B (decay 0.8) and C (decay 0.8)
1709
- * - B interferes with A (decay 0.8) and C (decay 0.8)
1710
- * - etc.
1711
- */
1712
- buildInterferenceMap() {
1713
- const map = /* @__PURE__ */ new Map();
1714
- for (const group of this.config.interferenceSets) {
1715
- const decay = group.decay ?? this.config.defaultDecay ?? DEFAULT_INTERFERENCE_DECAY;
1716
- for (const tag of group.tags) {
1717
- if (!map.has(tag)) {
1718
- map.set(tag, []);
1719
- }
1720
- const partners = map.get(tag);
1721
- for (const other of group.tags) {
1722
- if (other !== tag) {
1723
- const existing = partners.find((p) => p.partner === other);
1724
- if (existing) {
1725
- existing.decay = Math.max(existing.decay, decay);
1726
- } else {
1727
- partners.push({ partner: other, decay });
1728
- }
1729
- }
1730
- }
1731
- }
1732
- }
1733
- return map;
1734
- }
1735
- /**
1736
- * Get the set of tags that are currently immature for this user.
1737
- * A tag is immature if the user has interacted with it but hasn't
1738
- * reached the maturity threshold.
1739
- */
1740
- async getImmatureTags(context) {
1741
- const immature = /* @__PURE__ */ new Set();
1742
- try {
1743
- const courseReg = await context.user.getCourseRegDoc(context.course.getCourseID());
1744
- const userElo = (0, import_common8.toCourseElo)(courseReg.elo);
1745
- const minCount = this.config.maturityThreshold?.minCount ?? DEFAULT_MIN_COUNT2;
1746
- const minElo = this.config.maturityThreshold?.minElo;
1747
- const minElapsedDays = this.config.maturityThreshold?.minElapsedDays ?? DEFAULT_MIN_ELAPSED_DAYS;
1748
- const minCountForElapsed = minElapsedDays * 2;
1749
- for (const [tagId, tagElo] of Object.entries(userElo.tags)) {
1750
- if (tagElo.count === 0) continue;
1751
- const belowCount = tagElo.count < minCount;
1752
- const belowElo = minElo !== void 0 && tagElo.score < minElo;
1753
- const belowElapsed = tagElo.count < minCountForElapsed;
1754
- if (belowCount || belowElo || belowElapsed) {
1755
- immature.add(tagId);
1756
- }
1757
- }
1758
- } catch {
1759
- }
1760
- return immature;
1761
- }
1762
- /**
1763
- * Get all tags that interfere with any immature tag, along with their decay coefficients.
1764
- * These are the tags we want to avoid introducing.
1765
- */
1766
- getTagsToAvoid(immatureTags) {
1767
- const avoid = /* @__PURE__ */ new Map();
1768
- for (const immatureTag of immatureTags) {
1769
- const partners = this.interferenceMap.get(immatureTag);
1770
- if (partners) {
1771
- for (const { partner, decay } of partners) {
1772
- if (!immatureTags.has(partner)) {
1773
- const existing = avoid.get(partner) ?? 0;
1774
- avoid.set(partner, Math.max(existing, decay));
1775
- }
1776
- }
1777
- }
1778
- }
1779
- return avoid;
1780
- }
1781
- /**
1782
- * Get tags for a single card
1783
- */
1784
- async getCardTags(cardId, course) {
1785
- try {
1786
- const tagResponse = await course.getAppliedTags(cardId);
1787
- return tagResponse.rows.map((row) => row.value?.name || row.key).filter(Boolean);
1788
- } catch {
1789
- return [];
1790
- }
1791
- }
1792
- /**
1793
- * Compute interference score reduction for a card.
1794
- * Returns: { multiplier, interfering tags, reason }
1795
- */
1796
- computeInterferenceEffect(cardTags, tagsToAvoid, immatureTags) {
1797
- if (tagsToAvoid.size === 0) {
1798
- return {
1799
- multiplier: 1,
1800
- interferingTags: [],
1801
- reason: "No interference detected"
1802
- };
1803
- }
1804
- let multiplier = 1;
1805
- const interferingTags = [];
1806
- for (const tag of cardTags) {
1807
- const decay = tagsToAvoid.get(tag);
1808
- if (decay !== void 0) {
1809
- interferingTags.push(tag);
1810
- multiplier *= 1 - decay;
1811
- }
1812
- }
1813
- if (interferingTags.length === 0) {
1814
- return {
1815
- multiplier: 1,
1816
- interferingTags: [],
1817
- reason: "No interference detected"
1818
- };
1819
- }
1820
- const causingTags = /* @__PURE__ */ new Set();
1821
- for (const tag of interferingTags) {
1822
- for (const immatureTag of immatureTags) {
1823
- const partners = this.interferenceMap.get(immatureTag);
1824
- if (partners?.some((p) => p.partner === tag)) {
1825
- causingTags.add(immatureTag);
1826
- }
1827
- }
1828
- }
1829
- const reason = `Interferes with immature tags ${Array.from(causingTags).join(", ")} (tags: ${interferingTags.join(", ")}, multiplier: ${multiplier.toFixed(2)})`;
1830
- return { multiplier, interferingTags, reason };
1831
- }
1832
- /**
1833
- * CardFilter.transform implementation.
1834
- *
1835
- * Apply interference-aware scoring. Cards with tags that interfere with
1836
- * immature learnings get reduced scores.
1837
- */
1838
- async transform(cards, context) {
1839
- const immatureTags = await this.getImmatureTags(context);
1840
- const tagsToAvoid = this.getTagsToAvoid(immatureTags);
1841
- const adjusted = [];
1842
- for (const card of cards) {
1843
- const cardTags = await this.getCardTags(card.cardId, context.course);
1844
- const { multiplier, reason } = this.computeInterferenceEffect(
1845
- cardTags,
1846
- tagsToAvoid,
1847
- immatureTags
1848
- );
1849
- const finalScore = card.score * multiplier;
1850
- const action = multiplier < 1 ? "penalized" : multiplier > 1 ? "boosted" : "passed";
1851
- adjusted.push({
1852
- ...card,
1853
- score: finalScore,
1854
- provenance: [
1855
- ...card.provenance,
1856
- {
1857
- strategy: "interferenceMitigator",
1858
- strategyName: this.strategyName || this.name,
1859
- strategyId: this.strategyId || "NAVIGATION_STRATEGY-interference",
1860
- action,
1861
- score: finalScore,
1862
- reason
1863
- }
1864
- ]
1865
- });
1866
- }
1867
- return adjusted;
1868
- }
1869
- /**
1870
- * Legacy getWeightedCards - now throws as filters should not be used as generators.
1871
- *
1872
- * Use transform() via Pipeline instead.
1873
- */
1874
- async getWeightedCards(_limit) {
1875
- throw new Error(
1876
- "InterferenceMitigatorNavigator is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
1877
- );
1878
- }
1879
- // Legacy methods - stub implementations since filters don't generate cards
1880
- async getNewCards(_n) {
1881
- return [];
1882
- }
1883
- async getPendingReviews() {
1884
- return [];
1885
- }
1886
- };
1887
- }
1888
- });
1889
-
1890
- // src/core/navigators/relativePriority.ts
1891
- var relativePriority_exports = {};
1892
- __export(relativePriority_exports, {
1893
- default: () => RelativePriorityNavigator
1894
- });
1895
- var DEFAULT_PRIORITY, DEFAULT_PRIORITY_INFLUENCE, DEFAULT_COMBINE_MODE, RelativePriorityNavigator;
1896
- var init_relativePriority = __esm({
1897
- "src/core/navigators/relativePriority.ts"() {
1898
- "use strict";
1899
- init_navigators();
1900
- DEFAULT_PRIORITY = 0.5;
1901
- DEFAULT_PRIORITY_INFLUENCE = 0.5;
1902
- DEFAULT_COMBINE_MODE = "max";
1903
- RelativePriorityNavigator = class extends ContentNavigator {
1904
- config;
1905
- _strategyData;
1906
- /** Human-readable name for CardFilter interface */
1907
- name;
1908
- constructor(user, course, _strategyData) {
1909
- super(user, course, _strategyData);
1910
- this._strategyData = _strategyData;
1911
- this.config = this.parseConfig(_strategyData.serializedData);
1912
- this.name = _strategyData.name || "Relative Priority";
1913
- }
1914
- parseConfig(serializedData) {
1915
- try {
1916
- const parsed = JSON.parse(serializedData);
1917
- return {
1918
- tagPriorities: parsed.tagPriorities || {},
1919
- defaultPriority: parsed.defaultPriority ?? DEFAULT_PRIORITY,
1920
- combineMode: parsed.combineMode ?? DEFAULT_COMBINE_MODE,
1921
- priorityInfluence: parsed.priorityInfluence ?? DEFAULT_PRIORITY_INFLUENCE
1922
- };
1923
- } catch {
1924
- return {
1925
- tagPriorities: {},
1926
- defaultPriority: DEFAULT_PRIORITY,
1927
- combineMode: DEFAULT_COMBINE_MODE,
1928
- priorityInfluence: DEFAULT_PRIORITY_INFLUENCE
1929
- };
1930
- }
1931
- }
1932
- /**
1933
- * Look up the priority for a tag.
1934
- */
1935
- getTagPriority(tagId) {
1936
- return this.config.tagPriorities[tagId] ?? this.config.defaultPriority ?? DEFAULT_PRIORITY;
1937
- }
1938
- /**
1939
- * Compute combined priority for a card based on its tags.
1940
- */
1941
- computeCardPriority(cardTags) {
1942
- if (cardTags.length === 0) {
1943
- return this.config.defaultPriority ?? DEFAULT_PRIORITY;
1944
- }
1945
- const priorities = cardTags.map((tag) => this.getTagPriority(tag));
1946
- switch (this.config.combineMode) {
1947
- case "max":
1948
- return Math.max(...priorities);
1949
- case "min":
1950
- return Math.min(...priorities);
1951
- case "average":
1952
- return priorities.reduce((sum, p) => sum + p, 0) / priorities.length;
1953
- default:
1954
- return Math.max(...priorities);
1955
- }
1956
- }
1957
- /**
1958
- * Compute boost factor based on priority.
1959
- *
1960
- * The formula: 1 + (priority - 0.5) * priorityInfluence
1961
- *
1962
- * This creates a multiplier centered around 1.0:
1963
- * - Priority 1.0 with influence 0.5 → 1.25 (25% boost)
1964
- * - Priority 0.5 with any influence → 1.00 (neutral)
1965
- * - Priority 0.0 with influence 0.5 → 0.75 (25% reduction)
1966
- */
1967
- computeBoostFactor(priority) {
1968
- const influence = this.config.priorityInfluence ?? DEFAULT_PRIORITY_INFLUENCE;
1969
- return 1 + (priority - 0.5) * influence;
1970
- }
1971
- /**
1972
- * Build human-readable reason for priority adjustment.
1973
- */
1974
- buildPriorityReason(cardTags, priority, boostFactor, finalScore) {
1975
- if (cardTags.length === 0) {
1976
- return `No tags, neutral priority (${priority.toFixed(2)})`;
1977
- }
1978
- const tagList = cardTags.slice(0, 3).join(", ");
1979
- const more = cardTags.length > 3 ? ` (+${cardTags.length - 3} more)` : "";
1980
- if (boostFactor === 1) {
1981
- return `Neutral priority (${priority.toFixed(2)}) for tags: ${tagList}${more}`;
1982
- } else if (boostFactor > 1) {
1983
- return `High-priority tags: ${tagList}${more} (priority ${priority.toFixed(2)} \u2192 boost ${boostFactor.toFixed(2)}x \u2192 ${finalScore.toFixed(2)})`;
1984
- } else {
1985
- return `Low-priority tags: ${tagList}${more} (priority ${priority.toFixed(2)} \u2192 reduce ${boostFactor.toFixed(2)}x \u2192 ${finalScore.toFixed(2)})`;
1986
- }
1987
- }
1988
- /**
1989
- * Get tags for a single card.
1990
- */
1991
- async getCardTags(cardId, course) {
1992
- try {
1993
- const tagResponse = await course.getAppliedTags(cardId);
1994
- return tagResponse.rows.map((r) => r.doc?.name).filter((x) => !!x);
1995
- } catch {
1996
- return [];
1997
- }
1998
- }
1999
- /**
2000
- * CardFilter.transform implementation.
2001
- *
2002
- * Apply priority-adjusted scoring. Cards with high-priority tags get boosted,
2003
- * cards with low-priority tags get reduced scores.
2004
- */
2005
- async transform(cards, context) {
2006
- const adjusted = await Promise.all(
2007
- cards.map(async (card) => {
2008
- const cardTags = await this.getCardTags(card.cardId, context.course);
2009
- const priority = this.computeCardPriority(cardTags);
2010
- const boostFactor = this.computeBoostFactor(priority);
2011
- const finalScore = Math.max(0, Math.min(1, card.score * boostFactor));
2012
- const action = boostFactor > 1 ? "boosted" : boostFactor < 1 ? "penalized" : "passed";
2013
- const reason = this.buildPriorityReason(cardTags, priority, boostFactor, finalScore);
2014
- return {
2015
- ...card,
2016
- score: finalScore,
2017
- provenance: [
2018
- ...card.provenance,
2019
- {
2020
- strategy: "relativePriority",
2021
- strategyName: this.strategyName || this.name,
2022
- strategyId: this.strategyId || "NAVIGATION_STRATEGY-priority",
2023
- action,
2024
- score: finalScore,
2025
- reason
2026
- }
2027
- ]
2028
- };
2029
- })
2030
- );
2031
- return adjusted;
2032
- }
2033
- /**
2034
- * Legacy getWeightedCards - now throws as filters should not be used as generators.
2035
- *
2036
- * Use transform() via Pipeline instead.
2037
- */
2038
- async getWeightedCards(_limit) {
2039
- throw new Error(
2040
- "RelativePriorityNavigator is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
2041
- );
2042
- }
2043
- // Legacy methods - stub implementations since filters don't generate cards
2044
- async getNewCards(_n) {
2045
- return [];
2046
- }
2047
- async getPendingReviews() {
2048
- return [];
2049
- }
2050
- };
2051
- }
2052
- });
2053
-
2054
- // src/core/navigators/srs.ts
2055
- var srs_exports = {};
2056
- __export(srs_exports, {
2057
- default: () => SRSNavigator
2058
- });
2059
- var import_moment3, SRSNavigator;
2060
- var init_srs = __esm({
2061
- "src/core/navigators/srs.ts"() {
2062
- "use strict";
2063
- import_moment3 = __toESM(require("moment"), 1);
2064
- init_navigators();
2065
- SRSNavigator = class extends ContentNavigator {
2066
- /** Human-readable name for CardGenerator interface */
2067
- name;
2068
- constructor(user, course, strategyData) {
2069
- super(user, course, strategyData);
2070
- this.name = strategyData?.name || "SRS";
2071
- }
2072
- /**
2073
- * Get review cards scored by urgency.
2074
- *
2075
- * Score formula combines:
2076
- * - Relative overdueness: hoursOverdue / intervalHours
2077
- * - Interval recency: exponential decay favoring shorter intervals
2078
- *
2079
- * Cards not yet due are excluded (not scored as 0).
2080
- *
2081
- * This method supports both the legacy signature (limit only) and the
2082
- * CardGenerator interface signature (limit, context).
2083
- *
2084
- * @param limit - Maximum number of cards to return
2085
- * @param _context - Optional GeneratorContext (currently unused, but required for interface)
2086
- */
2087
- async getWeightedCards(limit, _context) {
2088
- if (!this.user || !this.course) {
2089
- throw new Error("SRSNavigator requires user and course to be set");
2090
- }
2091
- const reviews = await this.user.getPendingReviews(this.course.getCourseID());
2092
- const now = import_moment3.default.utc();
2093
- const dueReviews = reviews.filter((r) => now.isAfter(import_moment3.default.utc(r.reviewTime)));
2094
- const scored = dueReviews.map((review) => {
2095
- const { score, reason } = this.computeUrgencyScore(review, now);
2096
- return {
2097
- cardId: review.cardId,
2098
- courseId: review.courseId,
2099
- score,
2100
- provenance: [
2101
- {
2102
- strategy: "srs",
2103
- strategyName: this.strategyName || this.name,
2104
- strategyId: this.strategyId || "NAVIGATION_STRATEGY-SRS-default",
1429
+ strategyId: this.strategyId || "NAVIGATION_STRATEGY-SRS-default",
2105
1430
  action: "generated",
2106
1431
  score,
2107
1432
  reason
@@ -2109,6 +1434,7 @@ var init_srs = __esm({
2109
1434
  ]
2110
1435
  };
2111
1436
  });
1437
+ logger.debug(`[srsNav] got ${scored.length} weighted cards`);
2112
1438
  return scored.sort((a, b) => b.score - a.score).slice(0, limit);
2113
1439
  }
2114
1440
  /**
@@ -2140,235 +1466,102 @@ var init_srs = __esm({
2140
1466
  const reason = `${Math.round(hoursOverdue)}h overdue (interval: ${Math.round(intervalHours)}h, relative: ${relativeOverdue.toFixed(2)}), recency: ${recencyFactor.toFixed(2)}, review`;
2141
1467
  return { score, reason };
2142
1468
  }
2143
- /**
2144
- * Get pending reviews in legacy format.
2145
- *
2146
- * Returns all pending reviews for the course, enriched with session item fields.
2147
- */
2148
- async getPendingReviews() {
2149
- if (!this.user || !this.course) {
2150
- throw new Error("SRSNavigator requires user and course to be set");
2151
- }
2152
- const reviews = await this.user.getPendingReviews(this.course.getCourseID());
2153
- return reviews.map((r) => ({
2154
- ...r,
2155
- contentSourceType: "course",
2156
- contentSourceID: this.course.getCourseID(),
2157
- cardID: r.cardId,
2158
- courseID: r.courseId,
2159
- qualifiedID: `${r.courseId}-${r.cardId}`,
2160
- reviewID: r._id,
2161
- status: "review"
2162
- }));
2163
- }
2164
- /**
2165
- * SRS does not generate new cards.
2166
- * Use ELONavigator or another generator for new cards.
2167
- */
2168
- async getNewCards(_n) {
2169
- return [];
2170
- }
2171
1469
  };
2172
1470
  }
2173
1471
  });
2174
1472
 
2175
- // import("./**/*") in src/core/navigators/index.ts
2176
- var globImport;
2177
- var init_ = __esm({
2178
- 'import("./**/*") in src/core/navigators/index.ts'() {
2179
- globImport = __glob({
2180
- "./CompositeGenerator.ts": () => Promise.resolve().then(() => (init_CompositeGenerator(), CompositeGenerator_exports)),
2181
- "./Pipeline.ts": () => Promise.resolve().then(() => (init_Pipeline(), Pipeline_exports)),
2182
- "./PipelineAssembler.ts": () => Promise.resolve().then(() => (init_PipelineAssembler(), PipelineAssembler_exports)),
2183
- "./elo.ts": () => Promise.resolve().then(() => (init_elo(), elo_exports)),
2184
- "./filters/eloDistance.ts": () => Promise.resolve().then(() => (init_eloDistance(), eloDistance_exports)),
2185
- "./filters/index.ts": () => Promise.resolve().then(() => (init_filters(), filters_exports)),
2186
- "./filters/types.ts": () => Promise.resolve().then(() => (init_types(), types_exports)),
2187
- "./generators/index.ts": () => Promise.resolve().then(() => (init_generators(), generators_exports)),
2188
- "./generators/types.ts": () => Promise.resolve().then(() => (init_types2(), types_exports2)),
2189
- "./hardcodedOrder.ts": () => Promise.resolve().then(() => (init_hardcodedOrder(), hardcodedOrder_exports)),
2190
- "./hierarchyDefinition.ts": () => Promise.resolve().then(() => (init_hierarchyDefinition(), hierarchyDefinition_exports)),
2191
- "./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports)),
2192
- "./interferenceMitigator.ts": () => Promise.resolve().then(() => (init_interferenceMitigator(), interferenceMitigator_exports)),
2193
- "./relativePriority.ts": () => Promise.resolve().then(() => (init_relativePriority(), relativePriority_exports)),
2194
- "./srs.ts": () => Promise.resolve().then(() => (init_srs(), srs_exports))
2195
- });
2196
- }
2197
- });
2198
-
2199
- // src/core/navigators/index.ts
2200
- var navigators_exports = {};
2201
- __export(navigators_exports, {
2202
- ContentNavigator: () => ContentNavigator,
2203
- NavigatorRole: () => NavigatorRole,
2204
- NavigatorRoles: () => NavigatorRoles,
2205
- Navigators: () => Navigators,
2206
- getCardOrigin: () => getCardOrigin,
2207
- isFilter: () => isFilter,
2208
- isGenerator: () => isGenerator
2209
- });
2210
- function getCardOrigin(card) {
2211
- if (card.provenance.length === 0) {
2212
- throw new Error("Card has no provenance - cannot determine origin");
2213
- }
2214
- const firstEntry = card.provenance[0];
2215
- const reason = firstEntry.reason.toLowerCase();
2216
- if (reason.includes("failed")) {
2217
- return "failed";
2218
- }
2219
- if (reason.includes("review")) {
2220
- return "review";
2221
- }
2222
- return "new";
2223
- }
2224
- function isGenerator(impl) {
2225
- return NavigatorRoles[impl] === "generator" /* GENERATOR */;
2226
- }
2227
- function isFilter(impl) {
2228
- return NavigatorRoles[impl] === "filter" /* FILTER */;
1473
+ // src/core/navigators/filters/eloDistance.ts
1474
+ function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
1475
+ const normalizedDistance = distance / halfLife;
1476
+ const decay = Math.exp(-(normalizedDistance * normalizedDistance));
1477
+ return minMultiplier + (maxMultiplier - minMultiplier) * decay;
2229
1478
  }
2230
- var Navigators, NavigatorRole, NavigatorRoles, ContentNavigator;
2231
- var init_navigators = __esm({
2232
- "src/core/navigators/index.ts"() {
2233
- "use strict";
2234
- init_logger();
2235
- init_();
2236
- Navigators = /* @__PURE__ */ ((Navigators2) => {
2237
- Navigators2["ELO"] = "elo";
2238
- Navigators2["SRS"] = "srs";
2239
- Navigators2["HARDCODED"] = "hardcodedOrder";
2240
- Navigators2["HIERARCHY"] = "hierarchyDefinition";
2241
- Navigators2["INTERFERENCE"] = "interferenceMitigator";
2242
- Navigators2["RELATIVE_PRIORITY"] = "relativePriority";
2243
- return Navigators2;
2244
- })(Navigators || {});
2245
- NavigatorRole = /* @__PURE__ */ ((NavigatorRole2) => {
2246
- NavigatorRole2["GENERATOR"] = "generator";
2247
- NavigatorRole2["FILTER"] = "filter";
2248
- return NavigatorRole2;
2249
- })(NavigatorRole || {});
2250
- NavigatorRoles = {
2251
- ["elo" /* ELO */]: "generator" /* GENERATOR */,
2252
- ["srs" /* SRS */]: "generator" /* GENERATOR */,
2253
- ["hardcodedOrder" /* HARDCODED */]: "generator" /* GENERATOR */,
2254
- ["hierarchyDefinition" /* HIERARCHY */]: "filter" /* FILTER */,
2255
- ["interferenceMitigator" /* INTERFERENCE */]: "filter" /* FILTER */,
2256
- ["relativePriority" /* RELATIVE_PRIORITY */]: "filter" /* FILTER */
2257
- };
2258
- ContentNavigator = class {
2259
- /** User interface for this navigation session */
2260
- user;
2261
- /** Course interface for this navigation session */
2262
- course;
2263
- /** Human-readable name for this strategy instance (from ContentNavigationStrategyData.name) */
2264
- strategyName;
2265
- /** Unique document ID for this strategy instance (from ContentNavigationStrategyData._id) */
2266
- strategyId;
2267
- /**
2268
- * Constructor for standard navigators.
2269
- * Call this from subclass constructors to initialize common fields.
2270
- *
2271
- * Note: CompositeGenerator doesn't use this pattern and should call super() without args.
2272
- */
2273
- constructor(user, course, strategyData) {
2274
- if (user && course && strategyData) {
2275
- this.user = user;
2276
- this.course = course;
2277
- this.strategyName = strategyData.name;
2278
- this.strategyId = strategyData._id;
2279
- }
2280
- }
2281
- /**
2282
- * Factory method to create navigator instances dynamically.
2283
- *
2284
- * @param user - User interface
2285
- * @param course - Course interface
2286
- * @param strategyData - Strategy configuration document
2287
- * @returns the runtime object used to steer a study session.
2288
- */
2289
- static async create(user, course, strategyData) {
2290
- const implementingClass = strategyData.implementingClass;
2291
- let NavigatorImpl;
2292
- const variations = [".ts", ".js", ""];
2293
- for (const ext of variations) {
2294
- try {
2295
- const module2 = await globImport(`./${implementingClass}${ext}`);
2296
- NavigatorImpl = module2.default;
2297
- break;
2298
- } catch (e) {
2299
- logger.debug(`Failed to load with extension ${ext}:`, e);
2300
- }
2301
- }
2302
- if (!NavigatorImpl) {
2303
- throw new Error(`Could not load navigator implementation for: ${implementingClass}`);
2304
- }
2305
- return new NavigatorImpl(user, course, strategyData);
2306
- }
2307
- /**
2308
- * Get cards with suitability scores and provenance trails.
2309
- *
2310
- * **This is the PRIMARY API for navigation strategies.**
2311
- *
2312
- * Returns cards ranked by suitability score (0-1). Higher scores indicate
2313
- * better candidates for presentation. Each card includes a provenance trail
2314
- * documenting how strategies contributed to the final score.
2315
- *
2316
- * ## For Generators
2317
- * Override this method to generate candidates and compute scores based on
2318
- * your strategy's logic (e.g., ELO proximity, review urgency). Create the
2319
- * initial provenance entry with action='generated'.
2320
- *
2321
- * ## Default Implementation
2322
- * The base class provides a backward-compatible default that:
2323
- * 1. Calls legacy getNewCards() and getPendingReviews()
2324
- * 2. Assigns score=1.0 to all cards
2325
- * 3. Creates minimal provenance from legacy methods
2326
- * 4. Returns combined results up to limit
2327
- *
2328
- * This allows existing strategies to work without modification while
2329
- * new strategies can override with proper scoring and provenance.
2330
- *
2331
- * @param limit - Maximum cards to return
2332
- * @returns Cards sorted by score descending, with provenance trails
2333
- */
2334
- async getWeightedCards(limit) {
2335
- const newCards = await this.getNewCards(limit);
2336
- const reviews = await this.getPendingReviews();
2337
- const weighted = [
2338
- ...newCards.map((c) => ({
2339
- cardId: c.cardID,
2340
- courseId: c.courseID,
2341
- score: 1,
2342
- provenance: [
2343
- {
2344
- strategy: "legacy",
2345
- strategyName: this.strategyName || "Legacy API",
2346
- strategyId: this.strategyId || "legacy-fallback",
2347
- action: "generated",
2348
- score: 1,
2349
- reason: "Generated via legacy getNewCards(), new card"
2350
- }
2351
- ]
2352
- })),
2353
- ...reviews.map((r) => ({
2354
- cardId: r.cardID,
2355
- courseId: r.courseID,
2356
- score: 1,
2357
- provenance: [
2358
- {
2359
- strategy: "legacy",
2360
- strategyName: this.strategyName || "Legacy API",
2361
- strategyId: this.strategyId || "legacy-fallback",
2362
- action: "generated",
2363
- score: 1,
2364
- reason: "Generated via legacy getPendingReviews(), review"
2365
- }
2366
- ]
2367
- }))
2368
- ];
2369
- return weighted.slice(0, limit);
2370
- }
2371
- };
1479
+ function createEloDistanceFilter(config) {
1480
+ const halfLife = config?.halfLife ?? DEFAULT_HALF_LIFE;
1481
+ const minMultiplier = config?.minMultiplier ?? DEFAULT_MIN_MULTIPLIER;
1482
+ const maxMultiplier = config?.maxMultiplier ?? DEFAULT_MAX_MULTIPLIER;
1483
+ return {
1484
+ name: "ELO Distance Filter",
1485
+ async transform(cards, context) {
1486
+ const { course, userElo } = context;
1487
+ const cardIds = cards.map((c) => c.cardId);
1488
+ const cardElos = await course.getCardEloData(cardIds);
1489
+ return cards.map((card, i) => {
1490
+ const cardElo = cardElos[i]?.global?.score ?? 1e3;
1491
+ const distance = Math.abs(cardElo - userElo);
1492
+ const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
1493
+ const newScore = card.score * multiplier;
1494
+ const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
1495
+ return {
1496
+ ...card,
1497
+ score: newScore,
1498
+ provenance: [
1499
+ ...card.provenance,
1500
+ {
1501
+ strategy: "eloDistance",
1502
+ strategyName: "ELO Distance Filter",
1503
+ strategyId: "ELO_DISTANCE_FILTER",
1504
+ action,
1505
+ score: newScore,
1506
+ reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)}) \u2192 ${multiplier.toFixed(2)}x`
1507
+ }
1508
+ ]
1509
+ };
1510
+ });
1511
+ }
1512
+ };
1513
+ }
1514
+ var DEFAULT_HALF_LIFE, DEFAULT_MIN_MULTIPLIER, DEFAULT_MAX_MULTIPLIER;
1515
+ var init_eloDistance = __esm({
1516
+ "src/core/navigators/filters/eloDistance.ts"() {
1517
+ "use strict";
1518
+ DEFAULT_HALF_LIFE = 200;
1519
+ DEFAULT_MIN_MULTIPLIER = 0.3;
1520
+ DEFAULT_MAX_MULTIPLIER = 1;
1521
+ }
1522
+ });
1523
+
1524
+ // src/core/navigators/defaults.ts
1525
+ function createDefaultEloStrategy(courseId) {
1526
+ return {
1527
+ _id: "NAVIGATION_STRATEGY-ELO-default",
1528
+ docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
1529
+ name: "ELO (default)",
1530
+ description: "Default ELO-based navigation strategy for new cards",
1531
+ implementingClass: "elo" /* ELO */,
1532
+ course: courseId,
1533
+ serializedData: ""
1534
+ };
1535
+ }
1536
+ function createDefaultSrsStrategy(courseId) {
1537
+ return {
1538
+ _id: "NAVIGATION_STRATEGY-SRS-default",
1539
+ docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
1540
+ name: "SRS (default)",
1541
+ description: "Default SRS-based navigation strategy for reviews",
1542
+ implementingClass: "srs" /* SRS */,
1543
+ course: courseId,
1544
+ serializedData: ""
1545
+ };
1546
+ }
1547
+ function createDefaultPipeline(user, course) {
1548
+ const courseId = course.getCourseID();
1549
+ const eloNavigator = new ELONavigator(user, course, createDefaultEloStrategy(courseId));
1550
+ const srsNavigator = new SRSNavigator(user, course, createDefaultSrsStrategy(courseId));
1551
+ const compositeGenerator = new CompositeGenerator([eloNavigator, srsNavigator]);
1552
+ const eloDistanceFilter = createEloDistanceFilter();
1553
+ return new Pipeline(compositeGenerator, [eloDistanceFilter], user, course);
1554
+ }
1555
+ var init_defaults = __esm({
1556
+ "src/core/navigators/defaults.ts"() {
1557
+ "use strict";
1558
+ init_navigators();
1559
+ init_Pipeline();
1560
+ init_CompositeGenerator();
1561
+ init_elo();
1562
+ init_srs();
1563
+ init_eloDistance();
1564
+ init_types_legacy();
2372
1565
  }
2373
1566
  });
2374
1567
 
@@ -2448,11 +1641,11 @@ ${JSON.stringify(config)}
2448
1641
  function isSuccessRow(row) {
2449
1642
  return "doc" in row && row.doc !== null && row.doc !== void 0;
2450
1643
  }
2451
- var import_common9, CourseDB;
1644
+ var import_common7, CourseDB;
2452
1645
  var init_courseDB = __esm({
2453
1646
  "src/impl/couch/courseDB.ts"() {
2454
1647
  "use strict";
2455
- import_common9 = require("@vue-skuilder/common");
1648
+ import_common7 = require("@vue-skuilder/common");
2456
1649
  init_couch();
2457
1650
  init_updateQueue();
2458
1651
  init_types_legacy();
@@ -2461,12 +1654,8 @@ var init_courseDB = __esm({
2461
1654
  init_courseAPI();
2462
1655
  init_courseLookupDB();
2463
1656
  init_navigators();
2464
- init_Pipeline();
2465
1657
  init_PipelineAssembler();
2466
- init_CompositeGenerator();
2467
- init_elo();
2468
- init_srs();
2469
- init_eloDistance();
1658
+ init_defaults();
2470
1659
  CourseDB = class {
2471
1660
  // private log(msg: string): void {
2472
1661
  // log(`CourseLog: ${this.id}\n ${msg}`);
@@ -2533,14 +1722,14 @@ var init_courseDB = __esm({
2533
1722
  docs.rows.forEach((r) => {
2534
1723
  if (isSuccessRow(r)) {
2535
1724
  if (r.doc && r.doc.elo) {
2536
- ret.push((0, import_common9.toCourseElo)(r.doc.elo));
1725
+ ret.push((0, import_common7.toCourseElo)(r.doc.elo));
2537
1726
  } else {
2538
1727
  logger.warn("no elo data for card: " + r.id);
2539
- ret.push((0, import_common9.blankCourseElo)());
1728
+ ret.push((0, import_common7.blankCourseElo)());
2540
1729
  }
2541
1730
  } else {
2542
1731
  logger.warn("no elo data for card: " + JSON.stringify(r));
2543
- ret.push((0, import_common9.blankCourseElo)());
1732
+ ret.push((0, import_common7.blankCourseElo)());
2544
1733
  }
2545
1734
  });
2546
1735
  return ret;
@@ -2602,15 +1791,6 @@ var init_courseDB = __esm({
2602
1791
  ret[r.id] = r.doc.id_displayable_data;
2603
1792
  }
2604
1793
  });
2605
- await Promise.all(
2606
- cards.rows.map((r) => {
2607
- return async () => {
2608
- if (isSuccessRow(r)) {
2609
- ret[r.id] = r.doc.id_displayable_data;
2610
- }
2611
- };
2612
- })
2613
- );
2614
1794
  return ret;
2615
1795
  }
2616
1796
  async getCardsByELO(elo, cardLimit) {
@@ -2695,6 +1875,28 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
2695
1875
  throw new Error(`Failed to find tags for card ${this.id}-${cardId}`);
2696
1876
  }
2697
1877
  }
1878
+ async getAppliedTagsBatch(cardIds) {
1879
+ if (cardIds.length === 0) {
1880
+ return /* @__PURE__ */ new Map();
1881
+ }
1882
+ const db = getCourseDB2(this.id);
1883
+ const result = await db.query("getTags", {
1884
+ keys: cardIds,
1885
+ include_docs: false
1886
+ });
1887
+ const tagsByCard = /* @__PURE__ */ new Map();
1888
+ for (const cardId of cardIds) {
1889
+ tagsByCard.set(cardId, []);
1890
+ }
1891
+ for (const row of result.rows) {
1892
+ const cardId = row.key;
1893
+ const tagName = row.value?.name;
1894
+ if (tagName && tagsByCard.has(cardId)) {
1895
+ tagsByCard.get(cardId).push(tagName);
1896
+ }
1897
+ }
1898
+ return tagsByCard;
1899
+ }
2698
1900
  async addTagToCard(cardId, tagId, updateELO) {
2699
1901
  return await addTagToCard(
2700
1902
  this.id,
@@ -2722,7 +1924,7 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
2722
1924
  async getCourseTagStubs() {
2723
1925
  return getCourseTagStubs(this.id);
2724
1926
  }
2725
- async addNote(codeCourse, shape, data, author, tags, uploads, elo = (0, import_common9.blankCourseElo)()) {
1927
+ async addNote(codeCourse, shape, data, author, tags, uploads, elo = (0, import_common7.blankCourseElo)()) {
2726
1928
  try {
2727
1929
  const resp = await addNote55(this.id, codeCourse, shape, data, author, tags, uploads, elo);
2728
1930
  if (resp.ok) {
@@ -2731,19 +1933,19 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
2731
1933
  `[courseDB.addNote] Note added but card creation failed: ${resp.cardCreationError}`
2732
1934
  );
2733
1935
  return {
2734
- status: import_common9.Status.error,
1936
+ status: import_common7.Status.error,
2735
1937
  message: `Note was added but no cards were created: ${resp.cardCreationError}`,
2736
1938
  id: resp.id
2737
1939
  };
2738
1940
  }
2739
1941
  return {
2740
- status: import_common9.Status.ok,
1942
+ status: import_common7.Status.ok,
2741
1943
  message: "",
2742
1944
  id: resp.id
2743
1945
  };
2744
1946
  } else {
2745
1947
  return {
2746
- status: import_common9.Status.error,
1948
+ status: import_common7.Status.error,
2747
1949
  message: "Unexpected error adding note"
2748
1950
  };
2749
1951
  }
@@ -2755,7 +1957,7 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
2755
1957
  message: ${err.message}`
2756
1958
  );
2757
1959
  return {
2758
- status: import_common9.Status.error,
1960
+ status: import_common7.Status.error,
2759
1961
  message: `Error adding note to course. ${e.reason || err.message}`
2760
1962
  };
2761
1963
  }
@@ -2822,7 +2024,7 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
2822
2024
  logger.debug(
2823
2025
  "[courseDB] No strategy documents found, using default Pipeline(Composite(ELO, SRS), [eloDistanceFilter])"
2824
2026
  );
2825
- return this.createDefaultPipeline(user);
2027
+ return createDefaultPipeline(user, this);
2826
2028
  }
2827
2029
  const assembler = new PipelineAssembler();
2828
2030
  const { pipeline, generatorStrategies, filterStrategies, warnings } = await assembler.assemble({
@@ -2835,7 +2037,7 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
2835
2037
  }
2836
2038
  if (!pipeline) {
2837
2039
  logger.debug("[courseDB] Pipeline assembly failed, using default pipeline");
2838
- return this.createDefaultPipeline(user);
2040
+ return createDefaultPipeline(user, this);
2839
2041
  }
2840
2042
  logger.debug(
2841
2043
  `[courseDB] Using assembled pipeline with ${generatorStrategies.length} generator(s) and ${filterStrategies.length} filter(s)`
@@ -2846,69 +2048,12 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
2846
2048
  throw e;
2847
2049
  }
2848
2050
  }
2849
- makeDefaultEloStrategy() {
2850
- return {
2851
- _id: "NAVIGATION_STRATEGY-ELO-default",
2852
- docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
2853
- name: "ELO (default)",
2854
- description: "Default ELO-based navigation strategy for new cards",
2855
- implementingClass: "elo" /* ELO */,
2856
- course: this.id,
2857
- serializedData: ""
2858
- };
2859
- }
2860
- makeDefaultSrsStrategy() {
2861
- return {
2862
- _id: "NAVIGATION_STRATEGY-SRS-default",
2863
- docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
2864
- name: "SRS (default)",
2865
- description: "Default SRS-based navigation strategy for reviews",
2866
- implementingClass: "srs" /* SRS */,
2867
- course: this.id,
2868
- serializedData: ""
2869
- };
2870
- }
2871
- /**
2872
- * Creates the default navigation pipeline for courses with no configured strategies.
2873
- *
2874
- * Default: Pipeline(Composite(ELO, SRS), [eloDistanceFilter])
2875
- * - ELO generator: scores new cards by skill proximity
2876
- * - SRS generator: scores reviews by overdueness and interval recency
2877
- * - ELO distance filter: penalizes cards far from user's current level
2878
- */
2879
- createDefaultPipeline(user) {
2880
- const eloNavigator = new ELONavigator(user, this, this.makeDefaultEloStrategy());
2881
- const srsNavigator = new SRSNavigator(user, this, this.makeDefaultSrsStrategy());
2882
- const compositeGenerator = new CompositeGenerator([eloNavigator, srsNavigator]);
2883
- const eloDistanceFilter = createEloDistanceFilter();
2884
- return new Pipeline(compositeGenerator, [eloDistanceFilter], user, this);
2885
- }
2886
2051
  ////////////////////////////////////
2887
2052
  // END NavigationStrategyManager implementation
2888
2053
  ////////////////////////////////////
2889
2054
  ////////////////////////////////////
2890
2055
  // StudyContentSource implementation
2891
2056
  ////////////////////////////////////
2892
- async getNewCards(limit = 99) {
2893
- const u = await this._getCurrentUser();
2894
- try {
2895
- const navigator = await this.createNavigator(u);
2896
- return navigator.getNewCards(limit);
2897
- } catch (e) {
2898
- logger.error(`[courseDB] Error in getNewCards: ${e}`);
2899
- throw e;
2900
- }
2901
- }
2902
- async getPendingReviews() {
2903
- const u = await this._getCurrentUser();
2904
- try {
2905
- const navigator = await this.createNavigator(u);
2906
- return navigator.getPendingReviews();
2907
- } catch (e) {
2908
- logger.error(`[courseDB] Error in getPendingReviews: ${e}`);
2909
- throw e;
2910
- }
2911
- }
2912
2057
  /**
2913
2058
  * Get cards with suitability scores for presentation.
2914
2059
  *
@@ -2940,7 +2085,7 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
2940
2085
  const courseDoc = (await u.getCourseRegistrationsDoc()).courses.find((c) => {
2941
2086
  return c.courseID === this.id;
2942
2087
  });
2943
- targetElo = (0, import_common9.EloToNumber)(courseDoc.elo);
2088
+ targetElo = (0, import_common7.EloToNumber)(courseDoc.elo);
2944
2089
  } catch {
2945
2090
  targetElo = 1e3;
2946
2091
  }
@@ -3147,79 +2292,27 @@ var init_classroomDB2 = __esm({
3147
2292
  setChangeFcn(f) {
3148
2293
  void this.userMessages.on("change", f);
3149
2294
  }
3150
- async getPendingReviews() {
3151
- const u = this._user;
3152
- return (await u.getPendingReviews()).filter((r) => r.scheduledFor === "classroom" && r.schedulingAgentId === this._id).map((r) => {
3153
- return {
3154
- ...r,
3155
- qualifiedID: `${r.courseId}-${r.cardId}`,
3156
- courseID: r.courseId,
3157
- cardID: r.cardId,
3158
- contentSourceType: "classroom",
3159
- contentSourceID: this._id,
3160
- reviewID: r._id,
3161
- status: "review"
3162
- };
3163
- });
3164
- }
3165
- async getNewCards() {
3166
- const activeCards = await this._user.getActiveCards();
3167
- const now = import_moment4.default.utc();
3168
- const assigned = await this.getAssignedContent();
3169
- const due = assigned.filter((c) => now.isAfter(import_moment4.default.utc(c.activeOn, REVIEW_TIME_FORMAT2)));
3170
- logger.info(`Due content: ${JSON.stringify(due)}`);
3171
- let ret = [];
3172
- for (let i = 0; i < due.length; i++) {
3173
- const content = due[i];
3174
- if (content.type === "course") {
3175
- const db = new CourseDB(content.courseID, async () => this._user);
3176
- ret = ret.concat(await db.getNewCards());
3177
- } else if (content.type === "tag") {
3178
- const tagDoc = await getTag(content.courseID, content.tagID);
3179
- ret = ret.concat(
3180
- tagDoc.taggedCards.map((c) => {
3181
- return {
3182
- courseID: content.courseID,
3183
- cardID: c,
3184
- qualifiedID: `${content.courseID}-${c}`,
3185
- contentSourceType: "classroom",
3186
- contentSourceID: this._id,
3187
- status: "new"
3188
- };
3189
- })
3190
- );
3191
- } else if (content.type === "card") {
3192
- ret.push(await getCourseDB2(content.courseID).get(content.cardID));
3193
- }
3194
- }
3195
- logger.info(
3196
- `New Cards from classroom ${this._cfg.name}: ${ret.map((c) => `${c.courseID}-${c.cardID}`)}`
3197
- );
3198
- return ret.filter((c) => {
3199
- if (activeCards.some((ac) => c.cardID === ac.cardID)) {
3200
- return false;
3201
- } else {
3202
- return true;
3203
- }
3204
- });
3205
- }
3206
2295
  /**
3207
2296
  * Get cards with suitability scores for presentation.
3208
2297
  *
3209
- * This implementation wraps the legacy getNewCards/getPendingReviews methods,
3210
- * assigning score=1.0 to all cards. StudentClassroomDB does not currently
3211
- * support pluggable navigation strategies.
2298
+ * Gathers new cards from assigned content (courses, tags, cards) and
2299
+ * pending reviews scheduled for this classroom. Assigns score=1.0 to all.
3212
2300
  *
3213
2301
  * @param limit - Maximum number of cards to return
3214
2302
  * @returns Cards sorted by score descending (all scores = 1.0)
3215
2303
  */
3216
2304
  async getWeightedCards(limit) {
3217
- const [newCards, reviews] = await Promise.all([this.getNewCards(), this.getPendingReviews()]);
3218
- const weighted = [
3219
- ...newCards.map((c) => ({
3220
- cardId: c.cardID,
3221
- courseId: c.courseID,
2305
+ const weighted = [];
2306
+ const allUserReviews = await this._user.getPendingReviews();
2307
+ const classroomReviews = allUserReviews.filter(
2308
+ (r) => r.scheduledFor === "classroom" && r.schedulingAgentId === this._id
2309
+ );
2310
+ for (const r of classroomReviews) {
2311
+ weighted.push({
2312
+ cardId: r.cardId,
2313
+ courseId: r.courseId,
3222
2314
  score: 1,
2315
+ reviewID: r._id,
3223
2316
  provenance: [
3224
2317
  {
3225
2318
  strategy: "classroom",
@@ -3227,27 +2320,84 @@ var init_classroomDB2 = __esm({
3227
2320
  strategyId: "CLASSROOM",
3228
2321
  action: "generated",
3229
2322
  score: 1,
3230
- reason: "Classroom legacy getNewCards(), new card"
2323
+ reason: "Classroom scheduled review"
3231
2324
  }
3232
2325
  ]
3233
- })),
3234
- ...reviews.map((r) => ({
3235
- cardId: r.cardID,
3236
- courseId: r.courseID,
3237
- score: 1,
3238
- provenance: [
3239
- {
3240
- strategy: "classroom",
3241
- strategyName: "Classroom",
3242
- strategyId: "CLASSROOM",
3243
- action: "generated",
3244
- score: 1,
3245
- reason: "Classroom legacy getPendingReviews(), review"
2326
+ });
2327
+ }
2328
+ const activeCards = await this._user.getActiveCards();
2329
+ const activeCardIds = new Set(activeCards.map((ac) => ac.cardID));
2330
+ const now = import_moment4.default.utc();
2331
+ const assigned = await this.getAssignedContent();
2332
+ const due = assigned.filter((c) => now.isAfter(import_moment4.default.utc(c.activeOn, REVIEW_TIME_FORMAT2)));
2333
+ logger.info(`[StudentClassroomDB] Due content: ${JSON.stringify(due)}`);
2334
+ for (const content of due) {
2335
+ if (content.type === "course") {
2336
+ const db = new CourseDB(content.courseID, async () => this._user);
2337
+ const courseCards = await db.getWeightedCards(limit);
2338
+ for (const card of courseCards) {
2339
+ if (!activeCardIds.has(card.cardId)) {
2340
+ weighted.push({
2341
+ ...card,
2342
+ provenance: [
2343
+ ...card.provenance,
2344
+ {
2345
+ strategy: "classroom",
2346
+ strategyName: "Classroom",
2347
+ strategyId: "CLASSROOM",
2348
+ action: "passed",
2349
+ score: card.score,
2350
+ reason: `Assigned via classroom from course ${content.courseID}`
2351
+ }
2352
+ ]
2353
+ });
3246
2354
  }
3247
- ]
3248
- }))
3249
- ];
3250
- return weighted.slice(0, limit);
2355
+ }
2356
+ } else if (content.type === "tag") {
2357
+ const tagDoc = await getTag(content.courseID, content.tagID);
2358
+ for (const cardId of tagDoc.taggedCards) {
2359
+ if (!activeCardIds.has(cardId)) {
2360
+ weighted.push({
2361
+ cardId,
2362
+ courseId: content.courseID,
2363
+ score: 1,
2364
+ provenance: [
2365
+ {
2366
+ strategy: "classroom",
2367
+ strategyName: "Classroom",
2368
+ strategyId: "CLASSROOM",
2369
+ action: "generated",
2370
+ score: 1,
2371
+ reason: `Classroom assigned tag: ${content.tagID}, new card`
2372
+ }
2373
+ ]
2374
+ });
2375
+ }
2376
+ }
2377
+ } else if (content.type === "card") {
2378
+ if (!activeCardIds.has(content.cardID)) {
2379
+ weighted.push({
2380
+ cardId: content.cardID,
2381
+ courseId: content.courseID,
2382
+ score: 1,
2383
+ provenance: [
2384
+ {
2385
+ strategy: "classroom",
2386
+ strategyName: "Classroom",
2387
+ strategyId: "CLASSROOM",
2388
+ action: "generated",
2389
+ score: 1,
2390
+ reason: "Classroom assigned card, new card"
2391
+ }
2392
+ ]
2393
+ });
2394
+ }
2395
+ }
2396
+ }
2397
+ logger.info(
2398
+ `[StudentClassroomDB] New cards from classroom ${this._cfg.name}: ${weighted.length} total (reviews + new)`
2399
+ );
2400
+ return weighted.sort((a, b) => b.score - a.score).slice(0, limit);
3251
2401
  }
3252
2402
  };
3253
2403
  }
@@ -3278,14 +2428,14 @@ var init_auth = __esm({
3278
2428
  });
3279
2429
 
3280
2430
  // src/impl/couch/CouchDBSyncStrategy.ts
3281
- var import_common10;
2431
+ var import_common8;
3282
2432
  var init_CouchDBSyncStrategy = __esm({
3283
2433
  "src/impl/couch/CouchDBSyncStrategy.ts"() {
3284
2434
  "use strict";
3285
2435
  init_factory();
3286
2436
  init_types_legacy();
3287
2437
  init_logger();
3288
- import_common10 = require("@vue-skuilder/common");
2438
+ import_common8 = require("@vue-skuilder/common");
3289
2439
  init_common();
3290
2440
  init_pouchdb_setup();
3291
2441
  init_couch();
@@ -3471,13 +2621,13 @@ async function dropUserFromClassroom(user, classID) {
3471
2621
  async function getUserClassrooms(user) {
3472
2622
  return getOrCreateClassroomRegistrationsDoc(user);
3473
2623
  }
3474
- var import_common12, import_moment6, log3, BaseUser, userCoursesDoc, userClassroomsDoc;
2624
+ var import_common10, import_moment6, log3, BaseUser, userCoursesDoc, userClassroomsDoc;
3475
2625
  var init_BaseUserDB = __esm({
3476
2626
  "src/impl/common/BaseUserDB.ts"() {
3477
2627
  "use strict";
3478
2628
  init_core();
3479
2629
  init_util();
3480
- import_common12 = require("@vue-skuilder/common");
2630
+ import_common10 = require("@vue-skuilder/common");
3481
2631
  import_moment6 = __toESM(require("moment"), 1);
3482
2632
  init_types_legacy();
3483
2633
  init_logger();
@@ -3527,7 +2677,7 @@ Currently logged-in as ${this._username}.`
3527
2677
  );
3528
2678
  }
3529
2679
  const result = await this.syncStrategy.createAccount(username, password);
3530
- if (result.status === import_common12.Status.ok) {
2680
+ if (result.status === import_common10.Status.ok) {
3531
2681
  log3(`Account created successfully, updating username to ${username}`);
3532
2682
  this._username = username;
3533
2683
  try {
@@ -3569,7 +2719,7 @@ Currently logged-in as ${this._username}.`
3569
2719
  async resetUserData() {
3570
2720
  if (this.syncStrategy.canAuthenticate()) {
3571
2721
  return {
3572
- status: import_common12.Status.error,
2722
+ status: import_common10.Status.error,
3573
2723
  error: "Reset user data is only available for local-only mode. Use logout instead for remote sync."
3574
2724
  };
3575
2725
  }
@@ -3588,11 +2738,11 @@ Currently logged-in as ${this._username}.`
3588
2738
  await localDB.bulkDocs(docsToDelete);
3589
2739
  }
3590
2740
  await this.init();
3591
- return { status: import_common12.Status.ok };
2741
+ return { status: import_common10.Status.ok };
3592
2742
  } catch (error) {
3593
2743
  logger.error("Failed to reset user data:", error);
3594
2744
  return {
3595
- status: import_common12.Status.error,
2745
+ status: import_common10.Status.error,
3596
2746
  error: error instanceof Error ? error.message : "Unknown error during reset"
3597
2747
  };
3598
2748
  }
@@ -4283,6 +3433,55 @@ Currently logged-in as ${this._username}.`
4283
3433
  async updateUserElo(courseId, elo) {
4284
3434
  return updateUserElo(this._username, courseId, elo);
4285
3435
  }
3436
+ async getStrategyState(courseId, strategyKey) {
3437
+ const docId = buildStrategyStateId(courseId, strategyKey);
3438
+ try {
3439
+ const doc = await this.localDB.get(docId);
3440
+ return doc.data;
3441
+ } catch (e) {
3442
+ const err = e;
3443
+ if (err.status === 404) {
3444
+ return null;
3445
+ }
3446
+ throw e;
3447
+ }
3448
+ }
3449
+ async putStrategyState(courseId, strategyKey, data) {
3450
+ const docId = buildStrategyStateId(courseId, strategyKey);
3451
+ let existingRev;
3452
+ try {
3453
+ const existing = await this.localDB.get(docId);
3454
+ existingRev = existing._rev;
3455
+ } catch (e) {
3456
+ const err = e;
3457
+ if (err.status !== 404) {
3458
+ throw e;
3459
+ }
3460
+ }
3461
+ const doc = {
3462
+ _id: docId,
3463
+ _rev: existingRev,
3464
+ docType: "STRATEGY_STATE" /* STRATEGY_STATE */,
3465
+ courseId,
3466
+ strategyKey,
3467
+ data,
3468
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
3469
+ };
3470
+ await this.localDB.put(doc);
3471
+ }
3472
+ async deleteStrategyState(courseId, strategyKey) {
3473
+ const docId = buildStrategyStateId(courseId, strategyKey);
3474
+ try {
3475
+ const doc = await this.localDB.get(docId);
3476
+ await this.localDB.remove(doc);
3477
+ } catch (e) {
3478
+ const err = e;
3479
+ if (err.status === 404) {
3480
+ return;
3481
+ }
3482
+ throw e;
3483
+ }
3484
+ }
4286
3485
  };
4287
3486
  userCoursesDoc = "CourseRegistrations";
4288
3487
  userClassroomsDoc = "ClassroomRegistrations";
@@ -4323,11 +3522,11 @@ var init_factory = __esm({
4323
3522
  });
4324
3523
 
4325
3524
  // src/study/TagFilteredContentSource.ts
4326
- var import_common14, TagFilteredContentSource;
3525
+ var import_common12, TagFilteredContentSource;
4327
3526
  var init_TagFilteredContentSource = __esm({
4328
3527
  "src/study/TagFilteredContentSource.ts"() {
4329
3528
  "use strict";
4330
- import_common14 = require("@vue-skuilder/common");
3529
+ import_common12 = require("@vue-skuilder/common");
4331
3530
  init_courseDB();
4332
3531
  init_logger();
4333
3532
  TagFilteredContentSource = class {
@@ -4403,108 +3602,71 @@ var init_TagFilteredContentSource = __esm({
4403
3602
  return finalCardIds;
4404
3603
  }
4405
3604
  /**
4406
- * Gets new cards that match the tag filter and are not already active for the user.
3605
+ * Get cards with suitability scores for presentation.
3606
+ *
3607
+ * Filters cards by tag inclusion/exclusion and assigns score=1.0 to all.
3608
+ * TagFilteredContentSource does not currently support pluggable navigation
3609
+ * strategies - it returns flat-scored candidates.
3610
+ *
3611
+ * @param limit - Maximum number of cards to return
3612
+ * @returns Cards sorted by score descending (all scores = 1.0)
4407
3613
  */
4408
- async getNewCards(limit) {
4409
- if (!(0, import_common14.hasActiveFilter)(this.filter)) {
4410
- logger.warn("[TagFilteredContentSource] getNewCards called with no active filter");
3614
+ async getWeightedCards(limit) {
3615
+ if (!(0, import_common12.hasActiveFilter)(this.filter)) {
3616
+ logger.warn("[TagFilteredContentSource] getWeightedCards called with no active filter");
4411
3617
  return [];
4412
3618
  }
4413
3619
  const eligibleCardIds = await this.resolveFilteredCardIds();
4414
3620
  const activeCards = await this.user.getActiveCards();
4415
3621
  const activeCardIds = new Set(activeCards.map((c) => c.cardID));
4416
- const newItems = [];
3622
+ const newCardWeighted = [];
4417
3623
  for (const cardId of eligibleCardIds) {
4418
3624
  if (!activeCardIds.has(cardId)) {
4419
- newItems.push({
4420
- courseID: this.courseId,
4421
- cardID: cardId,
4422
- contentSourceType: "course",
4423
- contentSourceID: this.courseId,
4424
- status: "new"
3625
+ newCardWeighted.push({
3626
+ cardId,
3627
+ courseId: this.courseId,
3628
+ score: 1,
3629
+ provenance: [
3630
+ {
3631
+ strategy: "tagFilter",
3632
+ strategyName: "Tag Filter",
3633
+ strategyId: "TAG_FILTER",
3634
+ action: "generated",
3635
+ score: 1,
3636
+ reason: `Tag-filtered new card (tags: ${this.filter.include.join(", ")})`
3637
+ }
3638
+ ]
4425
3639
  });
4426
3640
  }
4427
- if (limit !== void 0 && newItems.length >= limit) {
3641
+ if (newCardWeighted.length >= limit) {
4428
3642
  break;
4429
3643
  }
4430
3644
  }
4431
- logger.info(`[TagFilteredContentSource] Found ${newItems.length} new cards matching filter`);
4432
- return newItems;
4433
- }
4434
- /**
4435
- * Gets pending reviews, filtered to only include cards that match the tag filter.
4436
- */
4437
- async getPendingReviews() {
4438
- if (!(0, import_common14.hasActiveFilter)(this.filter)) {
4439
- logger.warn("[TagFilteredContentSource] getPendingReviews called with no active filter");
4440
- return [];
4441
- }
4442
- const eligibleCardIds = await this.resolveFilteredCardIds();
3645
+ logger.info(
3646
+ `[TagFilteredContentSource] Found ${newCardWeighted.length} new cards matching filter`
3647
+ );
4443
3648
  const allReviews = await this.user.getPendingReviews(this.courseId);
4444
- const filteredReviews = allReviews.filter((review) => {
4445
- return eligibleCardIds.has(review.cardId);
4446
- });
3649
+ const filteredReviews = allReviews.filter((review) => eligibleCardIds.has(review.cardId));
4447
3650
  logger.info(
4448
3651
  `[TagFilteredContentSource] Found ${filteredReviews.length} pending reviews matching filter (of ${allReviews.length} total)`
4449
3652
  );
4450
- return filteredReviews.map((r) => ({
4451
- ...r,
4452
- courseID: r.courseId,
4453
- cardID: r.cardId,
4454
- contentSourceType: "course",
4455
- contentSourceID: this.courseId,
3653
+ const reviewWeighted = filteredReviews.map((r) => ({
3654
+ cardId: r.cardId,
3655
+ courseId: r.courseId,
3656
+ score: 1,
4456
3657
  reviewID: r._id,
4457
- status: "review"
3658
+ provenance: [
3659
+ {
3660
+ strategy: "tagFilter",
3661
+ strategyName: "Tag Filter",
3662
+ strategyId: "TAG_FILTER",
3663
+ action: "generated",
3664
+ score: 1,
3665
+ reason: `Tag-filtered review (tags: ${this.filter.include.join(", ")})`
3666
+ }
3667
+ ]
4458
3668
  }));
4459
- }
4460
- /**
4461
- * Get cards with suitability scores for presentation.
4462
- *
4463
- * This implementation wraps the legacy getNewCards/getPendingReviews methods,
4464
- * assigning score=1.0 to all cards. TagFilteredContentSource does not currently
4465
- * support pluggable navigation strategies - it returns flat-scored candidates.
4466
- *
4467
- * @param limit - Maximum number of cards to return
4468
- * @returns Cards sorted by score descending (all scores = 1.0)
4469
- */
4470
- async getWeightedCards(limit) {
4471
- const [newCards, reviews] = await Promise.all([
4472
- this.getNewCards(limit),
4473
- this.getPendingReviews()
4474
- ]);
4475
- const weighted = [
4476
- ...reviews.map((r) => ({
4477
- cardId: r.cardID,
4478
- courseId: r.courseID,
4479
- score: 1,
4480
- provenance: [
4481
- {
4482
- strategy: "tagFilter",
4483
- strategyName: "Tag Filter",
4484
- strategyId: "TAG_FILTER",
4485
- action: "generated",
4486
- score: 1,
4487
- reason: `Tag-filtered review (tags: ${this.filter.include.join(", ")})`
4488
- }
4489
- ]
4490
- })),
4491
- ...newCards.map((c) => ({
4492
- cardId: c.cardID,
4493
- courseId: c.courseID,
4494
- score: 1,
4495
- provenance: [
4496
- {
4497
- strategy: "tagFilter",
4498
- strategyName: "Tag Filter",
4499
- strategyId: "TAG_FILTER",
4500
- action: "generated",
4501
- score: 1,
4502
- reason: `Tag-filtered new card (tags: ${this.filter.include.join(", ")})`
4503
- }
4504
- ]
4505
- }))
4506
- ];
4507
- return weighted.slice(0, limit);
3669
+ return [...reviewWeighted, ...newCardWeighted].slice(0, limit);
4508
3670
  }
4509
3671
  /**
4510
3672
  * Clears the cached resolved card IDs.
@@ -4538,19 +3700,19 @@ async function getStudySource(source, user) {
4538
3700
  if (source.type === "classroom") {
4539
3701
  return await StudentClassroomDB.factory(source.id, user);
4540
3702
  } else {
4541
- if ((0, import_common15.hasActiveFilter)(source.tagFilter)) {
3703
+ if ((0, import_common13.hasActiveFilter)(source.tagFilter)) {
4542
3704
  return new TagFilteredContentSource(source.id, source.tagFilter, user);
4543
3705
  }
4544
3706
  return getDataLayer().getCourseDB(source.id);
4545
3707
  }
4546
3708
  }
4547
- var import_common15;
3709
+ var import_common13;
4548
3710
  var init_contentSource = __esm({
4549
3711
  "src/core/interfaces/contentSource.ts"() {
4550
3712
  "use strict";
4551
3713
  init_factory();
4552
3714
  init_classroomDB2();
4553
- import_common15 = require("@vue-skuilder/common");
3715
+ import_common13 = require("@vue-skuilder/common");
4554
3716
  init_TagFilteredContentSource();
4555
3717
  }
4556
3718
  });
@@ -4596,6 +3758,16 @@ var init_user = __esm({
4596
3758
  }
4597
3759
  });
4598
3760
 
3761
+ // src/core/types/strategyState.ts
3762
+ function buildStrategyStateId(courseId, strategyKey) {
3763
+ return `STRATEGY_STATE::${courseId}::${strategyKey}`;
3764
+ }
3765
+ var init_strategyState = __esm({
3766
+ "src/core/types/strategyState.ts"() {
3767
+ "use strict";
3768
+ }
3769
+ });
3770
+
4599
3771
  // src/core/bulkImport/cardProcessor.ts
4600
3772
  async function importParsedCards(parsedCards, courseDB, config) {
4601
3773
  const results = [];
@@ -4664,7 +3836,7 @@ elo: ${elo}`;
4664
3836
  misc: {}
4665
3837
  } : void 0
4666
3838
  );
4667
- if (result.status === import_common16.Status.ok) {
3839
+ if (result.status === import_common14.Status.ok) {
4668
3840
  return {
4669
3841
  originalText,
4670
3842
  status: "success",
@@ -4708,17 +3880,17 @@ function validateProcessorConfig(config) {
4708
3880
  }
4709
3881
  return { isValid: true };
4710
3882
  }
4711
- var import_common16;
3883
+ var import_common14;
4712
3884
  var init_cardProcessor = __esm({
4713
3885
  "src/core/bulkImport/cardProcessor.ts"() {
4714
3886
  "use strict";
4715
- import_common16 = require("@vue-skuilder/common");
3887
+ import_common14 = require("@vue-skuilder/common");
4716
3888
  init_logger();
4717
3889
  }
4718
3890
  });
4719
3891
 
4720
3892
  // src/core/bulkImport/types.ts
4721
- var init_types3 = __esm({
3893
+ var init_types = __esm({
4722
3894
  "src/core/bulkImport/types.ts"() {
4723
3895
  "use strict";
4724
3896
  }
@@ -4729,7 +3901,7 @@ var init_bulkImport = __esm({
4729
3901
  "src/core/bulkImport/index.ts"() {
4730
3902
  "use strict";
4731
3903
  init_cardProcessor();
4732
- init_types3();
3904
+ init_types();
4733
3905
  }
4734
3906
  });
4735
3907
 
@@ -4745,6 +3917,7 @@ __export(core_exports, {
4745
3917
  NavigatorRoles: () => NavigatorRoles,
4746
3918
  Navigators: () => Navigators,
4747
3919
  areQuestionRecords: () => areQuestionRecords,
3920
+ buildStrategyStateId: () => buildStrategyStateId,
4748
3921
  docIsDeleted: () => docIsDeleted,
4749
3922
  getCardHistoryID: () => getCardHistoryID,
4750
3923
  getCardOrigin: () => getCardOrigin,
@@ -4764,6 +3937,7 @@ var init_core = __esm({
4764
3937
  init_interfaces();
4765
3938
  init_types_legacy();
4766
3939
  init_user();
3940
+ init_strategyState();
4767
3941
  init_Loggable();
4768
3942
  init_util();
4769
3943
  init_navigators();
@@ -4782,6 +3956,7 @@ init_core();
4782
3956
  NavigatorRoles,
4783
3957
  Navigators,
4784
3958
  areQuestionRecords,
3959
+ buildStrategyStateId,
4785
3960
  docIsDeleted,
4786
3961
  getCardHistoryID,
4787
3962
  getCardOrigin,