@vue-skuilder/db 0.2.30 → 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 +88 -76
  6. package/dist/core/index.js.map +1 -1
  7. package/dist/core/index.mjs +40 -27
  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 +92 -80
  20. package/dist/impl/couch/index.js.map +1 -1
  21. package/dist/impl/couch/index.mjs +40 -27
  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 +79 -67
  26. package/dist/impl/static/index.js.map +1 -1
  27. package/dist/impl/static/index.mjs +40 -27
  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 +141 -110
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.mjs +65 -33
  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 +7 -8
  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
package/dist/index.mjs CHANGED
@@ -784,13 +784,12 @@ function clearRunHistory() {
784
784
  _pendingRuns = [];
785
785
  }
786
786
  function getOrigin(card) {
787
- const firstEntry = card.provenance[0];
788
- if (!firstEntry) return "unknown";
789
- const reason = firstEntry.reason?.toLowerCase() || "";
790
- const strategy = firstEntry.strategy?.toLowerCase() || "";
791
- if (reason.includes("new card") || strategy.includes("elo")) return "new";
792
- if (reason.includes("review") || strategy.includes("srs")) return "review";
793
- return "unknown";
787
+ return card.reviewID ? "review" : "new";
788
+ }
789
+ function requiredBy(card) {
790
+ return card.provenance.find(
791
+ (p) => p.strategy === "ephemeralHint" && p.score === Number.POSITIVE_INFINITY
792
+ )?.strategyName;
794
793
  }
795
794
  function captureRun(report) {
796
795
  const fullReport = {
@@ -814,17 +813,23 @@ function parseCardElo(provenance) {
814
813
  }
815
814
  function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints, scoredCards, regulators) {
816
815
  const selectedIds = new Set(selectedCards.map((c) => c.cardId));
817
- const toReport = (card) => ({
818
- cardId: card.cardId,
819
- courseId: card.courseId,
820
- origin: getOrigin(card),
821
- generator: card.provenance[0]?.strategyName || card.provenance[0]?.strategy,
822
- finalScore: card.score,
823
- cardElo: card.cardElo ?? parseCardElo(card.provenance),
824
- provenance: card.provenance,
825
- tags: card.tags,
826
- selected: selectedIds.has(card.cardId)
827
- });
816
+ const toReport = (card) => {
817
+ const required = requiredBy(card);
818
+ const first = card.provenance[0];
819
+ const generator = first && first.strategy !== "ephemeralHint" ? first.strategyName || first.strategy : void 0;
820
+ return {
821
+ cardId: card.cardId,
822
+ courseId: card.courseId,
823
+ origin: getOrigin(card),
824
+ ...generator ? { generator } : {},
825
+ ...required ? { required } : {},
826
+ finalScore: card.score,
827
+ cardElo: card.cardElo ?? parseCardElo(card.provenance),
828
+ provenance: card.provenance,
829
+ tags: card.tags,
830
+ selected: selectedIds.has(card.cardId)
831
+ };
832
+ };
828
833
  const selectedReported = [];
829
834
  const nearMissReported = [];
830
835
  const discardedTailCards = [];
@@ -1953,10 +1958,14 @@ var init_elo = __esm({
1953
1958
  const userElo = toCourseElo2(courseReg.elo);
1954
1959
  userGlobalElo = userElo.global.score;
1955
1960
  }
1956
- const activeCards = await this.user.getActiveCards();
1961
+ const [activeCards, seenCards] = await Promise.all([
1962
+ this.user.getActiveCards(),
1963
+ this.user.getSeenCards(this.course.getCourseID()).catch(() => [])
1964
+ ]);
1965
+ const notNew = /* @__PURE__ */ new Set([...activeCards.map((ac) => ac.cardID), ...seenCards]);
1957
1966
  const newCards = (await this.course.getCardsCenteredAtELO(
1958
1967
  { limit, elo: "user" },
1959
- (c) => !activeCards.some((ac) => c.cardID === ac.cardID)
1968
+ (c) => !notNew.has(c.cardID)
1960
1969
  )).map((c) => ({ ...c, status: "new" }));
1961
1970
  const scored = newCards.map((c) => {
1962
1971
  const cardElo = c.elo ?? 1e3;
@@ -2009,6 +2018,7 @@ __export(prescribed_exports, {
2009
2018
  default: () => PrescribedCardsGenerator,
2010
2019
  unmetIntroExposeTags: () => unmetIntroExposeTags
2011
2020
  });
2021
+ import { tagRole, withTagRole } from "@vue-skuilder/common";
2012
2022
  function dedupe(arr) {
2013
2023
  return [...new Set(arr)];
2014
2024
  }
@@ -2049,11 +2059,11 @@ function formatAge(ms) {
2049
2059
  }
2050
2060
  function unmetIntroExposeTags(tags, userTagElo, minCount) {
2051
2061
  if (minCount <= 0) return [];
2052
- const exposeTags = new Set(tags.filter((tag) => tag.startsWith("gpc:expose:")));
2062
+ const exposeTags = new Set(tags.filter((tag) => tagRole(tag) === "expose"));
2053
2063
  for (const tag of tags) {
2054
- if (!tag.startsWith("gpc:intro:")) continue;
2055
- const suffix = tag.slice("gpc:intro:".length);
2056
- if (suffix) exposeTags.add(`gpc:expose:${suffix}`);
2064
+ if (tagRole(tag) !== "intro") continue;
2065
+ const expose = withTagRole(tag, "expose");
2066
+ if (expose) exposeTags.add(expose);
2057
2067
  }
2058
2068
  return [...exposeTags].filter((tag) => {
2059
2069
  const tagElo = userTagElo[tag];
@@ -3255,6 +3265,7 @@ __export(eloDistance_exports, {
3255
3265
  mountMultiDimEloToggle: () => mountMultiDimEloToggle,
3256
3266
  tagAwareGap: () => tagAwareGap
3257
3267
  });
3268
+ import { COUNT_ONLY_SCORE, isCountOnlyTag } from "@vue-skuilder/common";
3258
3269
  function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
3259
3270
  const normalizedDistance = distance / halfLife;
3260
3271
  const decay = Math.exp(-(normalizedDistance * normalizedDistance));
@@ -3297,7 +3308,9 @@ function tagAwareGap(cardTags, cardElo, userElo, minTagCount) {
3297
3308
  const tags = [];
3298
3309
  for (const tag of cardTags) {
3299
3310
  const user = userElo.tags[tag];
3300
- if (!user || user.score === COUNT_ONLY_SENTINEL || user.count < minTagCount) continue;
3311
+ if (isCountOnlyTag(tag) || !user || user.score === COUNT_ONLY_SCORE || user.count < minTagCount) {
3312
+ continue;
3313
+ }
3301
3314
  const card = cardElo.tags[tag]?.score ?? cardElo.global.score;
3302
3315
  tags.push({
3303
3316
  tag,
@@ -3369,7 +3382,7 @@ function createEloDistanceFilter(config) {
3369
3382
  transform: (cards, context) => applyEloDistance(cards, context, resolved, source)
3370
3383
  };
3371
3384
  }
3372
- var DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, COUNT_ONLY_SENTINEL, DEFAULT_CARD_ELO, MULTI_DIM_ELO_KEY, multiDimElo, EloDistanceFilter;
3385
+ var DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, DEFAULT_CARD_ELO, MULTI_DIM_ELO_KEY, multiDimElo, EloDistanceFilter;
3373
3386
  var init_eloDistance = __esm({
3374
3387
  "src/core/navigators/filters/eloDistance.ts"() {
3375
3388
  "use strict";
@@ -3383,7 +3396,6 @@ var init_eloDistance = __esm({
3383
3396
  minTagCount: 3
3384
3397
  };
3385
3398
  TAG_CONFIDENCE_HALF = 10;
3386
- COUNT_ONLY_SENTINEL = -1;
3387
3399
  DEFAULT_CARD_ELO = 1e3;
3388
3400
  MULTI_DIM_ELO_KEY = "skuilder:multiDimElo";
3389
3401
  multiDimElo = readMultiDimElo();
@@ -8183,8 +8195,24 @@ var init_tagRecent = __esm({
8183
8195
  import {
8184
8196
  adjustCourseScores,
8185
8197
  adjustCourseScoresPerTag,
8198
+ isCountOnlyTag as isCountOnlyTag2,
8186
8199
  toCourseElo as toCourseElo7
8187
8200
  } from "@vue-skuilder/common";
8201
+ function withCountOnlyRoles(perf, cardId) {
8202
+ const out = { ...perf };
8203
+ const counted = [];
8204
+ for (const [tag, score] of Object.entries(perf)) {
8205
+ if (tag === "_global" || score === null || !isCountOnlyTag2(tag)) continue;
8206
+ out[tag] = null;
8207
+ counted.push(tag);
8208
+ }
8209
+ if (counted.length) {
8210
+ logger.warn(
8211
+ `[EloService] ${cardId} sent scores for bookkeeping tags [${counted.join(", ")}]; counted, not graded`
8212
+ );
8213
+ }
8214
+ return out;
8215
+ }
8188
8216
  var EloService;
8189
8217
  var init_EloService = __esm({
8190
8218
  "src/study/services/EloService.ts"() {
@@ -8235,10 +8263,11 @@ var init_EloService = __esm({
8235
8263
  courseReg.elo = eloUpdate.userElo;
8236
8264
  const tags = {};
8237
8265
  for (const tag of cardTagKeys) {
8266
+ const countOnly = isCountOnlyTag2(tag);
8238
8267
  tags[tag] = {
8239
8268
  before: beforeUserTag[tag],
8240
- after: eloUpdate.userElo.tags[tag].score,
8241
- score: userScore
8269
+ after: countOnly ? beforeUserTag[tag] : eloUpdate.userElo.tags[tag].score,
8270
+ score: countOnly ? null : userScore
8242
8271
  };
8243
8272
  }
8244
8273
  const event = {
@@ -8309,11 +8338,12 @@ var init_EloService = __esm({
8309
8338
  ]);
8310
8339
  const cardElo = cardEloResults[0];
8311
8340
  const cardTags = cardTagsMap.get(card_id) ?? [];
8312
- const enriched = { ...taggedPerformance };
8341
+ const graded = withCountOnlyRoles(taggedPerformance, card_id);
8342
+ const enriched = { ...graded };
8313
8343
  const globalScore = taggedPerformance._global;
8314
8344
  for (const tag of cardTags) {
8315
8345
  if (!(tag in enriched)) {
8316
- enriched[tag] = globalScore;
8346
+ enriched[tag] = isCountOnlyTag2(tag) ? null : globalScore;
8317
8347
  }
8318
8348
  }
8319
8349
  if (cardElo && userElo) {
@@ -8328,7 +8358,7 @@ var init_EloService = __esm({
8328
8358
  const at = (/* @__PURE__ */ new Date()).toISOString();
8329
8359
  const recorded = recordTagPresentations(
8330
8360
  eloUpdate.userElo,
8331
- taggedPerformance,
8361
+ graded,
8332
8362
  currentCard.records,
8333
8363
  card_id,
8334
8364
  at
@@ -11616,7 +11646,9 @@ function toRunCard(c) {
11616
11646
  cardId: c.cardId,
11617
11647
  origin: c.origin,
11618
11648
  ...c.generator ? { generator: c.generator } : {},
11619
- score: sig4(c.finalScore),
11649
+ ...c.required ? { required: c.required } : {},
11650
+ // A required card's score is infinite, which JSON can't hold: say so with null.
11651
+ score: Number.isFinite(c.finalScore) ? sig4(c.finalScore) : null,
11620
11652
  selected: c.selected
11621
11653
  };
11622
11654
  }