@vue-skuilder/db 0.2.29 → 0.2.31

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 (45) hide show
  1. package/dist/{contentSource-CqJmbOZN.d.ts → contentSource-DMduBjDC.d.ts} +19 -4
  2. package/dist/{contentSource-B6FrSihy.d.cts → contentSource-Doh1aVBJ.d.cts} +19 -4
  3. package/dist/core/index.d.cts +3 -3
  4. package/dist/core/index.d.ts +3 -3
  5. package/dist/core/index.js +128 -82
  6. package/dist/core/index.js.map +1 -1
  7. package/dist/core/index.mjs +80 -33
  8. package/dist/core/index.mjs.map +1 -1
  9. package/dist/{dataLayerProvider-DUxDqMtZ.d.cts → dataLayerProvider-BW1CBAbb.d.cts} +1 -1
  10. package/dist/{dataLayerProvider-B9_UCvkR.d.ts → dataLayerProvider-Cxfe4nSK.d.ts} +1 -1
  11. package/dist/diagnostics/index.d.cts +18 -3
  12. package/dist/diagnostics/index.d.ts +18 -3
  13. package/dist/diagnostics/index.js +159 -135
  14. package/dist/diagnostics/index.js.map +1 -1
  15. package/dist/diagnostics/index.mjs +156 -135
  16. package/dist/diagnostics/index.mjs.map +1 -1
  17. package/dist/impl/couch/index.d.cts +2 -2
  18. package/dist/impl/couch/index.d.ts +2 -2
  19. package/dist/impl/couch/index.js +132 -86
  20. package/dist/impl/couch/index.js.map +1 -1
  21. package/dist/impl/couch/index.mjs +80 -33
  22. package/dist/impl/couch/index.mjs.map +1 -1
  23. package/dist/impl/static/index.d.cts +2 -2
  24. package/dist/impl/static/index.d.ts +2 -2
  25. package/dist/impl/static/index.js +119 -73
  26. package/dist/impl/static/index.js.map +1 -1
  27. package/dist/impl/static/index.mjs +80 -33
  28. package/dist/impl/static/index.mjs.map +1 -1
  29. package/dist/index.d.cts +3 -3
  30. package/dist/index.d.ts +3 -3
  31. package/dist/index.js +181 -116
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.mjs +105 -39
  34. package/dist/index.mjs.map +1 -1
  35. package/package.json +3 -3
  36. package/src/core/navigators/PipelineDebugger.ts +42 -23
  37. package/src/core/navigators/filters/eloDistance.ts +79 -21
  38. package/src/core/navigators/generators/elo.ts +8 -2
  39. package/src/core/navigators/generators/prescribed.ts +7 -5
  40. package/src/core/types/studySession.ts +12 -1
  41. package/src/diagnostics/derive.ts +5 -2
  42. package/src/diagnostics/pipeline.ts +28 -0
  43. package/src/diagnostics/text.ts +11 -4
  44. package/src/study/SessionController.ts +3 -1
  45. package/src/study/services/EloService.ts +33 -6
@@ -481,13 +481,12 @@ function clearRunHistory() {
481
481
  _pendingRuns = [];
482
482
  }
483
483
  function getOrigin(card) {
484
- const firstEntry = card.provenance[0];
485
- if (!firstEntry) return "unknown";
486
- const reason = firstEntry.reason?.toLowerCase() || "";
487
- const strategy = firstEntry.strategy?.toLowerCase() || "";
488
- if (reason.includes("new card") || strategy.includes("elo")) return "new";
489
- if (reason.includes("review") || strategy.includes("srs")) return "review";
490
- return "unknown";
484
+ return card.reviewID ? "review" : "new";
485
+ }
486
+ function requiredBy(card) {
487
+ return card.provenance.find(
488
+ (p) => p.strategy === "ephemeralHint" && p.score === Number.POSITIVE_INFINITY
489
+ )?.strategyName;
491
490
  }
492
491
  function captureRun(report) {
493
492
  const fullReport = {
@@ -511,17 +510,23 @@ function parseCardElo(provenance) {
511
510
  }
512
511
  function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints, scoredCards, regulators) {
513
512
  const selectedIds = new Set(selectedCards.map((c) => c.cardId));
514
- const toReport = (card) => ({
515
- cardId: card.cardId,
516
- courseId: card.courseId,
517
- origin: getOrigin(card),
518
- generator: card.provenance[0]?.strategyName || card.provenance[0]?.strategy,
519
- finalScore: card.score,
520
- cardElo: card.cardElo ?? parseCardElo(card.provenance),
521
- provenance: card.provenance,
522
- tags: card.tags,
523
- selected: selectedIds.has(card.cardId)
524
- });
513
+ const toReport = (card) => {
514
+ const required = requiredBy(card);
515
+ const first = card.provenance[0];
516
+ const generator = first && first.strategy !== "ephemeralHint" ? first.strategyName || first.strategy : void 0;
517
+ return {
518
+ cardId: card.cardId,
519
+ courseId: card.courseId,
520
+ origin: getOrigin(card),
521
+ ...generator ? { generator } : {},
522
+ ...required ? { required } : {},
523
+ finalScore: card.score,
524
+ cardElo: card.cardElo ?? parseCardElo(card.provenance),
525
+ provenance: card.provenance,
526
+ tags: card.tags,
527
+ selected: selectedIds.has(card.cardId)
528
+ };
529
+ };
525
530
  const selectedReported = [];
526
531
  const nearMissReported = [];
527
532
  const discardedTailCards = [];
@@ -1650,10 +1655,14 @@ var init_elo = __esm({
1650
1655
  const userElo = toCourseElo2(courseReg.elo);
1651
1656
  userGlobalElo = userElo.global.score;
1652
1657
  }
1653
- const activeCards = await this.user.getActiveCards();
1658
+ const [activeCards, seenCards] = await Promise.all([
1659
+ this.user.getActiveCards(),
1660
+ this.user.getSeenCards(this.course.getCourseID()).catch(() => [])
1661
+ ]);
1662
+ const notNew = /* @__PURE__ */ new Set([...activeCards.map((ac) => ac.cardID), ...seenCards]);
1654
1663
  const newCards = (await this.course.getCardsCenteredAtELO(
1655
1664
  { limit, elo: "user" },
1656
- (c) => !activeCards.some((ac) => c.cardID === ac.cardID)
1665
+ (c) => !notNew.has(c.cardID)
1657
1666
  )).map((c) => ({ ...c, status: "new" }));
1658
1667
  const scored = newCards.map((c) => {
1659
1668
  const cardElo = c.elo ?? 1e3;
@@ -1706,6 +1715,7 @@ __export(prescribed_exports, {
1706
1715
  default: () => PrescribedCardsGenerator,
1707
1716
  unmetIntroExposeTags: () => unmetIntroExposeTags
1708
1717
  });
1718
+ import { tagRole, withTagRole } from "@vue-skuilder/common";
1709
1719
  function dedupe(arr) {
1710
1720
  return [...new Set(arr)];
1711
1721
  }
@@ -1746,11 +1756,11 @@ function formatAge(ms) {
1746
1756
  }
1747
1757
  function unmetIntroExposeTags(tags, userTagElo, minCount) {
1748
1758
  if (minCount <= 0) return [];
1749
- const exposeTags = new Set(tags.filter((tag) => tag.startsWith("gpc:expose:")));
1759
+ const exposeTags = new Set(tags.filter((tag) => tagRole(tag) === "expose"));
1750
1760
  for (const tag of tags) {
1751
- if (!tag.startsWith("gpc:intro:")) continue;
1752
- const suffix = tag.slice("gpc:intro:".length);
1753
- if (suffix) exposeTags.add(`gpc:expose:${suffix}`);
1761
+ if (tagRole(tag) !== "intro") continue;
1762
+ const expose = withTagRole(tag, "expose");
1763
+ if (expose) exposeTags.add(expose);
1754
1764
  }
1755
1765
  return [...exposeTags].filter((tag) => {
1756
1766
  const tagElo = userTagElo[tag];
@@ -2949,8 +2959,10 @@ __export(eloDistance_exports, {
2949
2959
  DEFAULT_ELO_DISTANCE_CONFIG: () => DEFAULT_ELO_DISTANCE_CONFIG,
2950
2960
  createEloDistanceFilter: () => createEloDistanceFilter,
2951
2961
  default: () => EloDistanceFilter,
2962
+ mountMultiDimEloToggle: () => mountMultiDimEloToggle,
2952
2963
  tagAwareGap: () => tagAwareGap
2953
2964
  });
2965
+ import { COUNT_ONLY_SCORE, isCountOnlyTag } from "@vue-skuilder/common";
2954
2966
  function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
2955
2967
  const normalizedDistance = distance / halfLife;
2956
2968
  const decay = Math.exp(-(normalizedDistance * normalizedDistance));
@@ -2959,12 +2971,43 @@ function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
2959
2971
  function resolveConfig(config) {
2960
2972
  return { ...DEFAULT_ELO_DISTANCE_CONFIG, ...config };
2961
2973
  }
2974
+ function readMultiDimElo() {
2975
+ try {
2976
+ return typeof localStorage !== "undefined" && localStorage.getItem(MULTI_DIM_ELO_KEY) === "true";
2977
+ } catch {
2978
+ return false;
2979
+ }
2980
+ }
2981
+ function mountMultiDimEloToggle() {
2982
+ if (typeof window === "undefined") return;
2983
+ const win = window;
2984
+ win.skuilder = win.skuilder || {};
2985
+ Object.defineProperty(win.skuilder, "multiDimElo", {
2986
+ configurable: true,
2987
+ enumerable: true,
2988
+ get: () => multiDimElo,
2989
+ set: (on) => {
2990
+ multiDimElo = on === true;
2991
+ try {
2992
+ if (multiDimElo) localStorage.setItem(MULTI_DIM_ELO_KEY, "true");
2993
+ else localStorage.removeItem(MULTI_DIM_ELO_KEY);
2994
+ } catch (e) {
2995
+ logger.warn(`[EloDistance] multiDimElo not persisted (localStorage unavailable): ${e}`);
2996
+ }
2997
+ logger.info(
2998
+ `[EloDistance] multiDimElo ${multiDimElo ? "on: tag-aware" : "off: per strategy config"} ELO distance from the next replan`
2999
+ );
3000
+ }
3001
+ });
3002
+ }
2962
3003
  function tagAwareGap(cardTags, cardElo, userElo, minTagCount) {
2963
3004
  const globalGap = cardElo.global.score - userElo.global.score;
2964
3005
  const tags = [];
2965
3006
  for (const tag of cardTags) {
2966
3007
  const user = userElo.tags[tag];
2967
- if (!user || user.score === COUNT_ONLY_SENTINEL || user.count < minTagCount) continue;
3008
+ if (isCountOnlyTag(tag) || !user || user.score === COUNT_ONLY_SCORE || user.count < minTagCount) {
3009
+ continue;
3010
+ }
2968
3011
  const card = cardElo.tags[tag]?.score ?? cardElo.global.score;
2969
3012
  tags.push({
2970
3013
  tag,
@@ -2986,7 +3029,7 @@ function tagReason(tags, globalGap) {
2986
3029
  async function applyEloDistance(cards, context, config, source) {
2987
3030
  const { course, userElo, userCourseElo } = context;
2988
3031
  const { halfLife, minMultiplier, maxMultiplier } = config;
2989
- const tagAware = config.tagAware && userCourseElo !== void 0;
3032
+ const tagAware = (config.tagAware || multiDimElo) && userCourseElo !== void 0;
2990
3033
  const missing = cards.filter((c) => tagAware || c.cardElo === void 0).map((c) => c.cardId);
2991
3034
  const fetched = /* @__PURE__ */ new Map();
2992
3035
  if (missing.length > 0) {
@@ -3000,10 +3043,10 @@ async function applyEloDistance(cards, context, config, source) {
3000
3043
  const cardElo = full?.global?.score ?? card.cardElo ?? DEFAULT_CARD_ELO;
3001
3044
  let distance = Math.abs(cardElo - userElo);
3002
3045
  let how = "";
3003
- if (tagAware && full) {
3004
- const t = tagAwareGap(card.tags ?? [], full, userCourseElo, config.minTagCount);
3005
- distance = Math.abs(t.gap);
3006
- if (t.tags.length > 0) how = tagReason(t.tags, t.globalGap);
3046
+ if (tagAware) {
3047
+ const t = full ? tagAwareGap(card.tags ?? [], full, userCourseElo, config.minTagCount) : void 0;
3048
+ if (t) distance = Math.abs(t.gap);
3049
+ how = t?.tags.length ? `, tag-aware${tagReason(t.tags, t.globalGap)}` : ", tag-aware: global (no shared tags)";
3007
3050
  }
3008
3051
  const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
3009
3052
  const newScore = card.score * multiplier;
@@ -3036,21 +3079,24 @@ function createEloDistanceFilter(config) {
3036
3079
  transform: (cards, context) => applyEloDistance(cards, context, resolved, source)
3037
3080
  };
3038
3081
  }
3039
- var DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, COUNT_ONLY_SENTINEL, DEFAULT_CARD_ELO, EloDistanceFilter;
3082
+ var DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, DEFAULT_CARD_ELO, MULTI_DIM_ELO_KEY, multiDimElo, EloDistanceFilter;
3040
3083
  var init_eloDistance = __esm({
3041
3084
  "src/core/navigators/filters/eloDistance.ts"() {
3042
3085
  "use strict";
3043
3086
  init_navigators();
3087
+ init_logger();
3044
3088
  DEFAULT_ELO_DISTANCE_CONFIG = {
3045
3089
  halfLife: 300,
3046
3090
  minMultiplier: 0.05,
3047
3091
  maxMultiplier: 1,
3048
- tagAware: true,
3092
+ tagAware: false,
3049
3093
  minTagCount: 3
3050
3094
  };
3051
3095
  TAG_CONFIDENCE_HALF = 10;
3052
- COUNT_ONLY_SENTINEL = -1;
3053
3096
  DEFAULT_CARD_ELO = 1e3;
3097
+ MULTI_DIM_ELO_KEY = "skuilder:multiDimElo";
3098
+ multiDimElo = readMultiDimElo();
3099
+ mountMultiDimEloToggle();
3054
3100
  EloDistanceFilter = class _EloDistanceFilter extends ContentNavigator {
3055
3101
  name;
3056
3102
  /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
@@ -5718,6 +5764,7 @@ var init_tagRecent = __esm({
5718
5764
  import {
5719
5765
  adjustCourseScores,
5720
5766
  adjustCourseScoresPerTag,
5767
+ isCountOnlyTag as isCountOnlyTag2,
5721
5768
  toCourseElo as toCourseElo7
5722
5769
  } from "@vue-skuilder/common";
5723
5770
  var init_EloService = __esm({