@vue-skuilder/db 0.2.28 → 0.2.30

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 (67) hide show
  1. package/dist/{contentSource-DpQqTG3m.d.cts → contentSource-B6FrSihy.d.cts} +218 -2
  2. package/dist/{contentSource-BoFBwvYa.d.ts → contentSource-CqJmbOZN.d.ts} +218 -2
  3. package/dist/core/index.d.cts +13 -90
  4. package/dist/core/index.d.ts +13 -90
  5. package/dist/core/index.js +621 -179
  6. package/dist/core/index.js.map +1 -1
  7. package/dist/core/index.mjs +620 -179
  8. package/dist/core/index.mjs.map +1 -1
  9. package/dist/{dataLayerProvider-D_LJT3F4.d.ts → dataLayerProvider-B9_UCvkR.d.ts} +1 -1
  10. package/dist/{dataLayerProvider-Dl3cAAvQ.d.cts → dataLayerProvider-DUxDqMtZ.d.cts} +1 -1
  11. package/dist/diagnostics/index.d.cts +79 -6
  12. package/dist/diagnostics/index.d.ts +79 -6
  13. package/dist/diagnostics/index.js +158 -4
  14. package/dist/diagnostics/index.js.map +1 -1
  15. package/dist/diagnostics/index.mjs +156 -4
  16. package/dist/diagnostics/index.mjs.map +1 -1
  17. package/dist/impl/couch/index.d.cts +11 -2
  18. package/dist/impl/couch/index.d.ts +11 -2
  19. package/dist/impl/couch/index.js +619 -179
  20. package/dist/impl/couch/index.js.map +1 -1
  21. package/dist/impl/couch/index.mjs +619 -179
  22. package/dist/impl/couch/index.mjs.map +1 -1
  23. package/dist/impl/static/index.d.cts +8 -2
  24. package/dist/impl/static/index.d.ts +8 -2
  25. package/dist/impl/static/index.js +616 -179
  26. package/dist/impl/static/index.js.map +1 -1
  27. package/dist/impl/static/index.mjs +616 -179
  28. package/dist/impl/static/index.mjs.map +1 -1
  29. package/dist/index.d.cts +66 -5
  30. package/dist/index.d.ts +66 -5
  31. package/dist/index.js +669 -180
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.mjs +656 -180
  34. package/dist/index.mjs.map +1 -1
  35. package/package.json +3 -3
  36. package/src/core/interfaces/contentSource.ts +7 -0
  37. package/src/core/navigators/Pipeline.ts +145 -13
  38. package/src/core/navigators/PipelineAssembler.ts +19 -40
  39. package/src/core/navigators/PipelineDebugger.ts +11 -2
  40. package/src/core/navigators/SrsDebugger.ts +37 -12
  41. package/src/core/navigators/defaults.ts +29 -5
  42. package/src/core/navigators/filters/WeightedFilter.ts +5 -1
  43. package/src/core/navigators/filters/eloDistance.ts +320 -76
  44. package/src/core/navigators/filters/hierarchyDefinition.ts +5 -1
  45. package/src/core/navigators/filters/index.ts +2 -2
  46. package/src/core/navigators/filters/interferenceMitigator.ts +5 -1
  47. package/src/core/navigators/filters/relativePriority.ts +5 -1
  48. package/src/core/navigators/filters/types.ts +24 -1
  49. package/src/core/navigators/filters/userTagPreference.ts +5 -1
  50. package/src/core/navigators/generators/elo.ts +23 -53
  51. package/src/core/navigators/generators/srs.ts +27 -124
  52. package/src/core/navigators/index.ts +31 -5
  53. package/src/core/navigators/pipelinePlan.ts +245 -0
  54. package/src/core/navigators/regulators.ts +230 -0
  55. package/src/core/types/studySession.ts +3 -0
  56. package/src/diagnostics/dataset.ts +13 -2
  57. package/src/diagnostics/index.ts +3 -0
  58. package/src/diagnostics/loader.ts +5 -2
  59. package/src/diagnostics/pipeline.ts +236 -0
  60. package/src/diagnostics/text.ts +26 -3
  61. package/src/impl/couch/courseDB.ts +13 -0
  62. package/src/impl/static/courseDB.ts +9 -0
  63. package/src/index.ts +4 -0
  64. package/src/study/SessionController.ts +20 -0
  65. package/src/study/SessionOverlay.ts +7 -4
  66. package/tests/core/navigators/PipelineAssembler.test.ts +20 -5
  67. package/tests/core/navigators/eloDistanceFilter.test.ts +9 -9
@@ -532,7 +532,7 @@ function parseCardElo(provenance) {
532
532
  const match = eloEntry.reason.match(/card:\s*(\d+)/);
533
533
  return match ? parseInt(match[1], 10) : void 0;
534
534
  }
535
- function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints, scoredCards) {
535
+ function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints, scoredCards, regulators) {
536
536
  const selectedIds = new Set(selectedCards.map((c) => c.cardId));
537
537
  const toReport = (card) => ({
538
538
  cardId: card.cardId,
@@ -540,7 +540,7 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
540
540
  origin: getOrigin(card),
541
541
  generator: card.provenance[0]?.strategyName || card.provenance[0]?.strategy,
542
542
  finalScore: card.score,
543
- cardElo: parseCardElo(card.provenance),
543
+ cardElo: card.cardElo ?? parseCardElo(card.provenance),
544
544
  provenance: card.provenance,
545
545
  tags: card.tags,
546
546
  selected: selectedIds.has(card.cardId)
@@ -618,7 +618,8 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
618
618
  newSelected,
619
619
  cards,
620
620
  unselectedNew,
621
- discardedTail
621
+ discardedTail,
622
+ ...regulators ? { regulators } : {}
622
623
  };
623
624
  }
624
625
  function formatProvenance(provenance) {
@@ -1342,11 +1343,23 @@ var SrsDebugger_exports = {};
1342
1343
  __export(SrsDebugger_exports, {
1343
1344
  captureSrsBacklog: () => captureSrsBacklog,
1344
1345
  clearSrsBacklogDebug: () => clearSrsBacklogDebug,
1345
- getSrsBacklogDebug: () => getSrsBacklogDebug
1346
+ getSrsBacklogDebug: () => getSrsBacklogDebug,
1347
+ noteReviewPressure: () => noteReviewPressure
1346
1348
  });
1347
1349
  function captureSrsBacklog(snapshot) {
1348
1350
  snapshots.set(snapshot.courseId, snapshot);
1349
1351
  }
1352
+ function noteReviewPressure(courseId, pressure) {
1353
+ const snapshot = snapshots.get(courseId);
1354
+ if (!snapshot) return;
1355
+ snapshots.set(courseId, {
1356
+ ...snapshot,
1357
+ reviewMass: pressure.mass,
1358
+ healthyBacklog: pressure.healthyMass,
1359
+ backlogGrowthRate: pressure.rate,
1360
+ backlogMultiplier: pressure.multiplier
1361
+ });
1362
+ }
1350
1363
  function getSrsBacklogDebug() {
1351
1364
  return [...snapshots.values()].sort((a, b) => b.timestamp - a.timestamp);
1352
1365
  }
@@ -1624,14 +1637,13 @@ var elo_exports = {};
1624
1637
  __export(elo_exports, {
1625
1638
  default: () => ELONavigator
1626
1639
  });
1627
- var import_common5, ELO_RELEVANCE_SIGMA, ELONavigator;
1640
+ var import_common5, ELONavigator;
1628
1641
  var init_elo = __esm({
1629
1642
  "src/core/navigators/generators/elo.ts"() {
1630
1643
  "use strict";
1631
1644
  init_navigators();
1632
1645
  import_common5 = require("@vue-skuilder/common");
1633
1646
  init_logger();
1634
- ELO_RELEVANCE_SIGMA = 300;
1635
1647
  ELONavigator = class extends ContentNavigator {
1636
1648
  /** Human-readable name for CardGenerator interface */
1637
1649
  name;
@@ -1640,10 +1652,8 @@ var init_elo = __esm({
1640
1652
  this.name = strategyData?.name || "ELO";
1641
1653
  }
1642
1654
  /**
1643
- * Get new cards with suitability scores based on ELO distance.
1644
- *
1645
- * Cards closer to user's ELO get higher scores.
1646
- * Score formula: max(0, 1 - distance / 500)
1655
+ * Get the new cards nearest the learner's ELO, each scored with a flat
1656
+ * jitter in [0.5, 1]. Carries each card's ELO for the ELO distance filter.
1647
1657
  *
1648
1658
  * NOTE: This generator only handles NEW cards. Reviews are handled by
1649
1659
  * SRSNavigator. Use CompositeGenerator to combine both.
@@ -1671,20 +1681,20 @@ var init_elo = __esm({
1671
1681
  const scored = newCards.map((c) => {
1672
1682
  const cardElo = c.elo ?? 1e3;
1673
1683
  const distance = Math.abs(cardElo - userGlobalElo);
1674
- const relevance = Math.exp(-((distance / ELO_RELEVANCE_SIGMA) ** 2));
1675
- const samplingKey = relevance * (0.5 + 0.5 * Math.random());
1684
+ const jitter = 0.5 + 0.5 * Math.random();
1676
1685
  return {
1677
1686
  cardId: c.cardID,
1678
1687
  courseId: c.courseID,
1679
- score: samplingKey,
1688
+ score: jitter,
1689
+ cardElo,
1680
1690
  provenance: [
1681
1691
  {
1682
1692
  strategy: "elo",
1683
1693
  strategyName: this.strategyName || this.name,
1684
1694
  strategyId: this.strategyId || "NAVIGATION_STRATEGY-ELO-default",
1685
1695
  action: "generated",
1686
- score: samplingKey,
1687
- reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}), relevance ${relevance.toFixed(3)}, key ${samplingKey.toFixed(3)}`
1696
+ score: jitter,
1697
+ reason: `new card near learner ELO: distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}), jitter ${jitter.toFixed(3)}`
1688
1698
  }
1689
1699
  ]
1690
1700
  };
@@ -2560,43 +2570,132 @@ var init_prescribed = __esm({
2560
2570
  }
2561
2571
  });
2562
2572
 
2573
+ // src/core/navigators/regulators.ts
2574
+ var regulators_exports = {};
2575
+ __export(regulators_exports, {
2576
+ DEFAULT_REGULATOR_CONFIG: () => DEFAULT_REGULATOR_CONFIG,
2577
+ INTAKE_CLOCK_KEY: () => INTAKE_CLOCK_KEY,
2578
+ applyReading: () => applyReading,
2579
+ frozenMsAt: () => frozenMsAt,
2580
+ intakeHours: () => intakeHours,
2581
+ intakeReading: () => intakeReading,
2582
+ resetIntakeClock: () => resetIntakeClock,
2583
+ reviewMassReading: () => reviewMassReading,
2584
+ reviewWeight: () => reviewWeight,
2585
+ stepIntakeClock: () => stepIntakeClock
2586
+ });
2587
+ function clamp01(x) {
2588
+ return Math.min(1, Math.max(0, x));
2589
+ }
2590
+ function reviewWeight(card, generatedScore, referenceScore) {
2591
+ if (card.reviewUrgency !== void 0 && generatedScore !== void 0 && generatedScore > 0) {
2592
+ return clamp01(card.reviewUrgency * (card.score / generatedScore));
2593
+ }
2594
+ return clamp01(card.score / referenceScore);
2595
+ }
2596
+ function reviewMassReading(reviews, generatedScores, config = DEFAULT_REGULATOR_CONFIG.reviewMass) {
2597
+ const mass = reviews.reduce(
2598
+ (m, c) => m + reviewWeight(c, generatedScores.get(c.cardId), config.referenceScore),
2599
+ 0
2600
+ );
2601
+ const multiplier = mass > config.healthyMass ? Math.pow(config.rate, (mass - config.healthyMass) / config.healthyMass) : 1;
2602
+ return {
2603
+ name: "review-mass",
2604
+ class: "review",
2605
+ urgency: mass,
2606
+ multiplier,
2607
+ applied: reviews.length,
2608
+ inputs: { due: reviews.length, mass, healthyMass: config.healthyMass }
2609
+ };
2610
+ }
2611
+ function resetIntakeClock(nowMs) {
2612
+ return { lastNewAt: new Date(nowMs).toISOString(), frozenMs: 0, unservableSince: null };
2613
+ }
2614
+ function frozenMsAt(state, nowMs) {
2615
+ const open = state.unservableSince ? Math.max(0, nowMs - Date.parse(state.unservableSince)) : 0;
2616
+ return state.frozenMs + open;
2617
+ }
2618
+ function intakeHours(state, nowMs) {
2619
+ const elapsed = nowMs - Date.parse(state.lastNewAt);
2620
+ return Math.max(0, elapsed - frozenMsAt(state, nowMs)) / 36e5;
2621
+ }
2622
+ function stepIntakeClock(state, nowMs, eligibleNew) {
2623
+ if (eligibleNew === 0 && !state.unservableSince) {
2624
+ return { ...state, unservableSince: new Date(nowMs).toISOString() };
2625
+ }
2626
+ if (eligibleNew > 0 && state.unservableSince) {
2627
+ return { ...state, frozenMs: frozenMsAt(state, nowMs), unservableSince: null };
2628
+ }
2629
+ return state;
2630
+ }
2631
+ function intakeReading(state, nowMs, counts, config = DEFAULT_REGULATOR_CONFIG.intake) {
2632
+ const hours = intakeHours(state, nowMs);
2633
+ const multiplier = counts.eligibleNew > 0 ? Math.pow(config.rate, hours / config.scaleHours) : 1;
2634
+ return {
2635
+ name: "intake",
2636
+ class: "new",
2637
+ urgency: hours,
2638
+ multiplier,
2639
+ applied: counts.eligibleNew,
2640
+ inputs: {
2641
+ hoursSinceNew: hours,
2642
+ frozenHours: frozenMsAt(state, nowMs) / 36e5,
2643
+ eligibleNew: counts.eligibleNew,
2644
+ newCandidates: counts.newCandidates
2645
+ }
2646
+ };
2647
+ }
2648
+ function applyReading(cards, reading) {
2649
+ if (reading.multiplier === 1) return;
2650
+ const reason = reading.name === "review-mass" ? `review mass ${reading.urgency.toFixed(1)} (healthy ${reading.inputs.healthyMass}) \u2192 \xD7${reading.multiplier.toFixed(2)}` : `${reading.urgency.toFixed(1)}h since a new card \u2192 \xD7${reading.multiplier.toFixed(2)}`;
2651
+ for (const card of cards) {
2652
+ card.score *= reading.multiplier;
2653
+ card.provenance.push({
2654
+ strategy: "regulator",
2655
+ strategyName: `Regulator: ${REGULATOR_LABEL[reading.name]}`,
2656
+ strategyId: `regulator-${reading.name}`,
2657
+ action: reading.multiplier > 1 ? "boosted" : "penalized",
2658
+ score: card.score,
2659
+ reason
2660
+ });
2661
+ }
2662
+ }
2663
+ var DEFAULT_REGULATOR_CONFIG, INTAKE_CLOCK_KEY, REGULATOR_LABEL;
2664
+ var init_regulators = __esm({
2665
+ "src/core/navigators/regulators.ts"() {
2666
+ "use strict";
2667
+ DEFAULT_REGULATOR_CONFIG = {
2668
+ reviewMass: { referenceScore: 0.95, healthyMass: 20, rate: 2 },
2669
+ intake: { rate: 2, scaleHours: 24 }
2670
+ };
2671
+ INTAKE_CLOCK_KEY = "IntakeClock";
2672
+ REGULATOR_LABEL = {
2673
+ "review-mass": "Review mass",
2674
+ intake: "Intake"
2675
+ };
2676
+ }
2677
+ });
2678
+
2563
2679
  // src/core/navigators/generators/srs.ts
2564
2680
  var srs_exports = {};
2565
2681
  __export(srs_exports, {
2566
2682
  default: () => SRSNavigator
2567
2683
  });
2568
- var import_moment, DEFAULT_HEALTHY_BACKLOG, BACKLOG_GROWTH_RATE, SRSNavigator;
2684
+ var import_moment, SRSNavigator;
2569
2685
  var init_srs = __esm({
2570
2686
  "src/core/navigators/generators/srs.ts"() {
2571
2687
  "use strict";
2572
2688
  import_moment = __toESM(require("moment"), 1);
2573
2689
  init_navigators();
2574
2690
  init_SrsDebugger();
2691
+ init_regulators();
2575
2692
  init_logger();
2576
- DEFAULT_HEALTHY_BACKLOG = 20;
2577
- BACKLOG_GROWTH_RATE = 2;
2578
2693
  SRSNavigator = class extends ContentNavigator {
2579
2694
  /** Human-readable name for CardGenerator interface */
2580
2695
  name;
2581
- /** Healthy backlog threshold - when exceeded, backlog pressure kicks in */
2582
- healthyBacklog;
2583
2696
  constructor(user, course, strategyData) {
2584
2697
  super(user, course, strategyData);
2585
2698
  this.name = strategyData?.name || "SRS";
2586
- const config = this.parseConfig(strategyData?.serializedData);
2587
- this.healthyBacklog = config.healthyBacklog ?? DEFAULT_HEALTHY_BACKLOG;
2588
- }
2589
- /**
2590
- * Parse configuration from serialized JSON.
2591
- */
2592
- parseConfig(serializedData) {
2593
- if (!serializedData) return {};
2594
- try {
2595
- return JSON.parse(serializedData);
2596
- } catch {
2597
- logger.warn("[SRS] Failed to parse strategy config, using defaults");
2598
- return {};
2599
- }
2600
2699
  }
2601
2700
  /**
2602
2701
  * Get review cards scored by urgency.
@@ -2604,7 +2703,6 @@ var init_srs = __esm({
2604
2703
  * Score formula combines:
2605
2704
  * - Relative overdueness: hoursOverdue / intervalHours
2606
2705
  * - Interval recency: exponential decay favoring shorter intervals
2607
- * - Backlog pressure: boost when due reviews exceed healthy threshold
2608
2706
  *
2609
2707
  * Cards not yet due are excluded (not scored as 0).
2610
2708
  *
@@ -2641,7 +2739,6 @@ var init_srs = __esm({
2641
2739
  }
2642
2740
  }
2643
2741
  }
2644
- const backlogMultiplier = this.computeBacklogMultiplier(dueReviews.length);
2645
2742
  const notDue = reviews.filter((r) => !now.isAfter(import_moment.default.utc(r.reviewTime)));
2646
2743
  let nextDueIn = null;
2647
2744
  if (notDue.length > 0) {
@@ -2652,9 +2749,8 @@ var init_srs = __esm({
2652
2749
  nextDueIn = until.asHours() < 1 ? `${Math.round(until.asMinutes())}m` : until.asHours() < 24 ? `${Math.round(until.asHours())}h` : `${Math.round(until.asDays())}d`;
2653
2750
  }
2654
2751
  if (dueReviews.length > 0) {
2655
- const pressureNote = backlogMultiplier > 1 ? ` [backlog pressure: \xD7${backlogMultiplier.toFixed(2)}]` : ` [healthy backlog]`;
2656
2752
  logger.info(
2657
- `[SRS] Course ${courseId}: ${dueReviews.length} reviews due now (of ${reviews.length} scheduled)${pressureNote}`
2753
+ `[SRS] Course ${courseId}: ${dueReviews.length} reviews due now (of ${reviews.length} scheduled)`
2658
2754
  );
2659
2755
  } else if (reviews.length > 0) {
2660
2756
  const sortedByDue = [...reviews].sort(
@@ -2671,11 +2767,12 @@ var init_srs = __esm({
2671
2767
  logger.info(`[SRS] Course ${courseId}: No reviews scheduled`);
2672
2768
  }
2673
2769
  const scored = dueReviews.map((review) => {
2674
- const { score, reason } = this.computeUrgencyScore(review, now, backlogMultiplier);
2770
+ const { score, urgency, reason } = this.computeUrgencyScore(review, now);
2675
2771
  return {
2676
2772
  cardId: review.cardId,
2677
2773
  courseId: review.courseId,
2678
2774
  score,
2775
+ reviewUrgency: urgency,
2679
2776
  reviewID: review._id,
2680
2777
  provenance: [
2681
2778
  {
@@ -2694,47 +2791,20 @@ var init_srs = __esm({
2694
2791
  courseId,
2695
2792
  scheduledTotal: reviews.length,
2696
2793
  dueNow: dueReviews.length,
2697
- healthyBacklog: this.healthyBacklog,
2698
- backlogMultiplier,
2699
- backlogGrowthRate: BACKLOG_GROWTH_RATE,
2794
+ healthyBacklog: DEFAULT_REGULATOR_CONFIG.reviewMass.healthyMass,
2795
+ reviewMass: null,
2796
+ backlogMultiplier: 1,
2797
+ backlogGrowthRate: DEFAULT_REGULATOR_CONFIG.reviewMass.rate,
2700
2798
  topReviewScore: sorted.length > 0 ? sorted[0].score : null,
2701
2799
  nextDueIn,
2702
2800
  timestamp: Date.now()
2703
2801
  });
2704
2802
  return { cards: sorted.slice(0, limit) };
2705
2803
  }
2706
- /**
2707
- * Compute the multiplicative backlog pressure based on number of due reviews.
2708
- *
2709
- * ×1.0 at or below the healthy threshold (no boost); above it, grows as
2710
- * BACKLOG_GROWTH_RATE raised to the excess expressed in multiples of the
2711
- * healthy threshold. Uncapped — self-regulating instead: reviews winning
2712
- * slots depletes dueCount, which drops the ratio and relaxes the multiplier
2713
- * next run.
2714
- *
2715
- * Examples (with default healthyBacklog=20, BACKLOG_GROWTH_RATE=1.5):
2716
- * - 10 due reviews → ×1.00 (healthy)
2717
- * - 20 due reviews → ×1.00 (at threshold, ratio 0)
2718
- * - 40 due reviews → ×1.50 (ratio 1, 2x threshold)
2719
- * - 60 due reviews → ×2.25 (ratio 2, 3x threshold — old hard cap was ×2.00 here)
2720
- * - 100 due reviews → ×5.06 (ratio 4, 5x threshold)
2721
- * - 160 due reviews → ×17.09 (ratio 7, 8x threshold)
2722
- *
2723
- * @param dueCount - Number of reviews currently due
2724
- * @returns Multiplier applied to review urgency (>= 1.0, unbounded)
2725
- */
2726
- computeBacklogMultiplier(dueCount) {
2727
- if (dueCount <= this.healthyBacklog) {
2728
- return 1;
2729
- }
2730
- const excess = dueCount - this.healthyBacklog;
2731
- const ratio = excess / this.healthyBacklog;
2732
- return Math.pow(BACKLOG_GROWTH_RATE, ratio);
2733
- }
2734
2804
  /**
2735
2805
  * Compute urgency score for a review card.
2736
2806
  *
2737
- * Three factors:
2807
+ * Two factors:
2738
2808
  * 1. Relative overdueness = hoursOverdue / intervalHours
2739
2809
  * - 2 days overdue on 3-day interval = 0.67 (urgent)
2740
2810
  * - 2 days overdue on 180-day interval = 0.01 (not urgent)
@@ -2744,20 +2814,14 @@ var init_srs = __esm({
2744
2814
  * - 30 days (720h) → ~0.56
2745
2815
  * - 180 days → ~0.30
2746
2816
  *
2747
- * 3. Backlog pressure = global *multiplier* when review backlog exceeds the
2748
- * healthy threshold (×1.0 healthy → exponential growth, uncapped, above it).
2749
- *
2750
- * Combined: (base 0.5 + urgency factors * 0.45) × backlog multiplier.
2751
- * Per-card range before pressure: ~0.57–0.95. NOT clamped to 1.0 — under a
2752
- * heavy backlog reviews scale onto the open scale to compete with (and exceed)
2753
- * new cards; there's no ceiling at all now, so a bad enough backlog always
2754
- * wins eventually — self-regulating because winning slots depletes dueCount.
2817
+ * Combined: base 0.5 + urgency factors * 0.45, so ~0.57–0.95 per card.
2818
+ * Backlog pressure is applied later, by the regulator stage, which can lift
2819
+ * reviews onto the open scale above new cards (see regulators.ts).
2755
2820
  *
2756
2821
  * @param review - The scheduled card to score
2757
2822
  * @param now - Current time
2758
- * @param backlogMultiplier - Pre-computed backlog multiplier (>= 1.0, unbounded)
2759
2823
  */
2760
- computeUrgencyScore(review, now, backlogMultiplier) {
2824
+ computeUrgencyScore(review, now) {
2761
2825
  const scheduledAt = import_moment.default.utc(review.scheduledAt);
2762
2826
  const due = import_moment.default.utc(review.reviewTime);
2763
2827
  const intervalHours = Math.max(1, due.diff(scheduledAt, "hours"));
@@ -2766,20 +2830,16 @@ var init_srs = __esm({
2766
2830
  const recencyFactor = 0.3 + 0.7 * Math.exp(-intervalHours / 720);
2767
2831
  const overdueContribution = Math.min(1, Math.max(0, relativeOverdue));
2768
2832
  const urgency = overdueContribution * 0.5 + recencyFactor * 0.5;
2769
- const baseScore = 0.5 + urgency * 0.45;
2770
- const score = baseScore * backlogMultiplier;
2833
+ const score = 0.5 + urgency * 0.45;
2771
2834
  const reasonParts = [
2772
2835
  `${Math.round(hoursOverdue)}h overdue`,
2773
2836
  `interval: ${Math.round(intervalHours)}h`,
2774
2837
  `relative: ${relativeOverdue.toFixed(2)}`,
2775
2838
  `recency: ${recencyFactor.toFixed(2)}`
2776
2839
  ];
2777
- if (backlogMultiplier > 1) {
2778
- reasonParts.push(`backlog: \xD7${backlogMultiplier.toFixed(2)}`);
2779
- }
2780
2840
  reasonParts.push("review");
2781
2841
  const reason = reasonParts.join(", ");
2782
- return { score, reason };
2842
+ return { score, urgency, reason };
2783
2843
  }
2784
2844
  };
2785
2845
  }
@@ -2834,6 +2894,8 @@ var init_WeightedFilter = __esm({
2834
2894
  init_contentNavigationStrategy();
2835
2895
  WeightedFilter = class {
2836
2896
  name;
2897
+ kind;
2898
+ liveOnly;
2837
2899
  inner;
2838
2900
  learnable;
2839
2901
  staticWeight;
@@ -2841,6 +2903,8 @@ var init_WeightedFilter = __esm({
2841
2903
  constructor(inner, learnable = DEFAULT_LEARNABLE_WEIGHT, staticWeight = false, strategyId) {
2842
2904
  this.inner = inner;
2843
2905
  this.name = inner.name;
2906
+ this.kind = inner.kind;
2907
+ this.liveOnly = inner.liveOnly;
2844
2908
  this.learnable = learnable;
2845
2909
  this.staticWeight = staticWeight;
2846
2910
  this.strategyId = strategyId;
@@ -2905,58 +2969,175 @@ var init_WeightedFilter = __esm({
2905
2969
  // src/core/navigators/filters/eloDistance.ts
2906
2970
  var eloDistance_exports = {};
2907
2971
  __export(eloDistance_exports, {
2908
- DEFAULT_HALF_LIFE: () => DEFAULT_HALF_LIFE,
2909
- DEFAULT_MAX_MULTIPLIER: () => DEFAULT_MAX_MULTIPLIER,
2910
- DEFAULT_MIN_MULTIPLIER: () => DEFAULT_MIN_MULTIPLIER,
2911
- createEloDistanceFilter: () => createEloDistanceFilter
2972
+ DEFAULT_ELO_DISTANCE_CONFIG: () => DEFAULT_ELO_DISTANCE_CONFIG,
2973
+ createEloDistanceFilter: () => createEloDistanceFilter,
2974
+ default: () => EloDistanceFilter,
2975
+ mountMultiDimEloToggle: () => mountMultiDimEloToggle,
2976
+ tagAwareGap: () => tagAwareGap
2912
2977
  });
2913
2978
  function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
2914
2979
  const normalizedDistance = distance / halfLife;
2915
2980
  const decay = Math.exp(-(normalizedDistance * normalizedDistance));
2916
2981
  return minMultiplier + (maxMultiplier - minMultiplier) * decay;
2917
2982
  }
2983
+ function resolveConfig(config) {
2984
+ return { ...DEFAULT_ELO_DISTANCE_CONFIG, ...config };
2985
+ }
2986
+ function readMultiDimElo() {
2987
+ try {
2988
+ return typeof localStorage !== "undefined" && localStorage.getItem(MULTI_DIM_ELO_KEY) === "true";
2989
+ } catch {
2990
+ return false;
2991
+ }
2992
+ }
2993
+ function mountMultiDimEloToggle() {
2994
+ if (typeof window === "undefined") return;
2995
+ const win = window;
2996
+ win.skuilder = win.skuilder || {};
2997
+ Object.defineProperty(win.skuilder, "multiDimElo", {
2998
+ configurable: true,
2999
+ enumerable: true,
3000
+ get: () => multiDimElo,
3001
+ set: (on) => {
3002
+ multiDimElo = on === true;
3003
+ try {
3004
+ if (multiDimElo) localStorage.setItem(MULTI_DIM_ELO_KEY, "true");
3005
+ else localStorage.removeItem(MULTI_DIM_ELO_KEY);
3006
+ } catch (e) {
3007
+ logger.warn(`[EloDistance] multiDimElo not persisted (localStorage unavailable): ${e}`);
3008
+ }
3009
+ logger.info(
3010
+ `[EloDistance] multiDimElo ${multiDimElo ? "on: tag-aware" : "off: per strategy config"} ELO distance from the next replan`
3011
+ );
3012
+ }
3013
+ });
3014
+ }
3015
+ function tagAwareGap(cardTags, cardElo, userElo, minTagCount) {
3016
+ const globalGap = cardElo.global.score - userElo.global.score;
3017
+ const tags = [];
3018
+ for (const tag of cardTags) {
3019
+ const user = userElo.tags[tag];
3020
+ if (!user || user.score === COUNT_ONLY_SENTINEL || user.count < minTagCount) continue;
3021
+ const card = cardElo.tags[tag]?.score ?? cardElo.global.score;
3022
+ tags.push({
3023
+ tag,
3024
+ gap: card - user.score,
3025
+ weight: user.count / (user.count + TAG_CONFIDENCE_HALF)
3026
+ });
3027
+ }
3028
+ if (tags.length === 0) return { gap: globalGap, globalGap, tags };
3029
+ const total = tags.reduce((w, t) => w + t.weight, 0);
3030
+ const tagGap = tags.reduce((g, t) => g + t.weight * t.gap, 0) / total;
3031
+ const lambda = total / (total + 1);
3032
+ return { gap: lambda * tagGap + (1 - lambda) * globalGap, globalGap, tags };
3033
+ }
3034
+ function tagReason(tags, globalGap) {
3035
+ const shown = [...tags].sort((a, b) => Math.abs(b.gap) * b.weight - Math.abs(a.gap) * a.weight).slice(0, 3).map((t) => `${t.tag} ${t.gap >= 0 ? "+" : ""}${Math.round(t.gap)}`).join(", ");
3036
+ const more = tags.length > 3 ? `, +${tags.length - 3} more` : "";
3037
+ return ` on ${tags.length} shared tag(s) [${shown}${more}] (global ${globalGap >= 0 ? "+" : ""}${Math.round(globalGap)})`;
3038
+ }
3039
+ async function applyEloDistance(cards, context, config, source) {
3040
+ const { course, userElo, userCourseElo } = context;
3041
+ const { halfLife, minMultiplier, maxMultiplier } = config;
3042
+ const tagAware = (config.tagAware || multiDimElo) && userCourseElo !== void 0;
3043
+ const missing = cards.filter((c) => tagAware || c.cardElo === void 0).map((c) => c.cardId);
3044
+ const fetched = /* @__PURE__ */ new Map();
3045
+ if (missing.length > 0) {
3046
+ const elos = await course.getCardEloData(missing);
3047
+ missing.forEach((id, i) => {
3048
+ if (elos[i]) fetched.set(id, elos[i]);
3049
+ });
3050
+ }
3051
+ return cards.map((card) => {
3052
+ const full = fetched.get(card.cardId);
3053
+ const cardElo = full?.global?.score ?? card.cardElo ?? DEFAULT_CARD_ELO;
3054
+ let distance = Math.abs(cardElo - userElo);
3055
+ let how = "";
3056
+ if (tagAware) {
3057
+ const t = full ? tagAwareGap(card.tags ?? [], full, userCourseElo, config.minTagCount) : void 0;
3058
+ if (t) distance = Math.abs(t.gap);
3059
+ how = t?.tags.length ? `, tag-aware${tagReason(t.tags, t.globalGap)}` : ", tag-aware: global (no shared tags)";
3060
+ }
3061
+ const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
3062
+ const newScore = card.score * multiplier;
3063
+ const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
3064
+ return {
3065
+ ...card,
3066
+ cardElo,
3067
+ score: newScore,
3068
+ provenance: [
3069
+ ...card.provenance,
3070
+ {
3071
+ strategy: "eloDistance",
3072
+ strategyName: source.name,
3073
+ strategyId: source.strategyId,
3074
+ action,
3075
+ score: newScore,
3076
+ reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)})${how} \u2192 ${multiplier.toFixed(2)}x`
3077
+ }
3078
+ ]
3079
+ };
3080
+ });
3081
+ }
2918
3082
  function createEloDistanceFilter(config) {
2919
- const halfLife = config?.halfLife ?? DEFAULT_HALF_LIFE;
2920
- const minMultiplier = config?.minMultiplier ?? DEFAULT_MIN_MULTIPLIER;
2921
- const maxMultiplier = config?.maxMultiplier ?? DEFAULT_MAX_MULTIPLIER;
3083
+ const resolved = resolveConfig(config);
3084
+ const source = { name: "ELO Distance Filter", strategyId: "ELO_DISTANCE_FILTER" };
2922
3085
  return {
2923
- name: "ELO Distance Filter",
2924
- async transform(cards, context) {
2925
- const { course, userElo } = context;
2926
- const cardIds = cards.map((c) => c.cardId);
2927
- const cardElos = await course.getCardEloData(cardIds);
2928
- return cards.map((card, i) => {
2929
- const cardElo = cardElos[i]?.global?.score ?? 1e3;
2930
- const distance = Math.abs(cardElo - userElo);
2931
- const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
2932
- const newScore = card.score * multiplier;
2933
- const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
2934
- return {
2935
- ...card,
2936
- score: newScore,
2937
- provenance: [
2938
- ...card.provenance,
2939
- {
2940
- strategy: "eloDistance",
2941
- strategyName: "ELO Distance Filter",
2942
- strategyId: "ELO_DISTANCE_FILTER",
2943
- action,
2944
- score: newScore,
2945
- reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)}) \u2192 ${multiplier.toFixed(2)}x`
2946
- }
2947
- ]
2948
- };
2949
- });
2950
- }
3086
+ name: source.name,
3087
+ kind: "signal",
3088
+ liveOnly: true,
3089
+ transform: (cards, context) => applyEloDistance(cards, context, resolved, source)
2951
3090
  };
2952
3091
  }
2953
- var DEFAULT_HALF_LIFE, DEFAULT_MIN_MULTIPLIER, DEFAULT_MAX_MULTIPLIER;
3092
+ var DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, COUNT_ONLY_SENTINEL, DEFAULT_CARD_ELO, MULTI_DIM_ELO_KEY, multiDimElo, EloDistanceFilter;
2954
3093
  var init_eloDistance = __esm({
2955
3094
  "src/core/navigators/filters/eloDistance.ts"() {
2956
3095
  "use strict";
2957
- DEFAULT_HALF_LIFE = 200;
2958
- DEFAULT_MIN_MULTIPLIER = 0.3;
2959
- DEFAULT_MAX_MULTIPLIER = 1;
3096
+ init_navigators();
3097
+ init_logger();
3098
+ DEFAULT_ELO_DISTANCE_CONFIG = {
3099
+ halfLife: 300,
3100
+ minMultiplier: 0.05,
3101
+ maxMultiplier: 1,
3102
+ tagAware: false,
3103
+ minTagCount: 3
3104
+ };
3105
+ TAG_CONFIDENCE_HALF = 10;
3106
+ COUNT_ONLY_SENTINEL = -1;
3107
+ DEFAULT_CARD_ELO = 1e3;
3108
+ MULTI_DIM_ELO_KEY = "skuilder:multiDimElo";
3109
+ multiDimElo = readMultiDimElo();
3110
+ mountMultiDimEloToggle();
3111
+ EloDistanceFilter = class _EloDistanceFilter extends ContentNavigator {
3112
+ name;
3113
+ /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
3114
+ static kind = "signal";
3115
+ kind = _EloDistanceFilter.kind;
3116
+ liveOnly = true;
3117
+ config;
3118
+ constructor(user, course, strategyData) {
3119
+ super(user, course, strategyData);
3120
+ this.name = strategyData.name || "ELO Distance";
3121
+ let parsed;
3122
+ try {
3123
+ parsed = strategyData.serializedData ? JSON.parse(strategyData.serializedData) : void 0;
3124
+ } catch {
3125
+ parsed = void 0;
3126
+ }
3127
+ this.config = resolveConfig(parsed);
3128
+ }
3129
+ transform(cards, context) {
3130
+ return applyEloDistance(cards, context, this.config, {
3131
+ name: this.name,
3132
+ strategyId: this.strategyId || "NAVIGATION_STRATEGY-eloDistance-default"
3133
+ });
3134
+ }
3135
+ async getWeightedCards(_limit) {
3136
+ throw new Error(
3137
+ "EloDistanceFilter is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
3138
+ );
3139
+ }
3140
+ };
2960
3141
  }
2961
3142
  });
2962
3143
 
@@ -2973,10 +3154,13 @@ var init_hierarchyDefinition = __esm({
2973
3154
  import_common6 = require("@vue-skuilder/common");
2974
3155
  init_logger();
2975
3156
  DEFAULT_MIN_COUNT2 = 3;
2976
- HierarchyDefinitionNavigator = class extends ContentNavigator {
3157
+ HierarchyDefinitionNavigator = class _HierarchyDefinitionNavigator extends ContentNavigator {
2977
3158
  config;
2978
3159
  /** Human-readable name for CardFilter interface */
2979
3160
  name;
3161
+ /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
3162
+ static kind = "gate";
3163
+ kind = _HierarchyDefinitionNavigator.kind;
2980
3164
  constructor(user, course, strategyData) {
2981
3165
  super(user, course, strategyData);
2982
3166
  this.config = this.parseConfig(strategyData.serializedData);
@@ -3243,10 +3427,13 @@ var init_userTagPreference = __esm({
3243
3427
  "src/core/navigators/filters/userTagPreference.ts"() {
3244
3428
  "use strict";
3245
3429
  init_navigators();
3246
- UserTagPreferenceFilter = class extends ContentNavigator {
3430
+ UserTagPreferenceFilter = class _UserTagPreferenceFilter extends ContentNavigator {
3247
3431
  _strategyData;
3248
3432
  /** Human-readable name for CardFilter interface */
3249
3433
  name;
3434
+ /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
3435
+ static kind = "signal";
3436
+ kind = _UserTagPreferenceFilter.kind;
3250
3437
  constructor(user, course, strategyData) {
3251
3438
  super(user, course, strategyData);
3252
3439
  this._strategyData = strategyData;
@@ -3356,6 +3543,7 @@ var init_userTagPreference = __esm({
3356
3543
  // src/core/navigators/filters/index.ts
3357
3544
  var filters_exports = {};
3358
3545
  __export(filters_exports, {
3546
+ EloDistanceFilter: () => EloDistanceFilter,
3359
3547
  UserTagPreferenceFilter: () => UserTagPreferenceFilter,
3360
3548
  createEloDistanceFilter: () => createEloDistanceFilter
3361
3549
  });
@@ -3394,10 +3582,13 @@ var init_interferenceMitigator = __esm({
3394
3582
  DEFAULT_MIN_COUNT3 = 10;
3395
3583
  DEFAULT_MIN_ELAPSED_DAYS = 3;
3396
3584
  DEFAULT_INTERFERENCE_DECAY = 0.8;
3397
- InterferenceMitigatorNavigator = class extends ContentNavigator {
3585
+ InterferenceMitigatorNavigator = class _InterferenceMitigatorNavigator extends ContentNavigator {
3398
3586
  config;
3399
3587
  /** Human-readable name for CardFilter interface */
3400
3588
  name;
3589
+ /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
3590
+ static kind = "signal";
3591
+ kind = _InterferenceMitigatorNavigator.kind;
3401
3592
  /** Precomputed map: tag -> set of { partner, decay } it interferes with */
3402
3593
  interferenceMap;
3403
3594
  constructor(user, course, strategyData) {
@@ -3613,10 +3804,13 @@ var init_relativePriority = __esm({
3613
3804
  DEFAULT_PRIORITY = 0.5;
3614
3805
  DEFAULT_PRIORITY_INFLUENCE = 0.5;
3615
3806
  DEFAULT_COMBINE_MODE = "max";
3616
- RelativePriorityNavigator = class extends ContentNavigator {
3807
+ RelativePriorityNavigator = class _RelativePriorityNavigator extends ContentNavigator {
3617
3808
  config;
3618
3809
  /** Human-readable name for CardFilter interface */
3619
3810
  name;
3811
+ /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
3812
+ static kind = "signal";
3813
+ kind = _RelativePriorityNavigator.kind;
3620
3814
  constructor(user, course, strategyData) {
3621
3815
  super(user, course, strategyData);
3622
3816
  this.config = this.parseConfig(strategyData.serializedData);
@@ -4024,6 +4218,8 @@ var init_Pipeline = __esm({
4024
4218
  init_orchestration();
4025
4219
  init_PipelineDebugger();
4026
4220
  init_diversityRerank();
4221
+ init_regulators();
4222
+ init_SrsDebugger();
4027
4223
  VERBOSE_RESULTS = true;
4028
4224
  Pipeline = class extends ContentNavigator {
4029
4225
  generator;
@@ -4049,6 +4245,13 @@ var init_Pipeline = __esm({
4049
4245
  * getWeightedCards() call, then cleared.
4050
4246
  */
4051
4247
  _ephemeralHints = null;
4248
+ /**
4249
+ * The intake valve's clock (see regulators.ts), loaded from strategy state on
4250
+ * first use and kept in memory. Writes are chained so a presentation and a
4251
+ * run can't race each other's revision.
4252
+ */
4253
+ _intakeClock = null;
4254
+ _intakeClockWrite = Promise.resolve();
4052
4255
  /**
4053
4256
  * Create a new pipeline.
4054
4257
  *
@@ -4123,13 +4326,12 @@ var init_Pipeline = __esm({
4123
4326
  }
4124
4327
  }
4125
4328
  generatorSummaries = Array.from(genMap.entries()).map(([name, data]) => {
4126
- const newCards = data.cards.filter((c) => c.provenance[0]?.reason?.includes("new card"));
4127
- const reviewCards = data.cards.filter((c) => c.provenance[0]?.reason?.includes("review"));
4329
+ const reviewCount = data.cards.filter((c) => c.reviewID).length;
4128
4330
  return {
4129
4331
  name,
4130
4332
  cardCount: data.cards.length,
4131
- newCount: newCards.length,
4132
- reviewCount: reviewCards.length,
4333
+ newCount: data.cards.length - reviewCount,
4334
+ reviewCount,
4133
4335
  topScore: Math.max(...data.cards.map((c) => c.score), 0)
4134
4336
  };
4135
4337
  });
@@ -4165,19 +4367,24 @@ var init_Pipeline = __esm({
4165
4367
  cards.filter((c) => c.provenance.some((p) => p.strategy === "prescribed")).map((c) => c.cardId)
4166
4368
  );
4167
4369
  const filterImpacts = [];
4370
+ const generatedScores = new Map(cards.map((c) => [c.cardId, c.score]));
4371
+ const gated = /* @__PURE__ */ new Set();
4168
4372
  for (const filter of this.filters) {
4169
4373
  const beforeCount = cards.length;
4170
4374
  const beforeScores = new Map(cards.map((c) => [c.cardId, c.score]));
4171
4375
  cards = await filter.transform(cards, context);
4172
4376
  let boosted = 0, penalized = 0, passed = 0;
4173
4377
  const removed = beforeCount - cards.length;
4378
+ const kind = filter.kind ?? "gate";
4174
4379
  for (const card of cards) {
4175
4380
  const before = beforeScores.get(card.cardId) ?? 0;
4176
4381
  if (card.score > before) boosted++;
4177
- else if (card.score < before) penalized++;
4178
- else passed++;
4382
+ else if (card.score < before) {
4383
+ penalized++;
4384
+ if (kind === "gate") gated.add(card.cardId);
4385
+ } else passed++;
4179
4386
  }
4180
- filterImpacts.push({ name: filter.name, boosted, penalized, passed, removed });
4387
+ filterImpacts.push({ name: filter.name, kind, boosted, penalized, passed, removed });
4181
4388
  if (prescribedIds.size > 0) {
4182
4389
  const survivingIds = new Set(cards.map((c) => c.cardId));
4183
4390
  const killedPrescribed = [...prescribedIds].filter((id) => !survivingIds.has(id));
@@ -4193,6 +4400,7 @@ var init_Pipeline = __esm({
4193
4400
  }
4194
4401
  const scoredCards = cards;
4195
4402
  cards = cards.filter((c) => c.score > 0);
4403
+ const regulators = await this.regulate(cards, generatedScores, gated);
4196
4404
  const hints = this._ephemeralHints;
4197
4405
  if (hints) {
4198
4406
  this._ephemeralHints = null;
@@ -4229,7 +4437,8 @@ var init_Pipeline = __esm({
4229
4437
  result,
4230
4438
  context.userElo,
4231
4439
  hints ?? void 0,
4232
- scoredCards
4440
+ scoredCards,
4441
+ regulators
4233
4442
  );
4234
4443
  captureRun(report);
4235
4444
  } catch (e) {
@@ -4408,6 +4617,77 @@ var init_Pipeline = __esm({
4408
4617
  logger.info(`[Pipeline] Hints applied: ${beforeCount} \u2192 ${cards.length} cards`);
4409
4618
  return cards;
4410
4619
  }
4620
+ /**
4621
+ * The regulator stage: measure each class's pressure and scale it.
4622
+ *
4623
+ * - Review mass: every due review's SRS urgency times the filters' net
4624
+ * effect on it.
4625
+ * - Intake: servable hours since a new card was presented, applied only to
4626
+ * eligible new cards (no gate penalized them). With none eligible, the
4627
+ * clock freezes.
4628
+ *
4629
+ * Mutates `cards` in place; returns the readings for the run report.
4630
+ */
4631
+ async regulate(cards, generatedScores, gated) {
4632
+ const config = DEFAULT_REGULATOR_CONFIG;
4633
+ const reviews = cards.filter((c) => c.reviewID);
4634
+ const newCards = cards.filter((c) => !c.reviewID);
4635
+ const eligibleNew = newCards.filter((c) => !gated.has(c.cardId));
4636
+ const mass = reviewMassReading(reviews, generatedScores, config.reviewMass);
4637
+ applyReading(reviews, mass);
4638
+ noteReviewPressure(this.course.getCourseID(), {
4639
+ mass: mass.urgency,
4640
+ healthyMass: config.reviewMass.healthyMass,
4641
+ rate: config.reviewMass.rate,
4642
+ multiplier: mass.multiplier
4643
+ });
4644
+ const now = Date.now();
4645
+ const clock = await this.loadIntakeClock(now);
4646
+ const stepped = stepIntakeClock(clock, now, eligibleNew.length);
4647
+ if (stepped !== clock) this.saveIntakeClock(stepped);
4648
+ const intake = intakeReading(
4649
+ stepped,
4650
+ now,
4651
+ { eligibleNew: eligibleNew.length, newCandidates: newCards.length },
4652
+ config.intake
4653
+ );
4654
+ applyReading(eligibleNew, intake);
4655
+ logger.info(
4656
+ `[Pipeline:regulators] review mass ${mass.urgency.toFixed(1)} over ${reviews.length} due \u2192 \xD7${mass.multiplier.toFixed(2)}; intake ${intake.urgency.toFixed(1)}h, ${eligibleNew.length}/${newCards.length} new eligible \u2192 \xD7${intake.multiplier.toFixed(2)}`
4657
+ );
4658
+ return [mass, intake];
4659
+ }
4660
+ /**
4661
+ * A card was presented. A new card's first presentation discharges the
4662
+ * intake valve: its clock restarts. Called by the SessionController.
4663
+ */
4664
+ notePresented(card) {
4665
+ if (card.status !== "new" || card.courseId !== this.course?.getCourseID()) return;
4666
+ this.saveIntakeClock(resetIntakeClock(Date.now()));
4667
+ }
4668
+ async loadIntakeClock(nowMs) {
4669
+ if (this._intakeClock) return this._intakeClock;
4670
+ let stored = null;
4671
+ try {
4672
+ stored = await this.user.getStrategyState(
4673
+ this.course.getCourseID(),
4674
+ INTAKE_CLOCK_KEY
4675
+ );
4676
+ } catch (e) {
4677
+ logger.warn(`[Pipeline:regulators] Could not read the intake clock: ${e}`);
4678
+ }
4679
+ if (stored) {
4680
+ this._intakeClock = stored;
4681
+ } else {
4682
+ this.saveIntakeClock(resetIntakeClock(nowMs));
4683
+ }
4684
+ return this._intakeClock;
4685
+ }
4686
+ saveIntakeClock(state) {
4687
+ this._intakeClock = state;
4688
+ const courseId = this.course.getCourseID();
4689
+ this._intakeClockWrite = this._intakeClockWrite.then(() => this.user.putStrategyState(courseId, INTAKE_CLOCK_KEY, state)).catch((e) => logger.warn(`[Pipeline:regulators] Could not save the intake clock: ${e}`));
4690
+ }
4411
4691
  /**
4412
4692
  * Build shared context for generator and filters.
4413
4693
  *
@@ -4418,10 +4698,11 @@ var init_Pipeline = __esm({
4418
4698
  */
4419
4699
  async buildContext() {
4420
4700
  let userElo = 1e3;
4701
+ let userCourseElo;
4421
4702
  try {
4422
4703
  const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
4423
- const courseElo = (0, import_common8.toCourseElo)(courseReg.elo);
4424
- userElo = courseElo.global.score;
4704
+ userCourseElo = (0, import_common8.toCourseElo)(courseReg.elo);
4705
+ userElo = userCourseElo.global.score;
4425
4706
  } catch (e) {
4426
4707
  logger.debug(`[Pipeline] Could not get user ELO, using default: ${e}`);
4427
4708
  }
@@ -4433,6 +4714,7 @@ var init_Pipeline = __esm({
4433
4714
  user: this.user,
4434
4715
  course: this.course,
4435
4716
  userElo,
4717
+ ...userCourseElo ? { userCourseElo } : {},
4436
4718
  orchestration
4437
4719
  };
4438
4720
  }
@@ -4546,7 +4828,7 @@ var init_Pipeline = __esm({
4546
4828
  cards = await this.hydrateTags(cards);
4547
4829
  const fullPool = cards.slice();
4548
4830
  const context = await this.buildContext();
4549
- for (const filter of this.filters) {
4831
+ for (const filter of this.forecastFilters()) {
4550
4832
  cards = await filter.transform(cards, context);
4551
4833
  }
4552
4834
  if (opts?.hints) {
@@ -4565,6 +4847,14 @@ var init_Pipeline = __esm({
4565
4847
  cards.sort((a, b) => b.score - a.score);
4566
4848
  return opts?.limit ? cards.slice(0, opts.limit) : cards;
4567
4849
  }
4850
+ /**
4851
+ * The filters a forecast or card-space scan applies. Those start every card at
4852
+ * 1.0 without a generator, so they skip `liveOnly` filters (ELO distance),
4853
+ * which only make sense against generator scores.
4854
+ */
4855
+ forecastFilters() {
4856
+ return this.filters.filter((f) => !f.liveOnly);
4857
+ }
4568
4858
  /**
4569
4859
  * Scan every card in the course through the filter chain and report
4570
4860
  * how many are "well indicated" (score >= threshold) for the current user.
@@ -4586,7 +4876,7 @@ var init_Pipeline = __esm({
4586
4876
  cards = await this.hydrateTags(cards);
4587
4877
  const context = await this.buildContext();
4588
4878
  const filterBreakdown = [];
4589
- for (const filter of this.filters) {
4879
+ for (const filter of this.forecastFilters()) {
4590
4880
  cards = await filter.transform(cards, context);
4591
4881
  const wi = cards.filter((c) => c.score >= THRESHOLD).length;
4592
4882
  filterBreakdown.push({ name: filter.name, wellIndicated: wi });
@@ -4650,6 +4940,7 @@ var init_Pipeline = __esm({
4650
4940
  // src/core/navigators/defaults.ts
4651
4941
  var defaults_exports = {};
4652
4942
  __export(defaults_exports, {
4943
+ createDefaultEloDistanceStrategy: () => createDefaultEloDistanceStrategy,
4653
4944
  createDefaultEloStrategy: () => createDefaultEloStrategy,
4654
4945
  createDefaultPipeline: () => createDefaultPipeline,
4655
4946
  createDefaultSrsStrategy: () => createDefaultSrsStrategy
@@ -4676,12 +4967,28 @@ function createDefaultSrsStrategy(courseId) {
4676
4967
  serializedData: ""
4677
4968
  };
4678
4969
  }
4970
+ function createDefaultEloDistanceStrategy(courseId) {
4971
+ return {
4972
+ _id: "NAVIGATION_STRATEGY-eloDistance-default",
4973
+ docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
4974
+ name: "ELO Distance (default)",
4975
+ description: "Scales every candidate, new or review, by its distance from the learner's ELO",
4976
+ implementingClass: "eloDistance" /* ELO_DISTANCE */,
4977
+ course: courseId,
4978
+ // Explicit, though the filter would default to it anyway: views show what runs.
4979
+ serializedData: JSON.stringify(DEFAULT_ELO_DISTANCE_CONFIG)
4980
+ };
4981
+ }
4679
4982
  function createDefaultPipeline(user, course) {
4680
4983
  const courseId = course.getCourseID();
4681
4984
  const eloNavigator = new ELONavigator(user, course, createDefaultEloStrategy(courseId));
4682
4985
  const srsNavigator = new SRSNavigator(user, course, createDefaultSrsStrategy(courseId));
4683
4986
  const compositeGenerator = new CompositeGenerator([eloNavigator, srsNavigator]);
4684
- const eloDistanceFilter = createEloDistanceFilter();
4987
+ const eloDistanceFilter = new EloDistanceFilter(
4988
+ user,
4989
+ course,
4990
+ createDefaultEloDistanceStrategy(courseId)
4991
+ );
4685
4992
  return new Pipeline(compositeGenerator, [eloDistanceFilter], user, course);
4686
4993
  }
4687
4994
  var init_defaults = __esm({
@@ -4697,6 +5004,131 @@ var init_defaults = __esm({
4697
5004
  }
4698
5005
  });
4699
5006
 
5007
+ // src/core/navigators/pipelinePlan.ts
5008
+ var pipelinePlan_exports = {};
5009
+ __export(pipelinePlan_exports, {
5010
+ PIPELINE_STAGES: () => PIPELINE_STAGES,
5011
+ planPipeline: () => planPipeline
5012
+ });
5013
+ function planned(strategy, role, origin) {
5014
+ const kind = role === "filter" /* FILTER */ ? getRegisteredFilterKind(strategy.implementingClass) : void 0;
5015
+ return {
5016
+ role,
5017
+ origin,
5018
+ name: strategy.name,
5019
+ implementingClass: strategy.implementingClass,
5020
+ strategy,
5021
+ ...kind ? { kind } : {}
5022
+ };
5023
+ }
5024
+ function planPipeline(strategies, courseId) {
5025
+ if (strategies.length === 0) {
5026
+ return {
5027
+ kind: "default",
5028
+ generators: [
5029
+ planned(createDefaultEloStrategy(courseId), "generator" /* GENERATOR */, "default-pipeline"),
5030
+ planned(createDefaultSrsStrategy(courseId), "generator" /* GENERATOR */, "default-pipeline")
5031
+ ],
5032
+ filters: [
5033
+ planned(
5034
+ createDefaultEloDistanceStrategy(courseId),
5035
+ "filter" /* FILTER */,
5036
+ "default-pipeline"
5037
+ )
5038
+ ],
5039
+ skipped: [],
5040
+ warnings: [],
5041
+ notes: [],
5042
+ regulators: DEFAULT_REGULATOR_CONFIG
5043
+ };
5044
+ }
5045
+ const generators = [];
5046
+ const filters = [];
5047
+ const skipped = [];
5048
+ const warnings = [];
5049
+ for (const s of strategies) {
5050
+ if (isGenerator(s.implementingClass)) {
5051
+ generators.push(planned(s, "generator" /* GENERATOR */, "strategy-doc"));
5052
+ } else if (isFilter(s.implementingClass)) {
5053
+ filters.push(planned(s, "filter" /* FILTER */, "strategy-doc"));
5054
+ } else {
5055
+ skipped.push({ strategy: s, reason: "not a registered generator or filter" });
5056
+ warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
5057
+ }
5058
+ }
5059
+ const declared = new Set(generators.map((g) => g.implementingClass));
5060
+ if (!declared.has(createDefaultEloStrategy(courseId).implementingClass)) {
5061
+ generators.push(
5062
+ planned(createDefaultEloStrategy(courseId), "generator" /* GENERATOR */, "assembler-default")
5063
+ );
5064
+ }
5065
+ if (!declared.has(createDefaultSrsStrategy(courseId).implementingClass)) {
5066
+ generators.push(
5067
+ planned(createDefaultSrsStrategy(courseId), "generator" /* GENERATOR */, "assembler-default")
5068
+ );
5069
+ }
5070
+ const eloDistance = createDefaultEloDistanceStrategy(courseId);
5071
+ if (!filters.some((f) => f.implementingClass === eloDistance.implementingClass)) {
5072
+ filters.push(planned(eloDistance, "filter" /* FILTER */, "assembler-default"));
5073
+ }
5074
+ filters.sort((a, b) => a.name.localeCompare(b.name));
5075
+ return {
5076
+ kind: "assembled",
5077
+ generators,
5078
+ filters,
5079
+ skipped,
5080
+ warnings,
5081
+ notes: [],
5082
+ regulators: DEFAULT_REGULATOR_CONFIG
5083
+ };
5084
+ }
5085
+ var PIPELINE_STAGES;
5086
+ var init_pipelinePlan = __esm({
5087
+ "src/core/navigators/pipelinePlan.ts"() {
5088
+ "use strict";
5089
+ init_navigators();
5090
+ init_regulators();
5091
+ init_defaults();
5092
+ PIPELINE_STAGES = [
5093
+ {
5094
+ key: "generate",
5095
+ title: "Generate",
5096
+ summary: "Each generator proposes candidates (up to 500 in all), scored on what is specific to its source. A card proposed by several generators keeps their mean score, raised 10% per extra generator."
5097
+ },
5098
+ {
5099
+ key: "filter",
5100
+ title: "Filter",
5101
+ summary: "Each filter multiplies candidate scores, in the order shown. A gate says a card is not ready yet; a signal expresses preference. Gates usually penalize rather than remove, so a gated card stays in the pool at a low score."
5102
+ },
5103
+ {
5104
+ key: "drop-zero",
5105
+ title: "Drop zero scores",
5106
+ summary: "Candidates whose score reached 0 leave the pool."
5107
+ },
5108
+ {
5109
+ key: "regulate",
5110
+ title: "Regulate",
5111
+ summary: "Balances reviews against new cards. Review mass: the due reviews weighed by their filtered scores; above a healthy level, every review is lifted. Intake: hours since a new card was last presented; new cards no gate penalized are lifted, and the clock stops while there are none."
5112
+ },
5113
+ {
5114
+ key: "hints",
5115
+ title: "Apply hints",
5116
+ summary: "The session's hints (from the app: an intro's follow-up, a difficulty boost) exclude, boost, or require cards. Required cards skip the filters entirely."
5117
+ },
5118
+ {
5119
+ key: "diversity",
5120
+ title: "Diversity re-rank",
5121
+ summary: "Demotes candidates that repeat a distinctive tag already ranked above them, so one concept or answer cannot take the whole head of the queue. Sees this run only, not what the session already served."
5122
+ },
5123
+ {
5124
+ key: "select",
5125
+ title: "Select",
5126
+ summary: "Highest scores first, up to the run's limit. The session mixes them into its supply queue."
5127
+ }
5128
+ ];
5129
+ }
5130
+ });
5131
+
4700
5132
  // src/core/navigators/PipelineAssembler.ts
4701
5133
  var PipelineAssembler_exports = {};
4702
5134
  __export(PipelineAssembler_exports, {
@@ -4711,16 +5143,16 @@ var init_PipelineAssembler = __esm({
4711
5143
  init_Pipeline();
4712
5144
  init_logger();
4713
5145
  init_CompositeGenerator();
4714
- init_defaults();
5146
+ init_pipelinePlan();
4715
5147
  PipelineAssembler = class {
4716
5148
  /**
4717
5149
  * Assembles a navigation pipeline from strategy documents.
4718
5150
  *
4719
- * 1. Separates into generators and filters by role
4720
- * 2. Validates at least one generator exists (or creates default ELO)
4721
- * 3. Instantiates generators - wraps multiple in CompositeGenerator
4722
- * 4. Instantiates filters
4723
- * 5. Returns Pipeline(generator, filters)
5151
+ * 1. Plans: classifies by role, adds default ELO/SRS and ELO distance, orders filters
5152
+ * (`planPipeline`)
5153
+ * 2. Instantiates generators - wraps multiple in CompositeGenerator
5154
+ * 3. Instantiates filters
5155
+ * 4. Returns Pipeline(generator, filters)
4724
5156
  *
4725
5157
  * @param input - Strategy documents plus user/course interfaces
4726
5158
  * @returns Assembled pipeline and any warnings
@@ -4736,28 +5168,17 @@ var init_PipelineAssembler = __esm({
4736
5168
  warnings
4737
5169
  };
4738
5170
  }
4739
- const generatorStrategies = [];
4740
- const filterStrategies = [];
4741
- for (const s of strategies) {
4742
- if (isGenerator(s.implementingClass)) {
4743
- generatorStrategies.push(s);
4744
- } else if (isFilter(s.implementingClass)) {
4745
- filterStrategies.push(s);
4746
- } else {
4747
- warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
5171
+ const plan = planPipeline(strategies, course.getCourseID());
5172
+ warnings.push(...plan.warnings);
5173
+ for (const n of [...plan.generators, ...plan.filters]) {
5174
+ if (n.origin === "assembler-default") {
5175
+ logger.debug(
5176
+ `[PipelineAssembler] No ${n.implementingClass} ${n.role} configured, adding default`
5177
+ );
4748
5178
  }
4749
5179
  }
4750
- const courseId = course.getCourseID();
4751
- const hasElo = generatorStrategies.some((s) => s.implementingClass === "elo" /* ELO */);
4752
- const hasSrs = generatorStrategies.some((s) => s.implementingClass === "srs" /* SRS */);
4753
- if (!hasElo) {
4754
- logger.debug("[PipelineAssembler] No ELO generator configured, adding default");
4755
- generatorStrategies.push(createDefaultEloStrategy(courseId));
4756
- }
4757
- if (!hasSrs) {
4758
- logger.debug("[PipelineAssembler] No SRS generator configured, adding default");
4759
- generatorStrategies.push(createDefaultSrsStrategy(courseId));
4760
- }
5180
+ const generatorStrategies = plan.generators.map((g) => g.strategy);
5181
+ const sortedFilterStrategies = plan.filters.map((f) => f.strategy);
4761
5182
  if (generatorStrategies.length === 0) {
4762
5183
  warnings.push("No generator strategy found");
4763
5184
  return {
@@ -4779,9 +5200,6 @@ var init_PipelineAssembler = __esm({
4779
5200
  generator = await CompositeGenerator.fromStrategies(user, course, generatorStrategies);
4780
5201
  }
4781
5202
  const filters = [];
4782
- const sortedFilterStrategies = [...filterStrategies].sort(
4783
- (a, b) => a.name.localeCompare(b.name)
4784
- );
4785
5203
  for (const filterStrategy of sortedFilterStrategies) {
4786
5204
  try {
4787
5205
  const nav = await ContentNavigator.create(user, course, filterStrategy);
@@ -4849,7 +5267,9 @@ var init_3 = __esm({
4849
5267
  "./generators/prescribed.ts": () => Promise.resolve().then(() => (init_prescribed(), prescribed_exports)),
4850
5268
  "./generators/srs.ts": () => Promise.resolve().then(() => (init_srs(), srs_exports)),
4851
5269
  "./generators/types.ts": () => Promise.resolve().then(() => (init_types(), types_exports)),
4852
- "./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports))
5270
+ "./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports)),
5271
+ "./pipelinePlan.ts": () => Promise.resolve().then(() => (init_pipelinePlan(), pipelinePlan_exports)),
5272
+ "./regulators.ts": () => Promise.resolve().then(() => (init_regulators(), regulators_exports))
4853
5273
  });
4854
5274
  }
4855
5275
  });
@@ -4870,6 +5290,7 @@ __export(navigators_exports, {
4870
5290
  drainCapturedRuns: () => drainCapturedRuns,
4871
5291
  getActivePipeline: () => getActivePipeline,
4872
5292
  getCardOrigin: () => getCardOrigin,
5293
+ getRegisteredFilterKind: () => getRegisteredFilterKind,
4873
5294
  getRegisteredNavigator: () => getRegisteredNavigator,
4874
5295
  getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
4875
5296
  getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
@@ -4898,6 +5319,10 @@ function hasRegisteredNavigator(implementingClass) {
4898
5319
  function getRegisteredNavigatorRole(implementingClass) {
4899
5320
  return navigatorRegistry.get(implementingClass)?.role;
4900
5321
  }
5322
+ function getRegisteredFilterKind(implementingClass) {
5323
+ const ctor = navigatorRegistry.get(implementingClass)?.constructor;
5324
+ return ctor?.kind;
5325
+ }
4901
5326
  function getRegisteredNavigatorNames() {
4902
5327
  return Array.from(navigatorRegistry.keys());
4903
5328
  }
@@ -4915,17 +5340,20 @@ async function initializeNavigatorRegistry() {
4915
5340
  hierarchyModule,
4916
5341
  interferenceModule,
4917
5342
  relativePriorityModule,
4918
- userTagPreferenceModule
5343
+ userTagPreferenceModule,
5344
+ eloDistanceModule
4919
5345
  ] = await Promise.all([
4920
5346
  Promise.resolve().then(() => (init_hierarchyDefinition(), hierarchyDefinition_exports)),
4921
5347
  Promise.resolve().then(() => (init_interferenceMitigator(), interferenceMitigator_exports)),
4922
5348
  Promise.resolve().then(() => (init_relativePriority(), relativePriority_exports)),
4923
- Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports))
5349
+ Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports)),
5350
+ Promise.resolve().then(() => (init_eloDistance(), eloDistance_exports))
4924
5351
  ]);
4925
5352
  registerNavigator("hierarchyDefinition", hierarchyModule.default);
4926
5353
  registerNavigator("interferenceMitigator", interferenceModule.default);
4927
5354
  registerNavigator("relativePriority", relativePriorityModule.default);
4928
5355
  registerNavigator("userTagPreference", userTagPreferenceModule.default);
5356
+ registerNavigator("eloDistance", eloDistanceModule.default);
4929
5357
  logger.debug(
4930
5358
  `[NavigatorRegistry] Initialized ${navigatorRegistry.size} navigators: ${getRegisteredNavigatorNames().join(", ")}`
4931
5359
  );
@@ -4973,6 +5401,7 @@ var init_navigators = __esm({
4973
5401
  Navigators2["INTERFERENCE"] = "interferenceMitigator";
4974
5402
  Navigators2["RELATIVE_PRIORITY"] = "relativePriority";
4975
5403
  Navigators2["USER_TAG_PREFERENCE"] = "userTagPreference";
5404
+ Navigators2["ELO_DISTANCE"] = "eloDistance";
4976
5405
  return Navigators2;
4977
5406
  })(Navigators || {});
4978
5407
  NavigatorRole = /* @__PURE__ */ ((NavigatorRole2) => {
@@ -4987,7 +5416,8 @@ var init_navigators = __esm({
4987
5416
  ["hierarchyDefinition" /* HIERARCHY */]: "filter" /* FILTER */,
4988
5417
  ["interferenceMitigator" /* INTERFERENCE */]: "filter" /* FILTER */,
4989
5418
  ["relativePriority" /* RELATIVE_PRIORITY */]: "filter" /* FILTER */,
4990
- ["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER */
5419
+ ["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER */,
5420
+ ["eloDistance" /* ELO_DISTANCE */]: "filter" /* FILTER */
4991
5421
  };
4992
5422
  ContentNavigator = class {
4993
5423
  /** User interface for this navigation session */
@@ -6831,10 +7261,11 @@ function backlogHtml(backlog) {
6831
7261
  const rows = backlog.map((b) => {
6832
7262
  const hot = b.backlogMultiplier >= 3;
6833
7263
  const multColor = b.backlogMultiplier <= 1 ? "#86efac" : hot ? "#fca5a5" : "#fcd34d";
6834
- const headroom = b.backlogMultiplier > 1 ? `climbing (\xD7${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog}-review excess, unbounded)` : "healthy \u2014 no pressure";
7264
+ const headroom = b.backlogMultiplier > 1 ? `climbing (\xD7${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog} of mass in excess, unbounded)` : "healthy \u2014 no pressure";
7265
+ const mass = b.reviewMass !== null ? ` \xB7 mass ${b.reviewMass.toFixed(1)}` : "";
6835
7266
  const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
6836
7267
  const next = b.nextDueIn ? ` <span style="opacity:.6">\xB7 next due ${esc(b.nextDueIn)}</span>` : "";
6837
- return `<div style="margin-left:6px"><span style="opacity:.7">${esc(b.courseId.slice(0, 8))}</span> due ${b.dueNow}/${b.scheduledTotal} <span style="opacity:.6">(healthy ${b.healthyBacklog})</span>${next}<div style="margin-left:6px">pressure <span style="color:${multColor}">\xD7${b.backlogMultiplier.toFixed(2)}</span> <span style="opacity:.6">${headroom} \xB7 top review ${top}</span></div></div>`;
7268
+ return `<div style="margin-left:6px"><span style="opacity:.7">${esc(b.courseId.slice(0, 8))}</span> due ${b.dueNow}/${b.scheduledTotal}${mass} <span style="opacity:.6">(healthy mass ${b.healthyBacklog})</span>${next}<div style="margin-left:6px">pressure <span style="color:${multColor}">\xD7${b.backlogMultiplier.toFixed(2)}</span> <span style="opacity:.6">${headroom} \xB7 top review ${top}</span></div></div>`;
6838
7269
  }).join("");
6839
7270
  return `<div style="margin-bottom:6px"><div style="color:#93c5fd">review backpressure</div>${rows}</div>`;
6840
7271
  }
@@ -6973,8 +7404,9 @@ function snapshotToText(s) {
6973
7404
  const headroom = b.backlogMultiplier > 1 ? "climbing" : "healthy";
6974
7405
  const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
6975
7406
  const next = b.nextDueIn ? `, next due ${b.nextDueIn}` : "";
7407
+ const mass = b.reviewMass !== null ? `, mass ${b.reviewMass.toFixed(1)}` : "";
6976
7408
  lines.push(
6977
- ` ${b.courseId.slice(0, 8)}: due ${b.dueNow}/${b.scheduledTotal} (healthy ${b.healthyBacklog})${next}; pressure \xD7${b.backlogMultiplier.toFixed(2)} ${headroom}; top review ${top}`
7409
+ ` ${b.courseId.slice(0, 8)}: due ${b.dueNow}/${b.scheduledTotal}${mass} (healthy mass ${b.healthyBacklog})${next}; pressure \xD7${b.backlogMultiplier.toFixed(2)} ${headroom}; top review ${top}`
6978
7410
  );
6979
7411
  }
6980
7412
  }
@@ -9999,6 +10431,11 @@ var init_courseDB3 = __esm({
9999
10431
  setEphemeralHints(hints) {
10000
10432
  this._pendingHints = hints;
10001
10433
  }
10434
+ /** Forward a presentation to the navigator (a new card restarts its intake clock). */
10435
+ notePresented(card) {
10436
+ if (card.status !== "new") return;
10437
+ void this.createNavigator(this.userDB).then((navigator2) => navigator2.notePresented?.(card)).catch((e) => logger.warn(`[static/courseDB] Could not note a presentation: ${e}`));
10438
+ }
10002
10439
  async getWeightedCards(limit) {
10003
10440
  try {
10004
10441
  const navigator2 = await this.createNavigator(this.userDB);