@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
@@ -776,7 +776,7 @@ function parseCardElo(provenance) {
776
776
  const match = eloEntry.reason.match(/card:\s*(\d+)/);
777
777
  return match ? parseInt(match[1], 10) : void 0;
778
778
  }
779
- function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints, scoredCards) {
779
+ function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints, scoredCards, regulators) {
780
780
  const selectedIds = new Set(selectedCards.map((c) => c.cardId));
781
781
  const toReport = (card) => ({
782
782
  cardId: card.cardId,
@@ -784,7 +784,7 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
784
784
  origin: getOrigin(card),
785
785
  generator: card.provenance[0]?.strategyName || card.provenance[0]?.strategy,
786
786
  finalScore: card.score,
787
- cardElo: parseCardElo(card.provenance),
787
+ cardElo: card.cardElo ?? parseCardElo(card.provenance),
788
788
  provenance: card.provenance,
789
789
  tags: card.tags,
790
790
  selected: selectedIds.has(card.cardId)
@@ -862,7 +862,8 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
862
862
  newSelected,
863
863
  cards,
864
864
  unselectedNew,
865
- discardedTail
865
+ discardedTail,
866
+ ...regulators ? { regulators } : {}
866
867
  };
867
868
  }
868
869
  function formatProvenance(provenance) {
@@ -1586,11 +1587,23 @@ var SrsDebugger_exports = {};
1586
1587
  __export(SrsDebugger_exports, {
1587
1588
  captureSrsBacklog: () => captureSrsBacklog,
1588
1589
  clearSrsBacklogDebug: () => clearSrsBacklogDebug,
1589
- getSrsBacklogDebug: () => getSrsBacklogDebug
1590
+ getSrsBacklogDebug: () => getSrsBacklogDebug,
1591
+ noteReviewPressure: () => noteReviewPressure
1590
1592
  });
1591
1593
  function captureSrsBacklog(snapshot) {
1592
1594
  snapshots.set(snapshot.courseId, snapshot);
1593
1595
  }
1596
+ function noteReviewPressure(courseId, pressure) {
1597
+ const snapshot = snapshots.get(courseId);
1598
+ if (!snapshot) return;
1599
+ snapshots.set(courseId, {
1600
+ ...snapshot,
1601
+ reviewMass: pressure.mass,
1602
+ healthyBacklog: pressure.healthyMass,
1603
+ backlogGrowthRate: pressure.rate,
1604
+ backlogMultiplier: pressure.multiplier
1605
+ });
1606
+ }
1594
1607
  function getSrsBacklogDebug() {
1595
1608
  return [...snapshots.values()].sort((a, b) => b.timestamp - a.timestamp);
1596
1609
  }
@@ -1869,13 +1882,12 @@ __export(elo_exports, {
1869
1882
  default: () => ELONavigator
1870
1883
  });
1871
1884
  import { toCourseElo as toCourseElo2 } from "@vue-skuilder/common";
1872
- var ELO_RELEVANCE_SIGMA, ELONavigator;
1885
+ var ELONavigator;
1873
1886
  var init_elo = __esm({
1874
1887
  "src/core/navigators/generators/elo.ts"() {
1875
1888
  "use strict";
1876
1889
  init_navigators();
1877
1890
  init_logger();
1878
- ELO_RELEVANCE_SIGMA = 300;
1879
1891
  ELONavigator = class extends ContentNavigator {
1880
1892
  /** Human-readable name for CardGenerator interface */
1881
1893
  name;
@@ -1884,10 +1896,8 @@ var init_elo = __esm({
1884
1896
  this.name = strategyData?.name || "ELO";
1885
1897
  }
1886
1898
  /**
1887
- * Get new cards with suitability scores based on ELO distance.
1888
- *
1889
- * Cards closer to user's ELO get higher scores.
1890
- * Score formula: max(0, 1 - distance / 500)
1899
+ * Get the new cards nearest the learner's ELO, each scored with a flat
1900
+ * jitter in [0.5, 1]. Carries each card's ELO for the ELO distance filter.
1891
1901
  *
1892
1902
  * NOTE: This generator only handles NEW cards. Reviews are handled by
1893
1903
  * SRSNavigator. Use CompositeGenerator to combine both.
@@ -1915,20 +1925,20 @@ var init_elo = __esm({
1915
1925
  const scored = newCards.map((c) => {
1916
1926
  const cardElo = c.elo ?? 1e3;
1917
1927
  const distance = Math.abs(cardElo - userGlobalElo);
1918
- const relevance = Math.exp(-((distance / ELO_RELEVANCE_SIGMA) ** 2));
1919
- const samplingKey = relevance * (0.5 + 0.5 * Math.random());
1928
+ const jitter = 0.5 + 0.5 * Math.random();
1920
1929
  return {
1921
1930
  cardId: c.cardID,
1922
1931
  courseId: c.courseID,
1923
- score: samplingKey,
1932
+ score: jitter,
1933
+ cardElo,
1924
1934
  provenance: [
1925
1935
  {
1926
1936
  strategy: "elo",
1927
1937
  strategyName: this.strategyName || this.name,
1928
1938
  strategyId: this.strategyId || "NAVIGATION_STRATEGY-ELO-default",
1929
1939
  action: "generated",
1930
- score: samplingKey,
1931
- reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}), relevance ${relevance.toFixed(3)}, key ${samplingKey.toFixed(3)}`
1940
+ score: jitter,
1941
+ reason: `new card near learner ELO: distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}), jitter ${jitter.toFixed(3)}`
1932
1942
  }
1933
1943
  ]
1934
1944
  };
@@ -2804,43 +2814,132 @@ var init_prescribed = __esm({
2804
2814
  }
2805
2815
  });
2806
2816
 
2817
+ // src/core/navigators/regulators.ts
2818
+ var regulators_exports = {};
2819
+ __export(regulators_exports, {
2820
+ DEFAULT_REGULATOR_CONFIG: () => DEFAULT_REGULATOR_CONFIG,
2821
+ INTAKE_CLOCK_KEY: () => INTAKE_CLOCK_KEY,
2822
+ applyReading: () => applyReading,
2823
+ frozenMsAt: () => frozenMsAt,
2824
+ intakeHours: () => intakeHours,
2825
+ intakeReading: () => intakeReading,
2826
+ resetIntakeClock: () => resetIntakeClock,
2827
+ reviewMassReading: () => reviewMassReading,
2828
+ reviewWeight: () => reviewWeight,
2829
+ stepIntakeClock: () => stepIntakeClock
2830
+ });
2831
+ function clamp01(x) {
2832
+ return Math.min(1, Math.max(0, x));
2833
+ }
2834
+ function reviewWeight(card, generatedScore, referenceScore) {
2835
+ if (card.reviewUrgency !== void 0 && generatedScore !== void 0 && generatedScore > 0) {
2836
+ return clamp01(card.reviewUrgency * (card.score / generatedScore));
2837
+ }
2838
+ return clamp01(card.score / referenceScore);
2839
+ }
2840
+ function reviewMassReading(reviews, generatedScores, config = DEFAULT_REGULATOR_CONFIG.reviewMass) {
2841
+ const mass = reviews.reduce(
2842
+ (m, c) => m + reviewWeight(c, generatedScores.get(c.cardId), config.referenceScore),
2843
+ 0
2844
+ );
2845
+ const multiplier = mass > config.healthyMass ? Math.pow(config.rate, (mass - config.healthyMass) / config.healthyMass) : 1;
2846
+ return {
2847
+ name: "review-mass",
2848
+ class: "review",
2849
+ urgency: mass,
2850
+ multiplier,
2851
+ applied: reviews.length,
2852
+ inputs: { due: reviews.length, mass, healthyMass: config.healthyMass }
2853
+ };
2854
+ }
2855
+ function resetIntakeClock(nowMs) {
2856
+ return { lastNewAt: new Date(nowMs).toISOString(), frozenMs: 0, unservableSince: null };
2857
+ }
2858
+ function frozenMsAt(state, nowMs) {
2859
+ const open = state.unservableSince ? Math.max(0, nowMs - Date.parse(state.unservableSince)) : 0;
2860
+ return state.frozenMs + open;
2861
+ }
2862
+ function intakeHours(state, nowMs) {
2863
+ const elapsed = nowMs - Date.parse(state.lastNewAt);
2864
+ return Math.max(0, elapsed - frozenMsAt(state, nowMs)) / 36e5;
2865
+ }
2866
+ function stepIntakeClock(state, nowMs, eligibleNew) {
2867
+ if (eligibleNew === 0 && !state.unservableSince) {
2868
+ return { ...state, unservableSince: new Date(nowMs).toISOString() };
2869
+ }
2870
+ if (eligibleNew > 0 && state.unservableSince) {
2871
+ return { ...state, frozenMs: frozenMsAt(state, nowMs), unservableSince: null };
2872
+ }
2873
+ return state;
2874
+ }
2875
+ function intakeReading(state, nowMs, counts, config = DEFAULT_REGULATOR_CONFIG.intake) {
2876
+ const hours = intakeHours(state, nowMs);
2877
+ const multiplier = counts.eligibleNew > 0 ? Math.pow(config.rate, hours / config.scaleHours) : 1;
2878
+ return {
2879
+ name: "intake",
2880
+ class: "new",
2881
+ urgency: hours,
2882
+ multiplier,
2883
+ applied: counts.eligibleNew,
2884
+ inputs: {
2885
+ hoursSinceNew: hours,
2886
+ frozenHours: frozenMsAt(state, nowMs) / 36e5,
2887
+ eligibleNew: counts.eligibleNew,
2888
+ newCandidates: counts.newCandidates
2889
+ }
2890
+ };
2891
+ }
2892
+ function applyReading(cards, reading) {
2893
+ if (reading.multiplier === 1) return;
2894
+ 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)}`;
2895
+ for (const card of cards) {
2896
+ card.score *= reading.multiplier;
2897
+ card.provenance.push({
2898
+ strategy: "regulator",
2899
+ strategyName: `Regulator: ${REGULATOR_LABEL[reading.name]}`,
2900
+ strategyId: `regulator-${reading.name}`,
2901
+ action: reading.multiplier > 1 ? "boosted" : "penalized",
2902
+ score: card.score,
2903
+ reason
2904
+ });
2905
+ }
2906
+ }
2907
+ var DEFAULT_REGULATOR_CONFIG, INTAKE_CLOCK_KEY, REGULATOR_LABEL;
2908
+ var init_regulators = __esm({
2909
+ "src/core/navigators/regulators.ts"() {
2910
+ "use strict";
2911
+ DEFAULT_REGULATOR_CONFIG = {
2912
+ reviewMass: { referenceScore: 0.95, healthyMass: 20, rate: 2 },
2913
+ intake: { rate: 2, scaleHours: 24 }
2914
+ };
2915
+ INTAKE_CLOCK_KEY = "IntakeClock";
2916
+ REGULATOR_LABEL = {
2917
+ "review-mass": "Review mass",
2918
+ intake: "Intake"
2919
+ };
2920
+ }
2921
+ });
2922
+
2807
2923
  // src/core/navigators/generators/srs.ts
2808
2924
  var srs_exports = {};
2809
2925
  __export(srs_exports, {
2810
2926
  default: () => SRSNavigator
2811
2927
  });
2812
2928
  import moment from "moment";
2813
- var DEFAULT_HEALTHY_BACKLOG, BACKLOG_GROWTH_RATE, SRSNavigator;
2929
+ var SRSNavigator;
2814
2930
  var init_srs = __esm({
2815
2931
  "src/core/navigators/generators/srs.ts"() {
2816
2932
  "use strict";
2817
2933
  init_navigators();
2818
2934
  init_SrsDebugger();
2935
+ init_regulators();
2819
2936
  init_logger();
2820
- DEFAULT_HEALTHY_BACKLOG = 20;
2821
- BACKLOG_GROWTH_RATE = 2;
2822
2937
  SRSNavigator = class extends ContentNavigator {
2823
2938
  /** Human-readable name for CardGenerator interface */
2824
2939
  name;
2825
- /** Healthy backlog threshold - when exceeded, backlog pressure kicks in */
2826
- healthyBacklog;
2827
2940
  constructor(user, course, strategyData) {
2828
2941
  super(user, course, strategyData);
2829
2942
  this.name = strategyData?.name || "SRS";
2830
- const config = this.parseConfig(strategyData?.serializedData);
2831
- this.healthyBacklog = config.healthyBacklog ?? DEFAULT_HEALTHY_BACKLOG;
2832
- }
2833
- /**
2834
- * Parse configuration from serialized JSON.
2835
- */
2836
- parseConfig(serializedData) {
2837
- if (!serializedData) return {};
2838
- try {
2839
- return JSON.parse(serializedData);
2840
- } catch {
2841
- logger.warn("[SRS] Failed to parse strategy config, using defaults");
2842
- return {};
2843
- }
2844
2943
  }
2845
2944
  /**
2846
2945
  * Get review cards scored by urgency.
@@ -2848,7 +2947,6 @@ var init_srs = __esm({
2848
2947
  * Score formula combines:
2849
2948
  * - Relative overdueness: hoursOverdue / intervalHours
2850
2949
  * - Interval recency: exponential decay favoring shorter intervals
2851
- * - Backlog pressure: boost when due reviews exceed healthy threshold
2852
2950
  *
2853
2951
  * Cards not yet due are excluded (not scored as 0).
2854
2952
  *
@@ -2885,7 +2983,6 @@ var init_srs = __esm({
2885
2983
  }
2886
2984
  }
2887
2985
  }
2888
- const backlogMultiplier = this.computeBacklogMultiplier(dueReviews.length);
2889
2986
  const notDue = reviews.filter((r) => !now.isAfter(moment.utc(r.reviewTime)));
2890
2987
  let nextDueIn = null;
2891
2988
  if (notDue.length > 0) {
@@ -2896,9 +2993,8 @@ var init_srs = __esm({
2896
2993
  nextDueIn = until.asHours() < 1 ? `${Math.round(until.asMinutes())}m` : until.asHours() < 24 ? `${Math.round(until.asHours())}h` : `${Math.round(until.asDays())}d`;
2897
2994
  }
2898
2995
  if (dueReviews.length > 0) {
2899
- const pressureNote = backlogMultiplier > 1 ? ` [backlog pressure: \xD7${backlogMultiplier.toFixed(2)}]` : ` [healthy backlog]`;
2900
2996
  logger.info(
2901
- `[SRS] Course ${courseId}: ${dueReviews.length} reviews due now (of ${reviews.length} scheduled)${pressureNote}`
2997
+ `[SRS] Course ${courseId}: ${dueReviews.length} reviews due now (of ${reviews.length} scheduled)`
2902
2998
  );
2903
2999
  } else if (reviews.length > 0) {
2904
3000
  const sortedByDue = [...reviews].sort(
@@ -2915,11 +3011,12 @@ var init_srs = __esm({
2915
3011
  logger.info(`[SRS] Course ${courseId}: No reviews scheduled`);
2916
3012
  }
2917
3013
  const scored = dueReviews.map((review) => {
2918
- const { score, reason } = this.computeUrgencyScore(review, now, backlogMultiplier);
3014
+ const { score, urgency, reason } = this.computeUrgencyScore(review, now);
2919
3015
  return {
2920
3016
  cardId: review.cardId,
2921
3017
  courseId: review.courseId,
2922
3018
  score,
3019
+ reviewUrgency: urgency,
2923
3020
  reviewID: review._id,
2924
3021
  provenance: [
2925
3022
  {
@@ -2938,47 +3035,20 @@ var init_srs = __esm({
2938
3035
  courseId,
2939
3036
  scheduledTotal: reviews.length,
2940
3037
  dueNow: dueReviews.length,
2941
- healthyBacklog: this.healthyBacklog,
2942
- backlogMultiplier,
2943
- backlogGrowthRate: BACKLOG_GROWTH_RATE,
3038
+ healthyBacklog: DEFAULT_REGULATOR_CONFIG.reviewMass.healthyMass,
3039
+ reviewMass: null,
3040
+ backlogMultiplier: 1,
3041
+ backlogGrowthRate: DEFAULT_REGULATOR_CONFIG.reviewMass.rate,
2944
3042
  topReviewScore: sorted.length > 0 ? sorted[0].score : null,
2945
3043
  nextDueIn,
2946
3044
  timestamp: Date.now()
2947
3045
  });
2948
3046
  return { cards: sorted.slice(0, limit) };
2949
3047
  }
2950
- /**
2951
- * Compute the multiplicative backlog pressure based on number of due reviews.
2952
- *
2953
- * ×1.0 at or below the healthy threshold (no boost); above it, grows as
2954
- * BACKLOG_GROWTH_RATE raised to the excess expressed in multiples of the
2955
- * healthy threshold. Uncapped — self-regulating instead: reviews winning
2956
- * slots depletes dueCount, which drops the ratio and relaxes the multiplier
2957
- * next run.
2958
- *
2959
- * Examples (with default healthyBacklog=20, BACKLOG_GROWTH_RATE=1.5):
2960
- * - 10 due reviews → ×1.00 (healthy)
2961
- * - 20 due reviews → ×1.00 (at threshold, ratio 0)
2962
- * - 40 due reviews → ×1.50 (ratio 1, 2x threshold)
2963
- * - 60 due reviews → ×2.25 (ratio 2, 3x threshold — old hard cap was ×2.00 here)
2964
- * - 100 due reviews → ×5.06 (ratio 4, 5x threshold)
2965
- * - 160 due reviews → ×17.09 (ratio 7, 8x threshold)
2966
- *
2967
- * @param dueCount - Number of reviews currently due
2968
- * @returns Multiplier applied to review urgency (>= 1.0, unbounded)
2969
- */
2970
- computeBacklogMultiplier(dueCount) {
2971
- if (dueCount <= this.healthyBacklog) {
2972
- return 1;
2973
- }
2974
- const excess = dueCount - this.healthyBacklog;
2975
- const ratio = excess / this.healthyBacklog;
2976
- return Math.pow(BACKLOG_GROWTH_RATE, ratio);
2977
- }
2978
3048
  /**
2979
3049
  * Compute urgency score for a review card.
2980
3050
  *
2981
- * Three factors:
3051
+ * Two factors:
2982
3052
  * 1. Relative overdueness = hoursOverdue / intervalHours
2983
3053
  * - 2 days overdue on 3-day interval = 0.67 (urgent)
2984
3054
  * - 2 days overdue on 180-day interval = 0.01 (not urgent)
@@ -2988,20 +3058,14 @@ var init_srs = __esm({
2988
3058
  * - 30 days (720h) → ~0.56
2989
3059
  * - 180 days → ~0.30
2990
3060
  *
2991
- * 3. Backlog pressure = global *multiplier* when review backlog exceeds the
2992
- * healthy threshold (×1.0 healthy → exponential growth, uncapped, above it).
2993
- *
2994
- * Combined: (base 0.5 + urgency factors * 0.45) × backlog multiplier.
2995
- * Per-card range before pressure: ~0.57–0.95. NOT clamped to 1.0 — under a
2996
- * heavy backlog reviews scale onto the open scale to compete with (and exceed)
2997
- * new cards; there's no ceiling at all now, so a bad enough backlog always
2998
- * wins eventually — self-regulating because winning slots depletes dueCount.
3061
+ * Combined: base 0.5 + urgency factors * 0.45, so ~0.57–0.95 per card.
3062
+ * Backlog pressure is applied later, by the regulator stage, which can lift
3063
+ * reviews onto the open scale above new cards (see regulators.ts).
2999
3064
  *
3000
3065
  * @param review - The scheduled card to score
3001
3066
  * @param now - Current time
3002
- * @param backlogMultiplier - Pre-computed backlog multiplier (>= 1.0, unbounded)
3003
3067
  */
3004
- computeUrgencyScore(review, now, backlogMultiplier) {
3068
+ computeUrgencyScore(review, now) {
3005
3069
  const scheduledAt = moment.utc(review.scheduledAt);
3006
3070
  const due = moment.utc(review.reviewTime);
3007
3071
  const intervalHours = Math.max(1, due.diff(scheduledAt, "hours"));
@@ -3010,20 +3074,16 @@ var init_srs = __esm({
3010
3074
  const recencyFactor = 0.3 + 0.7 * Math.exp(-intervalHours / 720);
3011
3075
  const overdueContribution = Math.min(1, Math.max(0, relativeOverdue));
3012
3076
  const urgency = overdueContribution * 0.5 + recencyFactor * 0.5;
3013
- const baseScore = 0.5 + urgency * 0.45;
3014
- const score = baseScore * backlogMultiplier;
3077
+ const score = 0.5 + urgency * 0.45;
3015
3078
  const reasonParts = [
3016
3079
  `${Math.round(hoursOverdue)}h overdue`,
3017
3080
  `interval: ${Math.round(intervalHours)}h`,
3018
3081
  `relative: ${relativeOverdue.toFixed(2)}`,
3019
3082
  `recency: ${recencyFactor.toFixed(2)}`
3020
3083
  ];
3021
- if (backlogMultiplier > 1) {
3022
- reasonParts.push(`backlog: \xD7${backlogMultiplier.toFixed(2)}`);
3023
- }
3024
3084
  reasonParts.push("review");
3025
3085
  const reason = reasonParts.join(", ");
3026
- return { score, reason };
3086
+ return { score, urgency, reason };
3027
3087
  }
3028
3088
  };
3029
3089
  }
@@ -3078,6 +3138,8 @@ var init_WeightedFilter = __esm({
3078
3138
  init_contentNavigationStrategy();
3079
3139
  WeightedFilter = class {
3080
3140
  name;
3141
+ kind;
3142
+ liveOnly;
3081
3143
  inner;
3082
3144
  learnable;
3083
3145
  staticWeight;
@@ -3085,6 +3147,8 @@ var init_WeightedFilter = __esm({
3085
3147
  constructor(inner, learnable = DEFAULT_LEARNABLE_WEIGHT, staticWeight = false, strategyId) {
3086
3148
  this.inner = inner;
3087
3149
  this.name = inner.name;
3150
+ this.kind = inner.kind;
3151
+ this.liveOnly = inner.liveOnly;
3088
3152
  this.learnable = learnable;
3089
3153
  this.staticWeight = staticWeight;
3090
3154
  this.strategyId = strategyId;
@@ -3149,58 +3213,175 @@ var init_WeightedFilter = __esm({
3149
3213
  // src/core/navigators/filters/eloDistance.ts
3150
3214
  var eloDistance_exports = {};
3151
3215
  __export(eloDistance_exports, {
3152
- DEFAULT_HALF_LIFE: () => DEFAULT_HALF_LIFE,
3153
- DEFAULT_MAX_MULTIPLIER: () => DEFAULT_MAX_MULTIPLIER,
3154
- DEFAULT_MIN_MULTIPLIER: () => DEFAULT_MIN_MULTIPLIER,
3155
- createEloDistanceFilter: () => createEloDistanceFilter
3216
+ DEFAULT_ELO_DISTANCE_CONFIG: () => DEFAULT_ELO_DISTANCE_CONFIG,
3217
+ createEloDistanceFilter: () => createEloDistanceFilter,
3218
+ default: () => EloDistanceFilter,
3219
+ mountMultiDimEloToggle: () => mountMultiDimEloToggle,
3220
+ tagAwareGap: () => tagAwareGap
3156
3221
  });
3157
3222
  function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
3158
3223
  const normalizedDistance = distance / halfLife;
3159
3224
  const decay = Math.exp(-(normalizedDistance * normalizedDistance));
3160
3225
  return minMultiplier + (maxMultiplier - minMultiplier) * decay;
3161
3226
  }
3227
+ function resolveConfig(config) {
3228
+ return { ...DEFAULT_ELO_DISTANCE_CONFIG, ...config };
3229
+ }
3230
+ function readMultiDimElo() {
3231
+ try {
3232
+ return typeof localStorage !== "undefined" && localStorage.getItem(MULTI_DIM_ELO_KEY) === "true";
3233
+ } catch {
3234
+ return false;
3235
+ }
3236
+ }
3237
+ function mountMultiDimEloToggle() {
3238
+ if (typeof window === "undefined") return;
3239
+ const win = window;
3240
+ win.skuilder = win.skuilder || {};
3241
+ Object.defineProperty(win.skuilder, "multiDimElo", {
3242
+ configurable: true,
3243
+ enumerable: true,
3244
+ get: () => multiDimElo,
3245
+ set: (on) => {
3246
+ multiDimElo = on === true;
3247
+ try {
3248
+ if (multiDimElo) localStorage.setItem(MULTI_DIM_ELO_KEY, "true");
3249
+ else localStorage.removeItem(MULTI_DIM_ELO_KEY);
3250
+ } catch (e) {
3251
+ logger.warn(`[EloDistance] multiDimElo not persisted (localStorage unavailable): ${e}`);
3252
+ }
3253
+ logger.info(
3254
+ `[EloDistance] multiDimElo ${multiDimElo ? "on: tag-aware" : "off: per strategy config"} ELO distance from the next replan`
3255
+ );
3256
+ }
3257
+ });
3258
+ }
3259
+ function tagAwareGap(cardTags, cardElo, userElo, minTagCount) {
3260
+ const globalGap = cardElo.global.score - userElo.global.score;
3261
+ const tags = [];
3262
+ for (const tag of cardTags) {
3263
+ const user = userElo.tags[tag];
3264
+ if (!user || user.score === COUNT_ONLY_SENTINEL || user.count < minTagCount) continue;
3265
+ const card = cardElo.tags[tag]?.score ?? cardElo.global.score;
3266
+ tags.push({
3267
+ tag,
3268
+ gap: card - user.score,
3269
+ weight: user.count / (user.count + TAG_CONFIDENCE_HALF)
3270
+ });
3271
+ }
3272
+ if (tags.length === 0) return { gap: globalGap, globalGap, tags };
3273
+ const total = tags.reduce((w, t) => w + t.weight, 0);
3274
+ const tagGap = tags.reduce((g, t) => g + t.weight * t.gap, 0) / total;
3275
+ const lambda = total / (total + 1);
3276
+ return { gap: lambda * tagGap + (1 - lambda) * globalGap, globalGap, tags };
3277
+ }
3278
+ function tagReason(tags, globalGap) {
3279
+ 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(", ");
3280
+ const more = tags.length > 3 ? `, +${tags.length - 3} more` : "";
3281
+ return ` on ${tags.length} shared tag(s) [${shown}${more}] (global ${globalGap >= 0 ? "+" : ""}${Math.round(globalGap)})`;
3282
+ }
3283
+ async function applyEloDistance(cards, context, config, source) {
3284
+ const { course, userElo, userCourseElo } = context;
3285
+ const { halfLife, minMultiplier, maxMultiplier } = config;
3286
+ const tagAware = (config.tagAware || multiDimElo) && userCourseElo !== void 0;
3287
+ const missing = cards.filter((c) => tagAware || c.cardElo === void 0).map((c) => c.cardId);
3288
+ const fetched = /* @__PURE__ */ new Map();
3289
+ if (missing.length > 0) {
3290
+ const elos = await course.getCardEloData(missing);
3291
+ missing.forEach((id, i) => {
3292
+ if (elos[i]) fetched.set(id, elos[i]);
3293
+ });
3294
+ }
3295
+ return cards.map((card) => {
3296
+ const full = fetched.get(card.cardId);
3297
+ const cardElo = full?.global?.score ?? card.cardElo ?? DEFAULT_CARD_ELO;
3298
+ let distance = Math.abs(cardElo - userElo);
3299
+ let how = "";
3300
+ if (tagAware) {
3301
+ const t = full ? tagAwareGap(card.tags ?? [], full, userCourseElo, config.minTagCount) : void 0;
3302
+ if (t) distance = Math.abs(t.gap);
3303
+ how = t?.tags.length ? `, tag-aware${tagReason(t.tags, t.globalGap)}` : ", tag-aware: global (no shared tags)";
3304
+ }
3305
+ const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
3306
+ const newScore = card.score * multiplier;
3307
+ const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
3308
+ return {
3309
+ ...card,
3310
+ cardElo,
3311
+ score: newScore,
3312
+ provenance: [
3313
+ ...card.provenance,
3314
+ {
3315
+ strategy: "eloDistance",
3316
+ strategyName: source.name,
3317
+ strategyId: source.strategyId,
3318
+ action,
3319
+ score: newScore,
3320
+ reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)})${how} \u2192 ${multiplier.toFixed(2)}x`
3321
+ }
3322
+ ]
3323
+ };
3324
+ });
3325
+ }
3162
3326
  function createEloDistanceFilter(config) {
3163
- const halfLife = config?.halfLife ?? DEFAULT_HALF_LIFE;
3164
- const minMultiplier = config?.minMultiplier ?? DEFAULT_MIN_MULTIPLIER;
3165
- const maxMultiplier = config?.maxMultiplier ?? DEFAULT_MAX_MULTIPLIER;
3327
+ const resolved = resolveConfig(config);
3328
+ const source = { name: "ELO Distance Filter", strategyId: "ELO_DISTANCE_FILTER" };
3166
3329
  return {
3167
- name: "ELO Distance Filter",
3168
- async transform(cards, context) {
3169
- const { course, userElo } = context;
3170
- const cardIds = cards.map((c) => c.cardId);
3171
- const cardElos = await course.getCardEloData(cardIds);
3172
- return cards.map((card, i) => {
3173
- const cardElo = cardElos[i]?.global?.score ?? 1e3;
3174
- const distance = Math.abs(cardElo - userElo);
3175
- const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
3176
- const newScore = card.score * multiplier;
3177
- const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
3178
- return {
3179
- ...card,
3180
- score: newScore,
3181
- provenance: [
3182
- ...card.provenance,
3183
- {
3184
- strategy: "eloDistance",
3185
- strategyName: "ELO Distance Filter",
3186
- strategyId: "ELO_DISTANCE_FILTER",
3187
- action,
3188
- score: newScore,
3189
- reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)}) \u2192 ${multiplier.toFixed(2)}x`
3190
- }
3191
- ]
3192
- };
3193
- });
3194
- }
3330
+ name: source.name,
3331
+ kind: "signal",
3332
+ liveOnly: true,
3333
+ transform: (cards, context) => applyEloDistance(cards, context, resolved, source)
3195
3334
  };
3196
3335
  }
3197
- var DEFAULT_HALF_LIFE, DEFAULT_MIN_MULTIPLIER, DEFAULT_MAX_MULTIPLIER;
3336
+ var DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, COUNT_ONLY_SENTINEL, DEFAULT_CARD_ELO, MULTI_DIM_ELO_KEY, multiDimElo, EloDistanceFilter;
3198
3337
  var init_eloDistance = __esm({
3199
3338
  "src/core/navigators/filters/eloDistance.ts"() {
3200
3339
  "use strict";
3201
- DEFAULT_HALF_LIFE = 200;
3202
- DEFAULT_MIN_MULTIPLIER = 0.3;
3203
- DEFAULT_MAX_MULTIPLIER = 1;
3340
+ init_navigators();
3341
+ init_logger();
3342
+ DEFAULT_ELO_DISTANCE_CONFIG = {
3343
+ halfLife: 300,
3344
+ minMultiplier: 0.05,
3345
+ maxMultiplier: 1,
3346
+ tagAware: false,
3347
+ minTagCount: 3
3348
+ };
3349
+ TAG_CONFIDENCE_HALF = 10;
3350
+ COUNT_ONLY_SENTINEL = -1;
3351
+ DEFAULT_CARD_ELO = 1e3;
3352
+ MULTI_DIM_ELO_KEY = "skuilder:multiDimElo";
3353
+ multiDimElo = readMultiDimElo();
3354
+ mountMultiDimEloToggle();
3355
+ EloDistanceFilter = class _EloDistanceFilter extends ContentNavigator {
3356
+ name;
3357
+ /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
3358
+ static kind = "signal";
3359
+ kind = _EloDistanceFilter.kind;
3360
+ liveOnly = true;
3361
+ config;
3362
+ constructor(user, course, strategyData) {
3363
+ super(user, course, strategyData);
3364
+ this.name = strategyData.name || "ELO Distance";
3365
+ let parsed;
3366
+ try {
3367
+ parsed = strategyData.serializedData ? JSON.parse(strategyData.serializedData) : void 0;
3368
+ } catch {
3369
+ parsed = void 0;
3370
+ }
3371
+ this.config = resolveConfig(parsed);
3372
+ }
3373
+ transform(cards, context) {
3374
+ return applyEloDistance(cards, context, this.config, {
3375
+ name: this.name,
3376
+ strategyId: this.strategyId || "NAVIGATION_STRATEGY-eloDistance-default"
3377
+ });
3378
+ }
3379
+ async getWeightedCards(_limit) {
3380
+ throw new Error(
3381
+ "EloDistanceFilter is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
3382
+ );
3383
+ }
3384
+ };
3204
3385
  }
3205
3386
  });
3206
3387
 
@@ -3217,10 +3398,13 @@ var init_hierarchyDefinition = __esm({
3217
3398
  init_navigators();
3218
3399
  init_logger();
3219
3400
  DEFAULT_MIN_COUNT2 = 3;
3220
- HierarchyDefinitionNavigator = class extends ContentNavigator {
3401
+ HierarchyDefinitionNavigator = class _HierarchyDefinitionNavigator extends ContentNavigator {
3221
3402
  config;
3222
3403
  /** Human-readable name for CardFilter interface */
3223
3404
  name;
3405
+ /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
3406
+ static kind = "gate";
3407
+ kind = _HierarchyDefinitionNavigator.kind;
3224
3408
  constructor(user, course, strategyData) {
3225
3409
  super(user, course, strategyData);
3226
3410
  this.config = this.parseConfig(strategyData.serializedData);
@@ -3487,10 +3671,13 @@ var init_userTagPreference = __esm({
3487
3671
  "src/core/navigators/filters/userTagPreference.ts"() {
3488
3672
  "use strict";
3489
3673
  init_navigators();
3490
- UserTagPreferenceFilter = class extends ContentNavigator {
3674
+ UserTagPreferenceFilter = class _UserTagPreferenceFilter extends ContentNavigator {
3491
3675
  _strategyData;
3492
3676
  /** Human-readable name for CardFilter interface */
3493
3677
  name;
3678
+ /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
3679
+ static kind = "signal";
3680
+ kind = _UserTagPreferenceFilter.kind;
3494
3681
  constructor(user, course, strategyData) {
3495
3682
  super(user, course, strategyData);
3496
3683
  this._strategyData = strategyData;
@@ -3600,6 +3787,7 @@ var init_userTagPreference = __esm({
3600
3787
  // src/core/navigators/filters/index.ts
3601
3788
  var filters_exports = {};
3602
3789
  __export(filters_exports, {
3790
+ EloDistanceFilter: () => EloDistanceFilter,
3603
3791
  UserTagPreferenceFilter: () => UserTagPreferenceFilter,
3604
3792
  createEloDistanceFilter: () => createEloDistanceFilter
3605
3793
  });
@@ -3638,10 +3826,13 @@ var init_interferenceMitigator = __esm({
3638
3826
  DEFAULT_MIN_COUNT3 = 10;
3639
3827
  DEFAULT_MIN_ELAPSED_DAYS = 3;
3640
3828
  DEFAULT_INTERFERENCE_DECAY = 0.8;
3641
- InterferenceMitigatorNavigator = class extends ContentNavigator {
3829
+ InterferenceMitigatorNavigator = class _InterferenceMitigatorNavigator extends ContentNavigator {
3642
3830
  config;
3643
3831
  /** Human-readable name for CardFilter interface */
3644
3832
  name;
3833
+ /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
3834
+ static kind = "signal";
3835
+ kind = _InterferenceMitigatorNavigator.kind;
3645
3836
  /** Precomputed map: tag -> set of { partner, decay } it interferes with */
3646
3837
  interferenceMap;
3647
3838
  constructor(user, course, strategyData) {
@@ -3857,10 +4048,13 @@ var init_relativePriority = __esm({
3857
4048
  DEFAULT_PRIORITY = 0.5;
3858
4049
  DEFAULT_PRIORITY_INFLUENCE = 0.5;
3859
4050
  DEFAULT_COMBINE_MODE = "max";
3860
- RelativePriorityNavigator = class extends ContentNavigator {
4051
+ RelativePriorityNavigator = class _RelativePriorityNavigator extends ContentNavigator {
3861
4052
  config;
3862
4053
  /** Human-readable name for CardFilter interface */
3863
4054
  name;
4055
+ /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
4056
+ static kind = "signal";
4057
+ kind = _RelativePriorityNavigator.kind;
3864
4058
  constructor(user, course, strategyData) {
3865
4059
  super(user, course, strategyData);
3866
4060
  this.config = this.parseConfig(strategyData.serializedData);
@@ -4268,6 +4462,8 @@ var init_Pipeline = __esm({
4268
4462
  init_orchestration();
4269
4463
  init_PipelineDebugger();
4270
4464
  init_diversityRerank();
4465
+ init_regulators();
4466
+ init_SrsDebugger();
4271
4467
  VERBOSE_RESULTS = true;
4272
4468
  Pipeline = class extends ContentNavigator {
4273
4469
  generator;
@@ -4293,6 +4489,13 @@ var init_Pipeline = __esm({
4293
4489
  * getWeightedCards() call, then cleared.
4294
4490
  */
4295
4491
  _ephemeralHints = null;
4492
+ /**
4493
+ * The intake valve's clock (see regulators.ts), loaded from strategy state on
4494
+ * first use and kept in memory. Writes are chained so a presentation and a
4495
+ * run can't race each other's revision.
4496
+ */
4497
+ _intakeClock = null;
4498
+ _intakeClockWrite = Promise.resolve();
4296
4499
  /**
4297
4500
  * Create a new pipeline.
4298
4501
  *
@@ -4367,13 +4570,12 @@ var init_Pipeline = __esm({
4367
4570
  }
4368
4571
  }
4369
4572
  generatorSummaries = Array.from(genMap.entries()).map(([name, data]) => {
4370
- const newCards = data.cards.filter((c) => c.provenance[0]?.reason?.includes("new card"));
4371
- const reviewCards = data.cards.filter((c) => c.provenance[0]?.reason?.includes("review"));
4573
+ const reviewCount = data.cards.filter((c) => c.reviewID).length;
4372
4574
  return {
4373
4575
  name,
4374
4576
  cardCount: data.cards.length,
4375
- newCount: newCards.length,
4376
- reviewCount: reviewCards.length,
4577
+ newCount: data.cards.length - reviewCount,
4578
+ reviewCount,
4377
4579
  topScore: Math.max(...data.cards.map((c) => c.score), 0)
4378
4580
  };
4379
4581
  });
@@ -4409,19 +4611,24 @@ var init_Pipeline = __esm({
4409
4611
  cards.filter((c) => c.provenance.some((p) => p.strategy === "prescribed")).map((c) => c.cardId)
4410
4612
  );
4411
4613
  const filterImpacts = [];
4614
+ const generatedScores = new Map(cards.map((c) => [c.cardId, c.score]));
4615
+ const gated = /* @__PURE__ */ new Set();
4412
4616
  for (const filter of this.filters) {
4413
4617
  const beforeCount = cards.length;
4414
4618
  const beforeScores = new Map(cards.map((c) => [c.cardId, c.score]));
4415
4619
  cards = await filter.transform(cards, context);
4416
4620
  let boosted = 0, penalized = 0, passed = 0;
4417
4621
  const removed = beforeCount - cards.length;
4622
+ const kind = filter.kind ?? "gate";
4418
4623
  for (const card of cards) {
4419
4624
  const before = beforeScores.get(card.cardId) ?? 0;
4420
4625
  if (card.score > before) boosted++;
4421
- else if (card.score < before) penalized++;
4422
- else passed++;
4626
+ else if (card.score < before) {
4627
+ penalized++;
4628
+ if (kind === "gate") gated.add(card.cardId);
4629
+ } else passed++;
4423
4630
  }
4424
- filterImpacts.push({ name: filter.name, boosted, penalized, passed, removed });
4631
+ filterImpacts.push({ name: filter.name, kind, boosted, penalized, passed, removed });
4425
4632
  if (prescribedIds.size > 0) {
4426
4633
  const survivingIds = new Set(cards.map((c) => c.cardId));
4427
4634
  const killedPrescribed = [...prescribedIds].filter((id) => !survivingIds.has(id));
@@ -4437,6 +4644,7 @@ var init_Pipeline = __esm({
4437
4644
  }
4438
4645
  const scoredCards = cards;
4439
4646
  cards = cards.filter((c) => c.score > 0);
4647
+ const regulators = await this.regulate(cards, generatedScores, gated);
4440
4648
  const hints = this._ephemeralHints;
4441
4649
  if (hints) {
4442
4650
  this._ephemeralHints = null;
@@ -4473,7 +4681,8 @@ var init_Pipeline = __esm({
4473
4681
  result,
4474
4682
  context.userElo,
4475
4683
  hints ?? void 0,
4476
- scoredCards
4684
+ scoredCards,
4685
+ regulators
4477
4686
  );
4478
4687
  captureRun(report);
4479
4688
  } catch (e) {
@@ -4652,6 +4861,77 @@ var init_Pipeline = __esm({
4652
4861
  logger.info(`[Pipeline] Hints applied: ${beforeCount} \u2192 ${cards.length} cards`);
4653
4862
  return cards;
4654
4863
  }
4864
+ /**
4865
+ * The regulator stage: measure each class's pressure and scale it.
4866
+ *
4867
+ * - Review mass: every due review's SRS urgency times the filters' net
4868
+ * effect on it.
4869
+ * - Intake: servable hours since a new card was presented, applied only to
4870
+ * eligible new cards (no gate penalized them). With none eligible, the
4871
+ * clock freezes.
4872
+ *
4873
+ * Mutates `cards` in place; returns the readings for the run report.
4874
+ */
4875
+ async regulate(cards, generatedScores, gated) {
4876
+ const config = DEFAULT_REGULATOR_CONFIG;
4877
+ const reviews = cards.filter((c) => c.reviewID);
4878
+ const newCards = cards.filter((c) => !c.reviewID);
4879
+ const eligibleNew = newCards.filter((c) => !gated.has(c.cardId));
4880
+ const mass = reviewMassReading(reviews, generatedScores, config.reviewMass);
4881
+ applyReading(reviews, mass);
4882
+ noteReviewPressure(this.course.getCourseID(), {
4883
+ mass: mass.urgency,
4884
+ healthyMass: config.reviewMass.healthyMass,
4885
+ rate: config.reviewMass.rate,
4886
+ multiplier: mass.multiplier
4887
+ });
4888
+ const now = Date.now();
4889
+ const clock = await this.loadIntakeClock(now);
4890
+ const stepped = stepIntakeClock(clock, now, eligibleNew.length);
4891
+ if (stepped !== clock) this.saveIntakeClock(stepped);
4892
+ const intake = intakeReading(
4893
+ stepped,
4894
+ now,
4895
+ { eligibleNew: eligibleNew.length, newCandidates: newCards.length },
4896
+ config.intake
4897
+ );
4898
+ applyReading(eligibleNew, intake);
4899
+ logger.info(
4900
+ `[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)}`
4901
+ );
4902
+ return [mass, intake];
4903
+ }
4904
+ /**
4905
+ * A card was presented. A new card's first presentation discharges the
4906
+ * intake valve: its clock restarts. Called by the SessionController.
4907
+ */
4908
+ notePresented(card) {
4909
+ if (card.status !== "new" || card.courseId !== this.course?.getCourseID()) return;
4910
+ this.saveIntakeClock(resetIntakeClock(Date.now()));
4911
+ }
4912
+ async loadIntakeClock(nowMs) {
4913
+ if (this._intakeClock) return this._intakeClock;
4914
+ let stored = null;
4915
+ try {
4916
+ stored = await this.user.getStrategyState(
4917
+ this.course.getCourseID(),
4918
+ INTAKE_CLOCK_KEY
4919
+ );
4920
+ } catch (e) {
4921
+ logger.warn(`[Pipeline:regulators] Could not read the intake clock: ${e}`);
4922
+ }
4923
+ if (stored) {
4924
+ this._intakeClock = stored;
4925
+ } else {
4926
+ this.saveIntakeClock(resetIntakeClock(nowMs));
4927
+ }
4928
+ return this._intakeClock;
4929
+ }
4930
+ saveIntakeClock(state) {
4931
+ this._intakeClock = state;
4932
+ const courseId = this.course.getCourseID();
4933
+ 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}`));
4934
+ }
4655
4935
  /**
4656
4936
  * Build shared context for generator and filters.
4657
4937
  *
@@ -4662,10 +4942,11 @@ var init_Pipeline = __esm({
4662
4942
  */
4663
4943
  async buildContext() {
4664
4944
  let userElo = 1e3;
4945
+ let userCourseElo;
4665
4946
  try {
4666
4947
  const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
4667
- const courseElo = toCourseElo5(courseReg.elo);
4668
- userElo = courseElo.global.score;
4948
+ userCourseElo = toCourseElo5(courseReg.elo);
4949
+ userElo = userCourseElo.global.score;
4669
4950
  } catch (e) {
4670
4951
  logger.debug(`[Pipeline] Could not get user ELO, using default: ${e}`);
4671
4952
  }
@@ -4677,6 +4958,7 @@ var init_Pipeline = __esm({
4677
4958
  user: this.user,
4678
4959
  course: this.course,
4679
4960
  userElo,
4961
+ ...userCourseElo ? { userCourseElo } : {},
4680
4962
  orchestration
4681
4963
  };
4682
4964
  }
@@ -4790,7 +5072,7 @@ var init_Pipeline = __esm({
4790
5072
  cards = await this.hydrateTags(cards);
4791
5073
  const fullPool = cards.slice();
4792
5074
  const context = await this.buildContext();
4793
- for (const filter of this.filters) {
5075
+ for (const filter of this.forecastFilters()) {
4794
5076
  cards = await filter.transform(cards, context);
4795
5077
  }
4796
5078
  if (opts?.hints) {
@@ -4809,6 +5091,14 @@ var init_Pipeline = __esm({
4809
5091
  cards.sort((a, b) => b.score - a.score);
4810
5092
  return opts?.limit ? cards.slice(0, opts.limit) : cards;
4811
5093
  }
5094
+ /**
5095
+ * The filters a forecast or card-space scan applies. Those start every card at
5096
+ * 1.0 without a generator, so they skip `liveOnly` filters (ELO distance),
5097
+ * which only make sense against generator scores.
5098
+ */
5099
+ forecastFilters() {
5100
+ return this.filters.filter((f) => !f.liveOnly);
5101
+ }
4812
5102
  /**
4813
5103
  * Scan every card in the course through the filter chain and report
4814
5104
  * how many are "well indicated" (score >= threshold) for the current user.
@@ -4830,7 +5120,7 @@ var init_Pipeline = __esm({
4830
5120
  cards = await this.hydrateTags(cards);
4831
5121
  const context = await this.buildContext();
4832
5122
  const filterBreakdown = [];
4833
- for (const filter of this.filters) {
5123
+ for (const filter of this.forecastFilters()) {
4834
5124
  cards = await filter.transform(cards, context);
4835
5125
  const wi = cards.filter((c) => c.score >= THRESHOLD).length;
4836
5126
  filterBreakdown.push({ name: filter.name, wellIndicated: wi });
@@ -4894,6 +5184,7 @@ var init_Pipeline = __esm({
4894
5184
  // src/core/navigators/defaults.ts
4895
5185
  var defaults_exports = {};
4896
5186
  __export(defaults_exports, {
5187
+ createDefaultEloDistanceStrategy: () => createDefaultEloDistanceStrategy,
4897
5188
  createDefaultEloStrategy: () => createDefaultEloStrategy,
4898
5189
  createDefaultPipeline: () => createDefaultPipeline,
4899
5190
  createDefaultSrsStrategy: () => createDefaultSrsStrategy
@@ -4920,12 +5211,28 @@ function createDefaultSrsStrategy(courseId) {
4920
5211
  serializedData: ""
4921
5212
  };
4922
5213
  }
5214
+ function createDefaultEloDistanceStrategy(courseId) {
5215
+ return {
5216
+ _id: "NAVIGATION_STRATEGY-eloDistance-default",
5217
+ docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
5218
+ name: "ELO Distance (default)",
5219
+ description: "Scales every candidate, new or review, by its distance from the learner's ELO",
5220
+ implementingClass: "eloDistance" /* ELO_DISTANCE */,
5221
+ course: courseId,
5222
+ // Explicit, though the filter would default to it anyway: views show what runs.
5223
+ serializedData: JSON.stringify(DEFAULT_ELO_DISTANCE_CONFIG)
5224
+ };
5225
+ }
4923
5226
  function createDefaultPipeline(user, course) {
4924
5227
  const courseId = course.getCourseID();
4925
5228
  const eloNavigator = new ELONavigator(user, course, createDefaultEloStrategy(courseId));
4926
5229
  const srsNavigator = new SRSNavigator(user, course, createDefaultSrsStrategy(courseId));
4927
5230
  const compositeGenerator = new CompositeGenerator([eloNavigator, srsNavigator]);
4928
- const eloDistanceFilter = createEloDistanceFilter();
5231
+ const eloDistanceFilter = new EloDistanceFilter(
5232
+ user,
5233
+ course,
5234
+ createDefaultEloDistanceStrategy(courseId)
5235
+ );
4929
5236
  return new Pipeline(compositeGenerator, [eloDistanceFilter], user, course);
4930
5237
  }
4931
5238
  var init_defaults = __esm({
@@ -4941,6 +5248,131 @@ var init_defaults = __esm({
4941
5248
  }
4942
5249
  });
4943
5250
 
5251
+ // src/core/navigators/pipelinePlan.ts
5252
+ var pipelinePlan_exports = {};
5253
+ __export(pipelinePlan_exports, {
5254
+ PIPELINE_STAGES: () => PIPELINE_STAGES,
5255
+ planPipeline: () => planPipeline
5256
+ });
5257
+ function planned(strategy, role, origin) {
5258
+ const kind = role === "filter" /* FILTER */ ? getRegisteredFilterKind(strategy.implementingClass) : void 0;
5259
+ return {
5260
+ role,
5261
+ origin,
5262
+ name: strategy.name,
5263
+ implementingClass: strategy.implementingClass,
5264
+ strategy,
5265
+ ...kind ? { kind } : {}
5266
+ };
5267
+ }
5268
+ function planPipeline(strategies, courseId) {
5269
+ if (strategies.length === 0) {
5270
+ return {
5271
+ kind: "default",
5272
+ generators: [
5273
+ planned(createDefaultEloStrategy(courseId), "generator" /* GENERATOR */, "default-pipeline"),
5274
+ planned(createDefaultSrsStrategy(courseId), "generator" /* GENERATOR */, "default-pipeline")
5275
+ ],
5276
+ filters: [
5277
+ planned(
5278
+ createDefaultEloDistanceStrategy(courseId),
5279
+ "filter" /* FILTER */,
5280
+ "default-pipeline"
5281
+ )
5282
+ ],
5283
+ skipped: [],
5284
+ warnings: [],
5285
+ notes: [],
5286
+ regulators: DEFAULT_REGULATOR_CONFIG
5287
+ };
5288
+ }
5289
+ const generators = [];
5290
+ const filters = [];
5291
+ const skipped = [];
5292
+ const warnings = [];
5293
+ for (const s of strategies) {
5294
+ if (isGenerator(s.implementingClass)) {
5295
+ generators.push(planned(s, "generator" /* GENERATOR */, "strategy-doc"));
5296
+ } else if (isFilter(s.implementingClass)) {
5297
+ filters.push(planned(s, "filter" /* FILTER */, "strategy-doc"));
5298
+ } else {
5299
+ skipped.push({ strategy: s, reason: "not a registered generator or filter" });
5300
+ warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
5301
+ }
5302
+ }
5303
+ const declared = new Set(generators.map((g) => g.implementingClass));
5304
+ if (!declared.has(createDefaultEloStrategy(courseId).implementingClass)) {
5305
+ generators.push(
5306
+ planned(createDefaultEloStrategy(courseId), "generator" /* GENERATOR */, "assembler-default")
5307
+ );
5308
+ }
5309
+ if (!declared.has(createDefaultSrsStrategy(courseId).implementingClass)) {
5310
+ generators.push(
5311
+ planned(createDefaultSrsStrategy(courseId), "generator" /* GENERATOR */, "assembler-default")
5312
+ );
5313
+ }
5314
+ const eloDistance = createDefaultEloDistanceStrategy(courseId);
5315
+ if (!filters.some((f) => f.implementingClass === eloDistance.implementingClass)) {
5316
+ filters.push(planned(eloDistance, "filter" /* FILTER */, "assembler-default"));
5317
+ }
5318
+ filters.sort((a, b) => a.name.localeCompare(b.name));
5319
+ return {
5320
+ kind: "assembled",
5321
+ generators,
5322
+ filters,
5323
+ skipped,
5324
+ warnings,
5325
+ notes: [],
5326
+ regulators: DEFAULT_REGULATOR_CONFIG
5327
+ };
5328
+ }
5329
+ var PIPELINE_STAGES;
5330
+ var init_pipelinePlan = __esm({
5331
+ "src/core/navigators/pipelinePlan.ts"() {
5332
+ "use strict";
5333
+ init_navigators();
5334
+ init_regulators();
5335
+ init_defaults();
5336
+ PIPELINE_STAGES = [
5337
+ {
5338
+ key: "generate",
5339
+ title: "Generate",
5340
+ 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."
5341
+ },
5342
+ {
5343
+ key: "filter",
5344
+ title: "Filter",
5345
+ 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."
5346
+ },
5347
+ {
5348
+ key: "drop-zero",
5349
+ title: "Drop zero scores",
5350
+ summary: "Candidates whose score reached 0 leave the pool."
5351
+ },
5352
+ {
5353
+ key: "regulate",
5354
+ title: "Regulate",
5355
+ 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."
5356
+ },
5357
+ {
5358
+ key: "hints",
5359
+ title: "Apply hints",
5360
+ 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."
5361
+ },
5362
+ {
5363
+ key: "diversity",
5364
+ title: "Diversity re-rank",
5365
+ 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."
5366
+ },
5367
+ {
5368
+ key: "select",
5369
+ title: "Select",
5370
+ summary: "Highest scores first, up to the run's limit. The session mixes them into its supply queue."
5371
+ }
5372
+ ];
5373
+ }
5374
+ });
5375
+
4944
5376
  // src/core/navigators/PipelineAssembler.ts
4945
5377
  var PipelineAssembler_exports = {};
4946
5378
  __export(PipelineAssembler_exports, {
@@ -4955,16 +5387,16 @@ var init_PipelineAssembler = __esm({
4955
5387
  init_Pipeline();
4956
5388
  init_logger();
4957
5389
  init_CompositeGenerator();
4958
- init_defaults();
5390
+ init_pipelinePlan();
4959
5391
  PipelineAssembler = class {
4960
5392
  /**
4961
5393
  * Assembles a navigation pipeline from strategy documents.
4962
5394
  *
4963
- * 1. Separates into generators and filters by role
4964
- * 2. Validates at least one generator exists (or creates default ELO)
4965
- * 3. Instantiates generators - wraps multiple in CompositeGenerator
4966
- * 4. Instantiates filters
4967
- * 5. Returns Pipeline(generator, filters)
5395
+ * 1. Plans: classifies by role, adds default ELO/SRS and ELO distance, orders filters
5396
+ * (`planPipeline`)
5397
+ * 2. Instantiates generators - wraps multiple in CompositeGenerator
5398
+ * 3. Instantiates filters
5399
+ * 4. Returns Pipeline(generator, filters)
4968
5400
  *
4969
5401
  * @param input - Strategy documents plus user/course interfaces
4970
5402
  * @returns Assembled pipeline and any warnings
@@ -4980,28 +5412,17 @@ var init_PipelineAssembler = __esm({
4980
5412
  warnings
4981
5413
  };
4982
5414
  }
4983
- const generatorStrategies = [];
4984
- const filterStrategies = [];
4985
- for (const s of strategies) {
4986
- if (isGenerator(s.implementingClass)) {
4987
- generatorStrategies.push(s);
4988
- } else if (isFilter(s.implementingClass)) {
4989
- filterStrategies.push(s);
4990
- } else {
4991
- warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
5415
+ const plan = planPipeline(strategies, course.getCourseID());
5416
+ warnings.push(...plan.warnings);
5417
+ for (const n of [...plan.generators, ...plan.filters]) {
5418
+ if (n.origin === "assembler-default") {
5419
+ logger.debug(
5420
+ `[PipelineAssembler] No ${n.implementingClass} ${n.role} configured, adding default`
5421
+ );
4992
5422
  }
4993
5423
  }
4994
- const courseId = course.getCourseID();
4995
- const hasElo = generatorStrategies.some((s) => s.implementingClass === "elo" /* ELO */);
4996
- const hasSrs = generatorStrategies.some((s) => s.implementingClass === "srs" /* SRS */);
4997
- if (!hasElo) {
4998
- logger.debug("[PipelineAssembler] No ELO generator configured, adding default");
4999
- generatorStrategies.push(createDefaultEloStrategy(courseId));
5000
- }
5001
- if (!hasSrs) {
5002
- logger.debug("[PipelineAssembler] No SRS generator configured, adding default");
5003
- generatorStrategies.push(createDefaultSrsStrategy(courseId));
5004
- }
5424
+ const generatorStrategies = plan.generators.map((g) => g.strategy);
5425
+ const sortedFilterStrategies = plan.filters.map((f) => f.strategy);
5005
5426
  if (generatorStrategies.length === 0) {
5006
5427
  warnings.push("No generator strategy found");
5007
5428
  return {
@@ -5023,9 +5444,6 @@ var init_PipelineAssembler = __esm({
5023
5444
  generator = await CompositeGenerator.fromStrategies(user, course, generatorStrategies);
5024
5445
  }
5025
5446
  const filters = [];
5026
- const sortedFilterStrategies = [...filterStrategies].sort(
5027
- (a, b) => a.name.localeCompare(b.name)
5028
- );
5029
5447
  for (const filterStrategy of sortedFilterStrategies) {
5030
5448
  try {
5031
5449
  const nav = await ContentNavigator.create(user, course, filterStrategy);
@@ -5093,7 +5511,9 @@ var init_3 = __esm({
5093
5511
  "./generators/prescribed.ts": () => Promise.resolve().then(() => (init_prescribed(), prescribed_exports)),
5094
5512
  "./generators/srs.ts": () => Promise.resolve().then(() => (init_srs(), srs_exports)),
5095
5513
  "./generators/types.ts": () => Promise.resolve().then(() => (init_types(), types_exports)),
5096
- "./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports))
5514
+ "./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports)),
5515
+ "./pipelinePlan.ts": () => Promise.resolve().then(() => (init_pipelinePlan(), pipelinePlan_exports)),
5516
+ "./regulators.ts": () => Promise.resolve().then(() => (init_regulators(), regulators_exports))
5097
5517
  });
5098
5518
  }
5099
5519
  });
@@ -5114,6 +5534,7 @@ __export(navigators_exports, {
5114
5534
  drainCapturedRuns: () => drainCapturedRuns,
5115
5535
  getActivePipeline: () => getActivePipeline,
5116
5536
  getCardOrigin: () => getCardOrigin,
5537
+ getRegisteredFilterKind: () => getRegisteredFilterKind,
5117
5538
  getRegisteredNavigator: () => getRegisteredNavigator,
5118
5539
  getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
5119
5540
  getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
@@ -5142,6 +5563,10 @@ function hasRegisteredNavigator(implementingClass) {
5142
5563
  function getRegisteredNavigatorRole(implementingClass) {
5143
5564
  return navigatorRegistry.get(implementingClass)?.role;
5144
5565
  }
5566
+ function getRegisteredFilterKind(implementingClass) {
5567
+ const ctor = navigatorRegistry.get(implementingClass)?.constructor;
5568
+ return ctor?.kind;
5569
+ }
5145
5570
  function getRegisteredNavigatorNames() {
5146
5571
  return Array.from(navigatorRegistry.keys());
5147
5572
  }
@@ -5159,17 +5584,20 @@ async function initializeNavigatorRegistry() {
5159
5584
  hierarchyModule,
5160
5585
  interferenceModule,
5161
5586
  relativePriorityModule,
5162
- userTagPreferenceModule
5587
+ userTagPreferenceModule,
5588
+ eloDistanceModule
5163
5589
  ] = await Promise.all([
5164
5590
  Promise.resolve().then(() => (init_hierarchyDefinition(), hierarchyDefinition_exports)),
5165
5591
  Promise.resolve().then(() => (init_interferenceMitigator(), interferenceMitigator_exports)),
5166
5592
  Promise.resolve().then(() => (init_relativePriority(), relativePriority_exports)),
5167
- Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports))
5593
+ Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports)),
5594
+ Promise.resolve().then(() => (init_eloDistance(), eloDistance_exports))
5168
5595
  ]);
5169
5596
  registerNavigator("hierarchyDefinition", hierarchyModule.default);
5170
5597
  registerNavigator("interferenceMitigator", interferenceModule.default);
5171
5598
  registerNavigator("relativePriority", relativePriorityModule.default);
5172
5599
  registerNavigator("userTagPreference", userTagPreferenceModule.default);
5600
+ registerNavigator("eloDistance", eloDistanceModule.default);
5173
5601
  logger.debug(
5174
5602
  `[NavigatorRegistry] Initialized ${navigatorRegistry.size} navigators: ${getRegisteredNavigatorNames().join(", ")}`
5175
5603
  );
@@ -5217,6 +5645,7 @@ var init_navigators = __esm({
5217
5645
  Navigators2["INTERFERENCE"] = "interferenceMitigator";
5218
5646
  Navigators2["RELATIVE_PRIORITY"] = "relativePriority";
5219
5647
  Navigators2["USER_TAG_PREFERENCE"] = "userTagPreference";
5648
+ Navigators2["ELO_DISTANCE"] = "eloDistance";
5220
5649
  return Navigators2;
5221
5650
  })(Navigators || {});
5222
5651
  NavigatorRole = /* @__PURE__ */ ((NavigatorRole2) => {
@@ -5231,7 +5660,8 @@ var init_navigators = __esm({
5231
5660
  ["hierarchyDefinition" /* HIERARCHY */]: "filter" /* FILTER */,
5232
5661
  ["interferenceMitigator" /* INTERFERENCE */]: "filter" /* FILTER */,
5233
5662
  ["relativePriority" /* RELATIVE_PRIORITY */]: "filter" /* FILTER */,
5234
- ["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER */
5663
+ ["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER */,
5664
+ ["eloDistance" /* ELO_DISTANCE */]: "filter" /* FILTER */
5235
5665
  };
5236
5666
  ContentNavigator = class {
5237
5667
  /** User interface for this navigation session */
@@ -6057,6 +6487,14 @@ ${e.stack}` : JSON.stringify(e);
6057
6487
  setEphemeralHints(hints) {
6058
6488
  this._pendingHints = hints;
6059
6489
  }
6490
+ /**
6491
+ * Forward a presentation to the navigator (a new card restarts its intake
6492
+ * clock). Builds the navigator if the cached one has expired.
6493
+ */
6494
+ notePresented(card) {
6495
+ if (card.status !== "new") return;
6496
+ void this._getCurrentUser().then((u) => this._getCachedNavigator(u)).then(({ navigator: navigator2 }) => navigator2.notePresented?.(card)).catch((e) => logger.warn(`[courseDB] Could not note a presentation: ${e}`));
6497
+ }
6060
6498
  async getWeightedCards(limit) {
6061
6499
  const u = await this._getCurrentUser();
6062
6500
  try {
@@ -8823,10 +9261,11 @@ function backlogHtml(backlog) {
8823
9261
  const rows = backlog.map((b) => {
8824
9262
  const hot = b.backlogMultiplier >= 3;
8825
9263
  const multColor = b.backlogMultiplier <= 1 ? "#86efac" : hot ? "#fca5a5" : "#fcd34d";
8826
- const headroom = b.backlogMultiplier > 1 ? `climbing (\xD7${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog}-review excess, unbounded)` : "healthy \u2014 no pressure";
9264
+ const headroom = b.backlogMultiplier > 1 ? `climbing (\xD7${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog} of mass in excess, unbounded)` : "healthy \u2014 no pressure";
9265
+ const mass = b.reviewMass !== null ? ` \xB7 mass ${b.reviewMass.toFixed(1)}` : "";
8827
9266
  const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
8828
9267
  const next = b.nextDueIn ? ` <span style="opacity:.6">\xB7 next due ${esc(b.nextDueIn)}</span>` : "";
8829
- 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>`;
9268
+ 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>`;
8830
9269
  }).join("");
8831
9270
  return `<div style="margin-bottom:6px"><div style="color:#93c5fd">review backpressure</div>${rows}</div>`;
8832
9271
  }
@@ -8965,8 +9404,9 @@ function snapshotToText(s) {
8965
9404
  const headroom = b.backlogMultiplier > 1 ? "climbing" : "healthy";
8966
9405
  const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
8967
9406
  const next = b.nextDueIn ? `, next due ${b.nextDueIn}` : "";
9407
+ const mass = b.reviewMass !== null ? `, mass ${b.reviewMass.toFixed(1)}` : "";
8968
9408
  lines.push(
8969
- ` ${b.courseId.slice(0, 8)}: due ${b.dueNow}/${b.scheduledTotal} (healthy ${b.healthyBacklog})${next}; pressure \xD7${b.backlogMultiplier.toFixed(2)} ${headroom}; top review ${top}`
9409
+ ` ${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}`
8970
9410
  );
8971
9411
  }
8972
9412
  }