@vue-skuilder/db 0.2.26 → 0.2.28

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 (61) hide show
  1. package/dist/classroomDB-DLTtLZct.d.cts +86 -0
  2. package/dist/classroomDB-DLTtLZct.d.ts +86 -0
  3. package/dist/{contentSource-LPf044hY.d.ts → contentSource-BoFBwvYa.d.ts} +65 -98
  4. package/dist/{contentSource-D3c1fMAk.d.cts → contentSource-DpQqTG3m.d.cts} +65 -98
  5. package/dist/core/index.d.cts +6 -5
  6. package/dist/core/index.d.ts +6 -5
  7. package/dist/core/index.js +43 -15
  8. package/dist/core/index.js.map +1 -1
  9. package/dist/core/index.mjs +43 -15
  10. package/dist/core/index.mjs.map +1 -1
  11. package/dist/{dataLayerProvider-DaAootVV.d.ts → dataLayerProvider-D_LJT3F4.d.ts} +2 -8
  12. package/dist/{dataLayerProvider-CeLiFbHv.d.cts → dataLayerProvider-Dl3cAAvQ.d.cts} +2 -8
  13. package/dist/diagnostics/index.d.cts +370 -0
  14. package/dist/diagnostics/index.d.ts +370 -0
  15. package/dist/diagnostics/index.js +778 -0
  16. package/dist/diagnostics/index.js.map +1 -0
  17. package/dist/diagnostics/index.mjs +729 -0
  18. package/dist/diagnostics/index.mjs.map +1 -0
  19. package/dist/impl/couch/index.d.cts +4 -3
  20. package/dist/impl/couch/index.d.ts +4 -3
  21. package/dist/impl/couch/index.js +43 -15
  22. package/dist/impl/couch/index.js.map +1 -1
  23. package/dist/impl/couch/index.mjs +43 -15
  24. package/dist/impl/couch/index.mjs.map +1 -1
  25. package/dist/impl/static/index.d.cts +5 -5
  26. package/dist/impl/static/index.d.ts +5 -5
  27. package/dist/impl/static/index.js +43 -21
  28. package/dist/impl/static/index.js.map +1 -1
  29. package/dist/impl/static/index.mjs +43 -21
  30. package/dist/impl/static/index.mjs.map +1 -1
  31. package/dist/{index-BkBJlGDX.d.ts → index-CVGehe_t.d.ts} +1 -1
  32. package/dist/{index-D7WdMDAs.d.cts → index-Ktg72jKb.d.cts} +1 -1
  33. package/dist/index.d.cts +10 -9
  34. package/dist/index.d.ts +10 -9
  35. package/dist/index.js +85 -36
  36. package/dist/index.js.map +1 -1
  37. package/dist/index.mjs +85 -36
  38. package/dist/index.mjs.map +1 -1
  39. package/dist/{types-DjiFOZxJ.d.cts → types-D0oQeJAi.d.cts} +1 -1
  40. package/dist/{types-uJ2Xn3_X.d.ts → types-dXWfyz9B.d.ts} +1 -1
  41. package/dist/{types-legacy-CrwyZIvI.d.cts → types-legacy-BkOYOR6U.d.cts} +1 -1
  42. package/dist/{types-legacy-CrwyZIvI.d.ts → types-legacy-BkOYOR6U.d.ts} +1 -1
  43. package/dist/util/packer/index.d.cts +3 -3
  44. package/dist/util/packer/index.d.ts +3 -3
  45. package/package.json +15 -3
  46. package/src/core/interfaces/dataLayerProvider.ts +3 -8
  47. package/src/core/navigators/Pipeline.ts +5 -2
  48. package/src/core/navigators/PipelineDebugger.ts +64 -16
  49. package/src/core/navigators/generators/prescribed.ts +43 -14
  50. package/src/core/navigators/index.ts +1 -0
  51. package/src/core/types/studySession.ts +37 -0
  52. package/src/diagnostics/dataset.ts +231 -0
  53. package/src/diagnostics/derive.ts +555 -0
  54. package/src/diagnostics/index.ts +24 -0
  55. package/src/diagnostics/loader.ts +191 -0
  56. package/src/diagnostics/text.ts +242 -0
  57. package/src/impl/couch/PouchDataLayerProvider.ts +0 -23
  58. package/src/impl/static/StaticDataLayerProvider.ts +0 -11
  59. package/src/study/SessionController.ts +56 -2
  60. package/tests/core/navigators/prescribedIntroExposure.test.ts +29 -0
  61. package/tsup.config.ts +1 -0
package/dist/index.mjs CHANGED
@@ -812,7 +812,7 @@ function parseCardElo(provenance) {
812
812
  const match = eloEntry.reason.match(/card:\s*(\d+)/);
813
813
  return match ? parseInt(match[1], 10) : void 0;
814
814
  }
815
- function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints) {
815
+ function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints, scoredCards) {
816
816
  const selectedIds = new Set(selectedCards.map((c) => c.cardId));
817
817
  const toReport = (card) => ({
818
818
  cardId: card.cardId,
@@ -865,6 +865,23 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
865
865
  note: `${discardedTailCards.length} additional candidate(s) scored below the top ${DISCARDED_KEEP_TOP} near-misses and were not retained (score ${scoreMin.toExponential(2)}\u2013${scoreMax.toExponential(2)}${eloFragment}). Likely ELO-window pull remnants filtered out by hierarchy/lesson/priority gates.`
866
866
  };
867
867
  }
868
+ const isUnselectedNew = (c) => !c.reviewID && !selectedIds.has(c.cardId);
869
+ const generatorScore = (c) => c.provenance[0]?.score ?? 0;
870
+ const keptIds = new Set(allCards.map((c) => c.cardId));
871
+ const hintExcluded = (c) => c.score > 0 && !keptIds.has(c.cardId);
872
+ let nextInLine;
873
+ for (const c of allCards) {
874
+ if (isUnselectedNew(c) && (!nextInLine || c.score > nextInLine.score)) nextInLine = c;
875
+ }
876
+ let topGenerated;
877
+ for (const c of scoredCards ?? allCards) {
878
+ if (!isUnselectedNew(c) || hintExcluded(c)) continue;
879
+ if (!topGenerated || generatorScore(c) > generatorScore(topGenerated)) topGenerated = c;
880
+ }
881
+ const unselectedNew = nextInLine || topGenerated ? {
882
+ ...nextInLine ? { nextInLine: toReport(nextInLine) } : {},
883
+ ...topGenerated && topGenerated.cardId !== nextInLine?.cardId ? { topGenerated: toReport(topGenerated) } : {}
884
+ } : void 0;
868
885
  const reviewsSelected = selectedCards.filter((c) => getOrigin(c) === "review").length;
869
886
  const newSelected = selectedCards.filter((c) => getOrigin(c) === "new").length;
870
887
  return {
@@ -880,6 +897,7 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
880
897
  reviewsSelected,
881
898
  newSelected,
882
899
  cards,
900
+ unselectedNew,
883
901
  discardedTail
884
902
  };
885
903
  }
@@ -1978,7 +1996,8 @@ var init_generators = __esm({
1978
1996
  // src/core/navigators/generators/prescribed.ts
1979
1997
  var prescribed_exports = {};
1980
1998
  __export(prescribed_exports, {
1981
- default: () => PrescribedCardsGenerator
1999
+ default: () => PrescribedCardsGenerator,
2000
+ unmetIntroExposeTags: () => unmetIntroExposeTags
1982
2001
  });
1983
2002
  function dedupe(arr) {
1984
2003
  return [...new Set(arr)];
@@ -2018,6 +2037,19 @@ function formatAge(ms) {
2018
2037
  if (hours < 24) return `${hours}h`;
2019
2038
  return `${Math.round(hours / 24)}d`;
2020
2039
  }
2040
+ function unmetIntroExposeTags(tags, userTagElo, minCount) {
2041
+ if (minCount <= 0) return [];
2042
+ const exposeTags = new Set(tags.filter((tag) => tag.startsWith("gpc:expose:")));
2043
+ for (const tag of tags) {
2044
+ if (!tag.startsWith("gpc:intro:")) continue;
2045
+ const suffix = tag.slice("gpc:intro:".length);
2046
+ if (suffix) exposeTags.add(`gpc:expose:${suffix}`);
2047
+ }
2048
+ return [...exposeTags].filter((tag) => {
2049
+ const tagElo = userTagElo[tag];
2050
+ return !tagElo || tagElo.count < minCount;
2051
+ });
2052
+ }
2021
2053
  function pickTopByScore(cards, limit) {
2022
2054
  return [...cards].sort((a, b) => b.score - a.score || a.cardId.localeCompare(b.cardId)).slice(0, limit);
2023
2055
  }
@@ -2316,6 +2348,7 @@ var init_prescribed = __esm({
2316
2348
  freshnessWindowSessions: typeof raw.freshnessWindowSessions === "number" ? raw.freshnessWindowSessions : DEFAULT_FRESHNESS_WINDOW,
2317
2349
  maxDirectTargetsPerRun: typeof raw.maxDirectTargetsPerRun === "number" ? raw.maxDirectTargetsPerRun : DEFAULT_MAX_DIRECT_PER_RUN,
2318
2350
  maxSupportCardsPerRun: typeof raw.maxSupportCardsPerRun === "number" ? raw.maxSupportCardsPerRun : DEFAULT_MAX_SUPPORT_PER_RUN,
2351
+ introExposeMinCount: typeof raw.introExposeMinCount === "number" ? raw.introExposeMinCount : DEFAULT_MIN_COUNT,
2319
2352
  hierarchyWalk: {
2320
2353
  enabled: raw.hierarchyWalk?.enabled !== false,
2321
2354
  maxDepth: typeof raw.hierarchyWalk?.maxDepth === "number" ? raw.hierarchyWalk.maxDepth : DEFAULT_HIERARCHY_DEPTH
@@ -2391,18 +2424,11 @@ var init_prescribed = __esm({
2391
2424
  group.hierarchyWalk?.enabled !== false,
2392
2425
  group.hierarchyWalk?.maxDepth ?? DEFAULT_HIERARCHY_DEPTH
2393
2426
  );
2394
- const introTags = tags.filter((tag) => tag.startsWith("gpc:intro:"));
2395
- const exposeTags = new Set(tags.filter((tag) => tag.startsWith("gpc:expose:")));
2396
- for (const introTag of introTags) {
2397
- const suffix = introTag.slice("gpc:intro:".length);
2398
- if (suffix) {
2399
- exposeTags.add(`gpc:expose:${suffix}`);
2400
- }
2401
- }
2402
- const unmetExposeTags = [...exposeTags].filter((tag) => {
2403
- const tagElo = userTagElo[tag];
2404
- return !tagElo || tagElo.count < DEFAULT_MIN_COUNT;
2405
- });
2427
+ const unmetExposeTags = unmetIntroExposeTags(
2428
+ tags,
2429
+ userTagElo,
2430
+ group.introExposeMinCount ?? DEFAULT_MIN_COUNT
2431
+ );
2406
2432
  if (unmetExposeTags.length > 0) {
2407
2433
  unmetExposeTags.forEach((tag) => supportTags.add(tag));
2408
2434
  }
@@ -4691,6 +4717,7 @@ var init_Pipeline = __esm({
4691
4717
  }
4692
4718
  logger.debug(`[Pipeline] Filter '${filter.name}': ${beforeScores.size} \u2192 ${cards.length} cards (\u2191${boosted} \u2193${penalized} =${passed})`);
4693
4719
  }
4720
+ const scoredCards = cards;
4694
4721
  cards = cards.filter((c) => c.score > 0);
4695
4722
  const hints = this._ephemeralHints;
4696
4723
  if (hints) {
@@ -4727,7 +4754,8 @@ var init_Pipeline = __esm({
4727
4754
  cards,
4728
4755
  result,
4729
4756
  context.userElo,
4730
- hints ?? void 0
4757
+ hints ?? void 0,
4758
+ scoredCards
4731
4759
  );
4732
4760
  captureRun(report);
4733
4761
  } catch (e) {
@@ -11140,7 +11168,41 @@ Example:
11140
11168
  });
11141
11169
 
11142
11170
  // src/study/SessionController.ts
11143
- var SessionController;
11171
+ function sig4(x) {
11172
+ return Number(x.toPrecision(4));
11173
+ }
11174
+ function toRunCard(c) {
11175
+ return {
11176
+ cardId: c.cardId,
11177
+ origin: c.origin,
11178
+ ...c.generator ? { generator: c.generator } : {},
11179
+ score: sig4(c.finalScore),
11180
+ selected: c.selected
11181
+ };
11182
+ }
11183
+ function toRunCardTrail(c) {
11184
+ return {
11185
+ ...toRunCard(c),
11186
+ trail: c.provenance.filter((p) => p.action !== "passed").map((p) => ({
11187
+ strategyName: p.strategyName,
11188
+ action: p.action,
11189
+ score: sig4(p.score),
11190
+ reason: p.reason
11191
+ }))
11192
+ };
11193
+ }
11194
+ function persistedRunCards(run) {
11195
+ const selected = run.cards.filter((c) => c.selected);
11196
+ const runnersUp = run.cards.filter((c) => !c.selected).slice(0, PERSISTED_RUNNERS_UP);
11197
+ return [...selected, ...runnersUp].map(toRunCard);
11198
+ }
11199
+ function persistedUnselectedNew(u) {
11200
+ return {
11201
+ ...u.nextInLine ? { nextInLine: toRunCardTrail(u.nextInLine) } : {},
11202
+ ...u.topGenerated ? { topGenerated: toRunCardTrail(u.topGenerated) } : {}
11203
+ };
11204
+ }
11205
+ var PERSISTED_RUNNERS_UP, SessionController;
11144
11206
  var init_SessionController = __esm({
11145
11207
  "src/study/SessionController.ts"() {
11146
11208
  "use strict";
@@ -11162,6 +11224,7 @@ var init_SessionController = __esm({
11162
11224
  init_SessionDebugger();
11163
11225
  init_SessionOverlay();
11164
11226
  init_logger();
11227
+ PERSISTED_RUNNERS_UP = 5;
11165
11228
  SessionController = class _SessionController extends Loggable {
11166
11229
  _className = "SessionController";
11167
11230
  services;
@@ -11444,13 +11507,16 @@ var init_SessionController = __esm({
11444
11507
  newSelected: run.newSelected,
11445
11508
  // Compact detail projected off the full report so a persisted run is
11446
11509
  // self-explanatory once the in-memory ring buffer has rolled over.
11447
- // Per-card provenance (`run.cards`) is intentionally left out — it's
11448
- // the dominant memory cost and not worth persisting per run.
11510
+ // Per-card provenance is the dominant cost, so it's kept only for the
11511
+ // (at most two) `unselectedNew` cards, and only its score-changing
11512
+ // entries. Everything else is ids and scores.
11449
11513
  ...typeof run.userElo === "number" ? { userElo: run.userElo } : {},
11450
11514
  ...run.generators ? { generators: run.generators } : {},
11451
11515
  ...run.filters ? { filters: run.filters } : {},
11452
11516
  ...run.hints ? { hints: run.hints } : {},
11453
- ...run.discardedTail ? { discardedTail: run.discardedTail } : {}
11517
+ ...run.discardedTail ? { discardedTail: run.discardedTail } : {},
11518
+ cards: persistedRunCards(run),
11519
+ ...run.unselectedNew ? { unselectedNew: persistedUnselectedNew(run.unselectedNew) } : {}
11454
11520
  });
11455
11521
  }
11456
11522
  }
@@ -14079,7 +14145,6 @@ var init_PouchDataLayerProvider = __esm({
14079
14145
  "use strict";
14080
14146
  init_logger();
14081
14147
  init_dataDirectory();
14082
- init_auth();
14083
14148
  init_adminDB2();
14084
14149
  init_classroomDB2();
14085
14150
  init_courseDB();
@@ -14153,16 +14218,6 @@ var init_PouchDataLayerProvider = __esm({
14153
14218
  getAdminDB() {
14154
14219
  return new AdminDB();
14155
14220
  }
14156
- async createUserReaderForUser(targetUsername) {
14157
- const requestingUsername = await getLoggedInUsername();
14158
- if (requestingUsername !== "admin") {
14159
- throw new Error("Unauthorized: Only admin users can access other users' data");
14160
- }
14161
- logger.info(`Admin user '${requestingUsername}' requesting UserDBReader for '${targetUsername}'`);
14162
- const syncStrategy = new CouchDBSyncStrategy();
14163
- const targetUserDB = await BaseUser.instance(syncStrategy, targetUsername);
14164
- return targetUserDB;
14165
- }
14166
14221
  isReadOnly() {
14167
14222
  return false;
14168
14223
  }
@@ -15175,12 +15230,6 @@ var init_StaticDataLayerProvider = __esm({
15175
15230
  getAdminDB() {
15176
15231
  throw new Error("Admin functions not supported in static mode");
15177
15232
  }
15178
- async createUserReaderForUser(targetUsername) {
15179
- logger.warn(`StaticDataLayerProvider: Multi-user access not supported in static mode`);
15180
- logger.warn(`Request: trying to access data for ${targetUsername}`);
15181
- logger.warn(`Returning current user's data instead`);
15182
- return this.getUserDB();
15183
- }
15184
15233
  isReadOnly() {
15185
15234
  return true;
15186
15235
  }