@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
@@ -748,13 +748,12 @@ function clearRunHistory() {
748
748
  _pendingRuns = [];
749
749
  }
750
750
  function getOrigin(card) {
751
- const firstEntry = card.provenance[0];
752
- if (!firstEntry) return "unknown";
753
- const reason = firstEntry.reason?.toLowerCase() || "";
754
- const strategy = firstEntry.strategy?.toLowerCase() || "";
755
- if (reason.includes("new card") || strategy.includes("elo")) return "new";
756
- if (reason.includes("review") || strategy.includes("srs")) return "review";
757
- return "unknown";
751
+ return card.reviewID ? "review" : "new";
752
+ }
753
+ function requiredBy(card) {
754
+ return card.provenance.find(
755
+ (p) => p.strategy === "ephemeralHint" && p.score === Number.POSITIVE_INFINITY
756
+ )?.strategyName;
758
757
  }
759
758
  function captureRun(report) {
760
759
  const fullReport = {
@@ -778,17 +777,23 @@ function parseCardElo(provenance) {
778
777
  }
779
778
  function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints, scoredCards, regulators) {
780
779
  const selectedIds = new Set(selectedCards.map((c) => c.cardId));
781
- const toReport = (card) => ({
782
- cardId: card.cardId,
783
- courseId: card.courseId,
784
- origin: getOrigin(card),
785
- generator: card.provenance[0]?.strategyName || card.provenance[0]?.strategy,
786
- finalScore: card.score,
787
- cardElo: card.cardElo ?? parseCardElo(card.provenance),
788
- provenance: card.provenance,
789
- tags: card.tags,
790
- selected: selectedIds.has(card.cardId)
791
- });
780
+ const toReport = (card) => {
781
+ const required = requiredBy(card);
782
+ const first = card.provenance[0];
783
+ const generator = first && first.strategy !== "ephemeralHint" ? first.strategyName || first.strategy : void 0;
784
+ return {
785
+ cardId: card.cardId,
786
+ courseId: card.courseId,
787
+ origin: getOrigin(card),
788
+ ...generator ? { generator } : {},
789
+ ...required ? { required } : {},
790
+ finalScore: card.score,
791
+ cardElo: card.cardElo ?? parseCardElo(card.provenance),
792
+ provenance: card.provenance,
793
+ tags: card.tags,
794
+ selected: selectedIds.has(card.cardId)
795
+ };
796
+ };
792
797
  const selectedReported = [];
793
798
  const nearMissReported = [];
794
799
  const discardedTailCards = [];
@@ -1917,10 +1922,14 @@ var init_elo = __esm({
1917
1922
  const userElo = toCourseElo2(courseReg.elo);
1918
1923
  userGlobalElo = userElo.global.score;
1919
1924
  }
1920
- const activeCards = await this.user.getActiveCards();
1925
+ const [activeCards, seenCards] = await Promise.all([
1926
+ this.user.getActiveCards(),
1927
+ this.user.getSeenCards(this.course.getCourseID()).catch(() => [])
1928
+ ]);
1929
+ const notNew = /* @__PURE__ */ new Set([...activeCards.map((ac) => ac.cardID), ...seenCards]);
1921
1930
  const newCards = (await this.course.getCardsCenteredAtELO(
1922
1931
  { limit, elo: "user" },
1923
- (c) => !activeCards.some((ac) => c.cardID === ac.cardID)
1932
+ (c) => !notNew.has(c.cardID)
1924
1933
  )).map((c) => ({ ...c, status: "new" }));
1925
1934
  const scored = newCards.map((c) => {
1926
1935
  const cardElo = c.elo ?? 1e3;
@@ -1973,6 +1982,7 @@ __export(prescribed_exports, {
1973
1982
  default: () => PrescribedCardsGenerator,
1974
1983
  unmetIntroExposeTags: () => unmetIntroExposeTags
1975
1984
  });
1985
+ import { tagRole, withTagRole } from "@vue-skuilder/common";
1976
1986
  function dedupe(arr) {
1977
1987
  return [...new Set(arr)];
1978
1988
  }
@@ -2013,11 +2023,11 @@ function formatAge(ms) {
2013
2023
  }
2014
2024
  function unmetIntroExposeTags(tags, userTagElo, minCount) {
2015
2025
  if (minCount <= 0) return [];
2016
- const exposeTags = new Set(tags.filter((tag) => tag.startsWith("gpc:expose:")));
2026
+ const exposeTags = new Set(tags.filter((tag) => tagRole(tag) === "expose"));
2017
2027
  for (const tag of tags) {
2018
- if (!tag.startsWith("gpc:intro:")) continue;
2019
- const suffix = tag.slice("gpc:intro:".length);
2020
- if (suffix) exposeTags.add(`gpc:expose:${suffix}`);
2028
+ if (tagRole(tag) !== "intro") continue;
2029
+ const expose = withTagRole(tag, "expose");
2030
+ if (expose) exposeTags.add(expose);
2021
2031
  }
2022
2032
  return [...exposeTags].filter((tag) => {
2023
2033
  const tagElo = userTagElo[tag];
@@ -3216,8 +3226,10 @@ __export(eloDistance_exports, {
3216
3226
  DEFAULT_ELO_DISTANCE_CONFIG: () => DEFAULT_ELO_DISTANCE_CONFIG,
3217
3227
  createEloDistanceFilter: () => createEloDistanceFilter,
3218
3228
  default: () => EloDistanceFilter,
3229
+ mountMultiDimEloToggle: () => mountMultiDimEloToggle,
3219
3230
  tagAwareGap: () => tagAwareGap
3220
3231
  });
3232
+ import { COUNT_ONLY_SCORE, isCountOnlyTag } from "@vue-skuilder/common";
3221
3233
  function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
3222
3234
  const normalizedDistance = distance / halfLife;
3223
3235
  const decay = Math.exp(-(normalizedDistance * normalizedDistance));
@@ -3226,12 +3238,43 @@ function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
3226
3238
  function resolveConfig(config) {
3227
3239
  return { ...DEFAULT_ELO_DISTANCE_CONFIG, ...config };
3228
3240
  }
3241
+ function readMultiDimElo() {
3242
+ try {
3243
+ return typeof localStorage !== "undefined" && localStorage.getItem(MULTI_DIM_ELO_KEY) === "true";
3244
+ } catch {
3245
+ return false;
3246
+ }
3247
+ }
3248
+ function mountMultiDimEloToggle() {
3249
+ if (typeof window === "undefined") return;
3250
+ const win = window;
3251
+ win.skuilder = win.skuilder || {};
3252
+ Object.defineProperty(win.skuilder, "multiDimElo", {
3253
+ configurable: true,
3254
+ enumerable: true,
3255
+ get: () => multiDimElo,
3256
+ set: (on) => {
3257
+ multiDimElo = on === true;
3258
+ try {
3259
+ if (multiDimElo) localStorage.setItem(MULTI_DIM_ELO_KEY, "true");
3260
+ else localStorage.removeItem(MULTI_DIM_ELO_KEY);
3261
+ } catch (e) {
3262
+ logger.warn(`[EloDistance] multiDimElo not persisted (localStorage unavailable): ${e}`);
3263
+ }
3264
+ logger.info(
3265
+ `[EloDistance] multiDimElo ${multiDimElo ? "on: tag-aware" : "off: per strategy config"} ELO distance from the next replan`
3266
+ );
3267
+ }
3268
+ });
3269
+ }
3229
3270
  function tagAwareGap(cardTags, cardElo, userElo, minTagCount) {
3230
3271
  const globalGap = cardElo.global.score - userElo.global.score;
3231
3272
  const tags = [];
3232
3273
  for (const tag of cardTags) {
3233
3274
  const user = userElo.tags[tag];
3234
- if (!user || user.score === COUNT_ONLY_SENTINEL || user.count < minTagCount) continue;
3275
+ if (isCountOnlyTag(tag) || !user || user.score === COUNT_ONLY_SCORE || user.count < minTagCount) {
3276
+ continue;
3277
+ }
3235
3278
  const card = cardElo.tags[tag]?.score ?? cardElo.global.score;
3236
3279
  tags.push({
3237
3280
  tag,
@@ -3253,7 +3296,7 @@ function tagReason(tags, globalGap) {
3253
3296
  async function applyEloDistance(cards, context, config, source) {
3254
3297
  const { course, userElo, userCourseElo } = context;
3255
3298
  const { halfLife, minMultiplier, maxMultiplier } = config;
3256
- const tagAware = config.tagAware && userCourseElo !== void 0;
3299
+ const tagAware = (config.tagAware || multiDimElo) && userCourseElo !== void 0;
3257
3300
  const missing = cards.filter((c) => tagAware || c.cardElo === void 0).map((c) => c.cardId);
3258
3301
  const fetched = /* @__PURE__ */ new Map();
3259
3302
  if (missing.length > 0) {
@@ -3267,10 +3310,10 @@ async function applyEloDistance(cards, context, config, source) {
3267
3310
  const cardElo = full?.global?.score ?? card.cardElo ?? DEFAULT_CARD_ELO;
3268
3311
  let distance = Math.abs(cardElo - userElo);
3269
3312
  let how = "";
3270
- if (tagAware && full) {
3271
- const t = tagAwareGap(card.tags ?? [], full, userCourseElo, config.minTagCount);
3272
- distance = Math.abs(t.gap);
3273
- if (t.tags.length > 0) how = tagReason(t.tags, t.globalGap);
3313
+ if (tagAware) {
3314
+ const t = full ? tagAwareGap(card.tags ?? [], full, userCourseElo, config.minTagCount) : void 0;
3315
+ if (t) distance = Math.abs(t.gap);
3316
+ how = t?.tags.length ? `, tag-aware${tagReason(t.tags, t.globalGap)}` : ", tag-aware: global (no shared tags)";
3274
3317
  }
3275
3318
  const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
3276
3319
  const newScore = card.score * multiplier;
@@ -3303,21 +3346,24 @@ function createEloDistanceFilter(config) {
3303
3346
  transform: (cards, context) => applyEloDistance(cards, context, resolved, source)
3304
3347
  };
3305
3348
  }
3306
- var DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, COUNT_ONLY_SENTINEL, DEFAULT_CARD_ELO, EloDistanceFilter;
3349
+ var DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, DEFAULT_CARD_ELO, MULTI_DIM_ELO_KEY, multiDimElo, EloDistanceFilter;
3307
3350
  var init_eloDistance = __esm({
3308
3351
  "src/core/navigators/filters/eloDistance.ts"() {
3309
3352
  "use strict";
3310
3353
  init_navigators();
3354
+ init_logger();
3311
3355
  DEFAULT_ELO_DISTANCE_CONFIG = {
3312
3356
  halfLife: 300,
3313
3357
  minMultiplier: 0.05,
3314
3358
  maxMultiplier: 1,
3315
- tagAware: true,
3359
+ tagAware: false,
3316
3360
  minTagCount: 3
3317
3361
  };
3318
3362
  TAG_CONFIDENCE_HALF = 10;
3319
- COUNT_ONLY_SENTINEL = -1;
3320
3363
  DEFAULT_CARD_ELO = 1e3;
3364
+ MULTI_DIM_ELO_KEY = "skuilder:multiDimElo";
3365
+ multiDimElo = readMultiDimElo();
3366
+ mountMultiDimEloToggle();
3321
3367
  EloDistanceFilter = class _EloDistanceFilter extends ContentNavigator {
3322
3368
  name;
3323
3369
  /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
@@ -7765,6 +7811,7 @@ var init_tagRecent = __esm({
7765
7811
  import {
7766
7812
  adjustCourseScores,
7767
7813
  adjustCourseScoresPerTag,
7814
+ isCountOnlyTag as isCountOnlyTag2,
7768
7815
  toCourseElo as toCourseElo7
7769
7816
  } from "@vue-skuilder/common";
7770
7817
  var init_EloService = __esm({