@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
@@ -723,7 +723,7 @@ function parseCardElo(provenance) {
723
723
  const match = eloEntry.reason.match(/card:\s*(\d+)/);
724
724
  return match ? parseInt(match[1], 10) : void 0;
725
725
  }
726
- function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints, scoredCards) {
726
+ function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints, scoredCards, regulators) {
727
727
  const selectedIds = new Set(selectedCards.map((c) => c.cardId));
728
728
  const toReport = (card) => ({
729
729
  cardId: card.cardId,
@@ -731,7 +731,7 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
731
731
  origin: getOrigin(card),
732
732
  generator: card.provenance[0]?.strategyName || card.provenance[0]?.strategy,
733
733
  finalScore: card.score,
734
- cardElo: parseCardElo(card.provenance),
734
+ cardElo: card.cardElo ?? parseCardElo(card.provenance),
735
735
  provenance: card.provenance,
736
736
  tags: card.tags,
737
737
  selected: selectedIds.has(card.cardId)
@@ -809,7 +809,8 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
809
809
  newSelected,
810
810
  cards,
811
811
  unselectedNew,
812
- discardedTail
812
+ discardedTail,
813
+ ...regulators ? { regulators } : {}
813
814
  };
814
815
  }
815
816
  function formatProvenance(provenance) {
@@ -1533,11 +1534,23 @@ var SrsDebugger_exports = {};
1533
1534
  __export(SrsDebugger_exports, {
1534
1535
  captureSrsBacklog: () => captureSrsBacklog,
1535
1536
  clearSrsBacklogDebug: () => clearSrsBacklogDebug,
1536
- getSrsBacklogDebug: () => getSrsBacklogDebug
1537
+ getSrsBacklogDebug: () => getSrsBacklogDebug,
1538
+ noteReviewPressure: () => noteReviewPressure
1537
1539
  });
1538
1540
  function captureSrsBacklog(snapshot) {
1539
1541
  snapshots.set(snapshot.courseId, snapshot);
1540
1542
  }
1543
+ function noteReviewPressure(courseId, pressure) {
1544
+ const snapshot = snapshots.get(courseId);
1545
+ if (!snapshot) return;
1546
+ snapshots.set(courseId, {
1547
+ ...snapshot,
1548
+ reviewMass: pressure.mass,
1549
+ healthyBacklog: pressure.healthyMass,
1550
+ backlogGrowthRate: pressure.rate,
1551
+ backlogMultiplier: pressure.multiplier
1552
+ });
1553
+ }
1541
1554
  function getSrsBacklogDebug() {
1542
1555
  return [...snapshots.values()].sort((a, b) => b.timestamp - a.timestamp);
1543
1556
  }
@@ -1815,14 +1828,13 @@ var elo_exports = {};
1815
1828
  __export(elo_exports, {
1816
1829
  default: () => ELONavigator
1817
1830
  });
1818
- var import_common5, ELO_RELEVANCE_SIGMA, ELONavigator;
1831
+ var import_common5, ELONavigator;
1819
1832
  var init_elo = __esm({
1820
1833
  "src/core/navigators/generators/elo.ts"() {
1821
1834
  "use strict";
1822
1835
  init_navigators();
1823
1836
  import_common5 = require("@vue-skuilder/common");
1824
1837
  init_logger();
1825
- ELO_RELEVANCE_SIGMA = 300;
1826
1838
  ELONavigator = class extends ContentNavigator {
1827
1839
  /** Human-readable name for CardGenerator interface */
1828
1840
  name;
@@ -1831,10 +1843,8 @@ var init_elo = __esm({
1831
1843
  this.name = strategyData?.name || "ELO";
1832
1844
  }
1833
1845
  /**
1834
- * Get new cards with suitability scores based on ELO distance.
1835
- *
1836
- * Cards closer to user's ELO get higher scores.
1837
- * Score formula: max(0, 1 - distance / 500)
1846
+ * Get the new cards nearest the learner's ELO, each scored with a flat
1847
+ * jitter in [0.5, 1]. Carries each card's ELO for the ELO distance filter.
1838
1848
  *
1839
1849
  * NOTE: This generator only handles NEW cards. Reviews are handled by
1840
1850
  * SRSNavigator. Use CompositeGenerator to combine both.
@@ -1862,20 +1872,20 @@ var init_elo = __esm({
1862
1872
  const scored = newCards.map((c) => {
1863
1873
  const cardElo = c.elo ?? 1e3;
1864
1874
  const distance = Math.abs(cardElo - userGlobalElo);
1865
- const relevance = Math.exp(-((distance / ELO_RELEVANCE_SIGMA) ** 2));
1866
- const samplingKey = relevance * (0.5 + 0.5 * Math.random());
1875
+ const jitter = 0.5 + 0.5 * Math.random();
1867
1876
  return {
1868
1877
  cardId: c.cardID,
1869
1878
  courseId: c.courseID,
1870
- score: samplingKey,
1879
+ score: jitter,
1880
+ cardElo,
1871
1881
  provenance: [
1872
1882
  {
1873
1883
  strategy: "elo",
1874
1884
  strategyName: this.strategyName || this.name,
1875
1885
  strategyId: this.strategyId || "NAVIGATION_STRATEGY-ELO-default",
1876
1886
  action: "generated",
1877
- score: samplingKey,
1878
- reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}), relevance ${relevance.toFixed(3)}, key ${samplingKey.toFixed(3)}`
1887
+ score: jitter,
1888
+ reason: `new card near learner ELO: distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}), jitter ${jitter.toFixed(3)}`
1879
1889
  }
1880
1890
  ]
1881
1891
  };
@@ -2751,43 +2761,132 @@ var init_prescribed = __esm({
2751
2761
  }
2752
2762
  });
2753
2763
 
2764
+ // src/core/navigators/regulators.ts
2765
+ var regulators_exports = {};
2766
+ __export(regulators_exports, {
2767
+ DEFAULT_REGULATOR_CONFIG: () => DEFAULT_REGULATOR_CONFIG,
2768
+ INTAKE_CLOCK_KEY: () => INTAKE_CLOCK_KEY,
2769
+ applyReading: () => applyReading,
2770
+ frozenMsAt: () => frozenMsAt,
2771
+ intakeHours: () => intakeHours,
2772
+ intakeReading: () => intakeReading,
2773
+ resetIntakeClock: () => resetIntakeClock,
2774
+ reviewMassReading: () => reviewMassReading,
2775
+ reviewWeight: () => reviewWeight,
2776
+ stepIntakeClock: () => stepIntakeClock
2777
+ });
2778
+ function clamp01(x) {
2779
+ return Math.min(1, Math.max(0, x));
2780
+ }
2781
+ function reviewWeight(card, generatedScore, referenceScore) {
2782
+ if (card.reviewUrgency !== void 0 && generatedScore !== void 0 && generatedScore > 0) {
2783
+ return clamp01(card.reviewUrgency * (card.score / generatedScore));
2784
+ }
2785
+ return clamp01(card.score / referenceScore);
2786
+ }
2787
+ function reviewMassReading(reviews, generatedScores, config = DEFAULT_REGULATOR_CONFIG.reviewMass) {
2788
+ const mass = reviews.reduce(
2789
+ (m, c) => m + reviewWeight(c, generatedScores.get(c.cardId), config.referenceScore),
2790
+ 0
2791
+ );
2792
+ const multiplier = mass > config.healthyMass ? Math.pow(config.rate, (mass - config.healthyMass) / config.healthyMass) : 1;
2793
+ return {
2794
+ name: "review-mass",
2795
+ class: "review",
2796
+ urgency: mass,
2797
+ multiplier,
2798
+ applied: reviews.length,
2799
+ inputs: { due: reviews.length, mass, healthyMass: config.healthyMass }
2800
+ };
2801
+ }
2802
+ function resetIntakeClock(nowMs) {
2803
+ return { lastNewAt: new Date(nowMs).toISOString(), frozenMs: 0, unservableSince: null };
2804
+ }
2805
+ function frozenMsAt(state, nowMs) {
2806
+ const open = state.unservableSince ? Math.max(0, nowMs - Date.parse(state.unservableSince)) : 0;
2807
+ return state.frozenMs + open;
2808
+ }
2809
+ function intakeHours(state, nowMs) {
2810
+ const elapsed = nowMs - Date.parse(state.lastNewAt);
2811
+ return Math.max(0, elapsed - frozenMsAt(state, nowMs)) / 36e5;
2812
+ }
2813
+ function stepIntakeClock(state, nowMs, eligibleNew) {
2814
+ if (eligibleNew === 0 && !state.unservableSince) {
2815
+ return { ...state, unservableSince: new Date(nowMs).toISOString() };
2816
+ }
2817
+ if (eligibleNew > 0 && state.unservableSince) {
2818
+ return { ...state, frozenMs: frozenMsAt(state, nowMs), unservableSince: null };
2819
+ }
2820
+ return state;
2821
+ }
2822
+ function intakeReading(state, nowMs, counts, config = DEFAULT_REGULATOR_CONFIG.intake) {
2823
+ const hours = intakeHours(state, nowMs);
2824
+ const multiplier = counts.eligibleNew > 0 ? Math.pow(config.rate, hours / config.scaleHours) : 1;
2825
+ return {
2826
+ name: "intake",
2827
+ class: "new",
2828
+ urgency: hours,
2829
+ multiplier,
2830
+ applied: counts.eligibleNew,
2831
+ inputs: {
2832
+ hoursSinceNew: hours,
2833
+ frozenHours: frozenMsAt(state, nowMs) / 36e5,
2834
+ eligibleNew: counts.eligibleNew,
2835
+ newCandidates: counts.newCandidates
2836
+ }
2837
+ };
2838
+ }
2839
+ function applyReading(cards, reading) {
2840
+ if (reading.multiplier === 1) return;
2841
+ 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)}`;
2842
+ for (const card of cards) {
2843
+ card.score *= reading.multiplier;
2844
+ card.provenance.push({
2845
+ strategy: "regulator",
2846
+ strategyName: `Regulator: ${REGULATOR_LABEL[reading.name]}`,
2847
+ strategyId: `regulator-${reading.name}`,
2848
+ action: reading.multiplier > 1 ? "boosted" : "penalized",
2849
+ score: card.score,
2850
+ reason
2851
+ });
2852
+ }
2853
+ }
2854
+ var DEFAULT_REGULATOR_CONFIG, INTAKE_CLOCK_KEY, REGULATOR_LABEL;
2855
+ var init_regulators = __esm({
2856
+ "src/core/navigators/regulators.ts"() {
2857
+ "use strict";
2858
+ DEFAULT_REGULATOR_CONFIG = {
2859
+ reviewMass: { referenceScore: 0.95, healthyMass: 20, rate: 2 },
2860
+ intake: { rate: 2, scaleHours: 24 }
2861
+ };
2862
+ INTAKE_CLOCK_KEY = "IntakeClock";
2863
+ REGULATOR_LABEL = {
2864
+ "review-mass": "Review mass",
2865
+ intake: "Intake"
2866
+ };
2867
+ }
2868
+ });
2869
+
2754
2870
  // src/core/navigators/generators/srs.ts
2755
2871
  var srs_exports = {};
2756
2872
  __export(srs_exports, {
2757
2873
  default: () => SRSNavigator
2758
2874
  });
2759
- var import_moment, DEFAULT_HEALTHY_BACKLOG, BACKLOG_GROWTH_RATE, SRSNavigator;
2875
+ var import_moment, SRSNavigator;
2760
2876
  var init_srs = __esm({
2761
2877
  "src/core/navigators/generators/srs.ts"() {
2762
2878
  "use strict";
2763
2879
  import_moment = __toESM(require("moment"), 1);
2764
2880
  init_navigators();
2765
2881
  init_SrsDebugger();
2882
+ init_regulators();
2766
2883
  init_logger();
2767
- DEFAULT_HEALTHY_BACKLOG = 20;
2768
- BACKLOG_GROWTH_RATE = 2;
2769
2884
  SRSNavigator = class extends ContentNavigator {
2770
2885
  /** Human-readable name for CardGenerator interface */
2771
2886
  name;
2772
- /** Healthy backlog threshold - when exceeded, backlog pressure kicks in */
2773
- healthyBacklog;
2774
2887
  constructor(user, course, strategyData) {
2775
2888
  super(user, course, strategyData);
2776
2889
  this.name = strategyData?.name || "SRS";
2777
- const config = this.parseConfig(strategyData?.serializedData);
2778
- this.healthyBacklog = config.healthyBacklog ?? DEFAULT_HEALTHY_BACKLOG;
2779
- }
2780
- /**
2781
- * Parse configuration from serialized JSON.
2782
- */
2783
- parseConfig(serializedData) {
2784
- if (!serializedData) return {};
2785
- try {
2786
- return JSON.parse(serializedData);
2787
- } catch {
2788
- logger.warn("[SRS] Failed to parse strategy config, using defaults");
2789
- return {};
2790
- }
2791
2890
  }
2792
2891
  /**
2793
2892
  * Get review cards scored by urgency.
@@ -2795,7 +2894,6 @@ var init_srs = __esm({
2795
2894
  * Score formula combines:
2796
2895
  * - Relative overdueness: hoursOverdue / intervalHours
2797
2896
  * - Interval recency: exponential decay favoring shorter intervals
2798
- * - Backlog pressure: boost when due reviews exceed healthy threshold
2799
2897
  *
2800
2898
  * Cards not yet due are excluded (not scored as 0).
2801
2899
  *
@@ -2832,7 +2930,6 @@ var init_srs = __esm({
2832
2930
  }
2833
2931
  }
2834
2932
  }
2835
- const backlogMultiplier = this.computeBacklogMultiplier(dueReviews.length);
2836
2933
  const notDue = reviews.filter((r) => !now.isAfter(import_moment.default.utc(r.reviewTime)));
2837
2934
  let nextDueIn = null;
2838
2935
  if (notDue.length > 0) {
@@ -2843,9 +2940,8 @@ var init_srs = __esm({
2843
2940
  nextDueIn = until.asHours() < 1 ? `${Math.round(until.asMinutes())}m` : until.asHours() < 24 ? `${Math.round(until.asHours())}h` : `${Math.round(until.asDays())}d`;
2844
2941
  }
2845
2942
  if (dueReviews.length > 0) {
2846
- const pressureNote = backlogMultiplier > 1 ? ` [backlog pressure: \xD7${backlogMultiplier.toFixed(2)}]` : ` [healthy backlog]`;
2847
2943
  logger.info(
2848
- `[SRS] Course ${courseId}: ${dueReviews.length} reviews due now (of ${reviews.length} scheduled)${pressureNote}`
2944
+ `[SRS] Course ${courseId}: ${dueReviews.length} reviews due now (of ${reviews.length} scheduled)`
2849
2945
  );
2850
2946
  } else if (reviews.length > 0) {
2851
2947
  const sortedByDue = [...reviews].sort(
@@ -2862,11 +2958,12 @@ var init_srs = __esm({
2862
2958
  logger.info(`[SRS] Course ${courseId}: No reviews scheduled`);
2863
2959
  }
2864
2960
  const scored = dueReviews.map((review) => {
2865
- const { score, reason } = this.computeUrgencyScore(review, now, backlogMultiplier);
2961
+ const { score, urgency, reason } = this.computeUrgencyScore(review, now);
2866
2962
  return {
2867
2963
  cardId: review.cardId,
2868
2964
  courseId: review.courseId,
2869
2965
  score,
2966
+ reviewUrgency: urgency,
2870
2967
  reviewID: review._id,
2871
2968
  provenance: [
2872
2969
  {
@@ -2885,47 +2982,20 @@ var init_srs = __esm({
2885
2982
  courseId,
2886
2983
  scheduledTotal: reviews.length,
2887
2984
  dueNow: dueReviews.length,
2888
- healthyBacklog: this.healthyBacklog,
2889
- backlogMultiplier,
2890
- backlogGrowthRate: BACKLOG_GROWTH_RATE,
2985
+ healthyBacklog: DEFAULT_REGULATOR_CONFIG.reviewMass.healthyMass,
2986
+ reviewMass: null,
2987
+ backlogMultiplier: 1,
2988
+ backlogGrowthRate: DEFAULT_REGULATOR_CONFIG.reviewMass.rate,
2891
2989
  topReviewScore: sorted.length > 0 ? sorted[0].score : null,
2892
2990
  nextDueIn,
2893
2991
  timestamp: Date.now()
2894
2992
  });
2895
2993
  return { cards: sorted.slice(0, limit) };
2896
2994
  }
2897
- /**
2898
- * Compute the multiplicative backlog pressure based on number of due reviews.
2899
- *
2900
- * ×1.0 at or below the healthy threshold (no boost); above it, grows as
2901
- * BACKLOG_GROWTH_RATE raised to the excess expressed in multiples of the
2902
- * healthy threshold. Uncapped — self-regulating instead: reviews winning
2903
- * slots depletes dueCount, which drops the ratio and relaxes the multiplier
2904
- * next run.
2905
- *
2906
- * Examples (with default healthyBacklog=20, BACKLOG_GROWTH_RATE=1.5):
2907
- * - 10 due reviews → ×1.00 (healthy)
2908
- * - 20 due reviews → ×1.00 (at threshold, ratio 0)
2909
- * - 40 due reviews → ×1.50 (ratio 1, 2x threshold)
2910
- * - 60 due reviews → ×2.25 (ratio 2, 3x threshold — old hard cap was ×2.00 here)
2911
- * - 100 due reviews → ×5.06 (ratio 4, 5x threshold)
2912
- * - 160 due reviews → ×17.09 (ratio 7, 8x threshold)
2913
- *
2914
- * @param dueCount - Number of reviews currently due
2915
- * @returns Multiplier applied to review urgency (>= 1.0, unbounded)
2916
- */
2917
- computeBacklogMultiplier(dueCount) {
2918
- if (dueCount <= this.healthyBacklog) {
2919
- return 1;
2920
- }
2921
- const excess = dueCount - this.healthyBacklog;
2922
- const ratio = excess / this.healthyBacklog;
2923
- return Math.pow(BACKLOG_GROWTH_RATE, ratio);
2924
- }
2925
2995
  /**
2926
2996
  * Compute urgency score for a review card.
2927
2997
  *
2928
- * Three factors:
2998
+ * Two factors:
2929
2999
  * 1. Relative overdueness = hoursOverdue / intervalHours
2930
3000
  * - 2 days overdue on 3-day interval = 0.67 (urgent)
2931
3001
  * - 2 days overdue on 180-day interval = 0.01 (not urgent)
@@ -2935,20 +3005,14 @@ var init_srs = __esm({
2935
3005
  * - 30 days (720h) → ~0.56
2936
3006
  * - 180 days → ~0.30
2937
3007
  *
2938
- * 3. Backlog pressure = global *multiplier* when review backlog exceeds the
2939
- * healthy threshold (×1.0 healthy → exponential growth, uncapped, above it).
2940
- *
2941
- * Combined: (base 0.5 + urgency factors * 0.45) × backlog multiplier.
2942
- * Per-card range before pressure: ~0.57–0.95. NOT clamped to 1.0 — under a
2943
- * heavy backlog reviews scale onto the open scale to compete with (and exceed)
2944
- * new cards; there's no ceiling at all now, so a bad enough backlog always
2945
- * wins eventually — self-regulating because winning slots depletes dueCount.
3008
+ * Combined: base 0.5 + urgency factors * 0.45, so ~0.57–0.95 per card.
3009
+ * Backlog pressure is applied later, by the regulator stage, which can lift
3010
+ * reviews onto the open scale above new cards (see regulators.ts).
2946
3011
  *
2947
3012
  * @param review - The scheduled card to score
2948
3013
  * @param now - Current time
2949
- * @param backlogMultiplier - Pre-computed backlog multiplier (>= 1.0, unbounded)
2950
3014
  */
2951
- computeUrgencyScore(review, now, backlogMultiplier) {
3015
+ computeUrgencyScore(review, now) {
2952
3016
  const scheduledAt = import_moment.default.utc(review.scheduledAt);
2953
3017
  const due = import_moment.default.utc(review.reviewTime);
2954
3018
  const intervalHours = Math.max(1, due.diff(scheduledAt, "hours"));
@@ -2957,20 +3021,16 @@ var init_srs = __esm({
2957
3021
  const recencyFactor = 0.3 + 0.7 * Math.exp(-intervalHours / 720);
2958
3022
  const overdueContribution = Math.min(1, Math.max(0, relativeOverdue));
2959
3023
  const urgency = overdueContribution * 0.5 + recencyFactor * 0.5;
2960
- const baseScore = 0.5 + urgency * 0.45;
2961
- const score = baseScore * backlogMultiplier;
3024
+ const score = 0.5 + urgency * 0.45;
2962
3025
  const reasonParts = [
2963
3026
  `${Math.round(hoursOverdue)}h overdue`,
2964
3027
  `interval: ${Math.round(intervalHours)}h`,
2965
3028
  `relative: ${relativeOverdue.toFixed(2)}`,
2966
3029
  `recency: ${recencyFactor.toFixed(2)}`
2967
3030
  ];
2968
- if (backlogMultiplier > 1) {
2969
- reasonParts.push(`backlog: \xD7${backlogMultiplier.toFixed(2)}`);
2970
- }
2971
3031
  reasonParts.push("review");
2972
3032
  const reason = reasonParts.join(", ");
2973
- return { score, reason };
3033
+ return { score, urgency, reason };
2974
3034
  }
2975
3035
  };
2976
3036
  }
@@ -3025,6 +3085,8 @@ var init_WeightedFilter = __esm({
3025
3085
  init_contentNavigationStrategy();
3026
3086
  WeightedFilter = class {
3027
3087
  name;
3088
+ kind;
3089
+ liveOnly;
3028
3090
  inner;
3029
3091
  learnable;
3030
3092
  staticWeight;
@@ -3032,6 +3094,8 @@ var init_WeightedFilter = __esm({
3032
3094
  constructor(inner, learnable = DEFAULT_LEARNABLE_WEIGHT, staticWeight = false, strategyId) {
3033
3095
  this.inner = inner;
3034
3096
  this.name = inner.name;
3097
+ this.kind = inner.kind;
3098
+ this.liveOnly = inner.liveOnly;
3035
3099
  this.learnable = learnable;
3036
3100
  this.staticWeight = staticWeight;
3037
3101
  this.strategyId = strategyId;
@@ -3096,58 +3160,175 @@ var init_WeightedFilter = __esm({
3096
3160
  // src/core/navigators/filters/eloDistance.ts
3097
3161
  var eloDistance_exports = {};
3098
3162
  __export(eloDistance_exports, {
3099
- DEFAULT_HALF_LIFE: () => DEFAULT_HALF_LIFE,
3100
- DEFAULT_MAX_MULTIPLIER: () => DEFAULT_MAX_MULTIPLIER,
3101
- DEFAULT_MIN_MULTIPLIER: () => DEFAULT_MIN_MULTIPLIER,
3102
- createEloDistanceFilter: () => createEloDistanceFilter
3163
+ DEFAULT_ELO_DISTANCE_CONFIG: () => DEFAULT_ELO_DISTANCE_CONFIG,
3164
+ createEloDistanceFilter: () => createEloDistanceFilter,
3165
+ default: () => EloDistanceFilter,
3166
+ mountMultiDimEloToggle: () => mountMultiDimEloToggle,
3167
+ tagAwareGap: () => tagAwareGap
3103
3168
  });
3104
3169
  function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
3105
3170
  const normalizedDistance = distance / halfLife;
3106
3171
  const decay = Math.exp(-(normalizedDistance * normalizedDistance));
3107
3172
  return minMultiplier + (maxMultiplier - minMultiplier) * decay;
3108
3173
  }
3174
+ function resolveConfig(config) {
3175
+ return { ...DEFAULT_ELO_DISTANCE_CONFIG, ...config };
3176
+ }
3177
+ function readMultiDimElo() {
3178
+ try {
3179
+ return typeof localStorage !== "undefined" && localStorage.getItem(MULTI_DIM_ELO_KEY) === "true";
3180
+ } catch {
3181
+ return false;
3182
+ }
3183
+ }
3184
+ function mountMultiDimEloToggle() {
3185
+ if (typeof window === "undefined") return;
3186
+ const win = window;
3187
+ win.skuilder = win.skuilder || {};
3188
+ Object.defineProperty(win.skuilder, "multiDimElo", {
3189
+ configurable: true,
3190
+ enumerable: true,
3191
+ get: () => multiDimElo,
3192
+ set: (on) => {
3193
+ multiDimElo = on === true;
3194
+ try {
3195
+ if (multiDimElo) localStorage.setItem(MULTI_DIM_ELO_KEY, "true");
3196
+ else localStorage.removeItem(MULTI_DIM_ELO_KEY);
3197
+ } catch (e) {
3198
+ logger.warn(`[EloDistance] multiDimElo not persisted (localStorage unavailable): ${e}`);
3199
+ }
3200
+ logger.info(
3201
+ `[EloDistance] multiDimElo ${multiDimElo ? "on: tag-aware" : "off: per strategy config"} ELO distance from the next replan`
3202
+ );
3203
+ }
3204
+ });
3205
+ }
3206
+ function tagAwareGap(cardTags, cardElo, userElo, minTagCount) {
3207
+ const globalGap = cardElo.global.score - userElo.global.score;
3208
+ const tags = [];
3209
+ for (const tag of cardTags) {
3210
+ const user = userElo.tags[tag];
3211
+ if (!user || user.score === COUNT_ONLY_SENTINEL || user.count < minTagCount) continue;
3212
+ const card = cardElo.tags[tag]?.score ?? cardElo.global.score;
3213
+ tags.push({
3214
+ tag,
3215
+ gap: card - user.score,
3216
+ weight: user.count / (user.count + TAG_CONFIDENCE_HALF)
3217
+ });
3218
+ }
3219
+ if (tags.length === 0) return { gap: globalGap, globalGap, tags };
3220
+ const total = tags.reduce((w, t) => w + t.weight, 0);
3221
+ const tagGap = tags.reduce((g, t) => g + t.weight * t.gap, 0) / total;
3222
+ const lambda = total / (total + 1);
3223
+ return { gap: lambda * tagGap + (1 - lambda) * globalGap, globalGap, tags };
3224
+ }
3225
+ function tagReason(tags, globalGap) {
3226
+ 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(", ");
3227
+ const more = tags.length > 3 ? `, +${tags.length - 3} more` : "";
3228
+ return ` on ${tags.length} shared tag(s) [${shown}${more}] (global ${globalGap >= 0 ? "+" : ""}${Math.round(globalGap)})`;
3229
+ }
3230
+ async function applyEloDistance(cards, context, config, source) {
3231
+ const { course, userElo, userCourseElo } = context;
3232
+ const { halfLife, minMultiplier, maxMultiplier } = config;
3233
+ const tagAware = (config.tagAware || multiDimElo) && userCourseElo !== void 0;
3234
+ const missing = cards.filter((c) => tagAware || c.cardElo === void 0).map((c) => c.cardId);
3235
+ const fetched = /* @__PURE__ */ new Map();
3236
+ if (missing.length > 0) {
3237
+ const elos = await course.getCardEloData(missing);
3238
+ missing.forEach((id, i) => {
3239
+ if (elos[i]) fetched.set(id, elos[i]);
3240
+ });
3241
+ }
3242
+ return cards.map((card) => {
3243
+ const full = fetched.get(card.cardId);
3244
+ const cardElo = full?.global?.score ?? card.cardElo ?? DEFAULT_CARD_ELO;
3245
+ let distance = Math.abs(cardElo - userElo);
3246
+ let how = "";
3247
+ if (tagAware) {
3248
+ const t = full ? tagAwareGap(card.tags ?? [], full, userCourseElo, config.minTagCount) : void 0;
3249
+ if (t) distance = Math.abs(t.gap);
3250
+ how = t?.tags.length ? `, tag-aware${tagReason(t.tags, t.globalGap)}` : ", tag-aware: global (no shared tags)";
3251
+ }
3252
+ const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
3253
+ const newScore = card.score * multiplier;
3254
+ const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
3255
+ return {
3256
+ ...card,
3257
+ cardElo,
3258
+ score: newScore,
3259
+ provenance: [
3260
+ ...card.provenance,
3261
+ {
3262
+ strategy: "eloDistance",
3263
+ strategyName: source.name,
3264
+ strategyId: source.strategyId,
3265
+ action,
3266
+ score: newScore,
3267
+ reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)})${how} \u2192 ${multiplier.toFixed(2)}x`
3268
+ }
3269
+ ]
3270
+ };
3271
+ });
3272
+ }
3109
3273
  function createEloDistanceFilter(config) {
3110
- const halfLife = config?.halfLife ?? DEFAULT_HALF_LIFE;
3111
- const minMultiplier = config?.minMultiplier ?? DEFAULT_MIN_MULTIPLIER;
3112
- const maxMultiplier = config?.maxMultiplier ?? DEFAULT_MAX_MULTIPLIER;
3274
+ const resolved = resolveConfig(config);
3275
+ const source = { name: "ELO Distance Filter", strategyId: "ELO_DISTANCE_FILTER" };
3113
3276
  return {
3114
- name: "ELO Distance Filter",
3115
- async transform(cards, context) {
3116
- const { course, userElo } = context;
3117
- const cardIds = cards.map((c) => c.cardId);
3118
- const cardElos = await course.getCardEloData(cardIds);
3119
- return cards.map((card, i) => {
3120
- const cardElo = cardElos[i]?.global?.score ?? 1e3;
3121
- const distance = Math.abs(cardElo - userElo);
3122
- const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
3123
- const newScore = card.score * multiplier;
3124
- const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
3125
- return {
3126
- ...card,
3127
- score: newScore,
3128
- provenance: [
3129
- ...card.provenance,
3130
- {
3131
- strategy: "eloDistance",
3132
- strategyName: "ELO Distance Filter",
3133
- strategyId: "ELO_DISTANCE_FILTER",
3134
- action,
3135
- score: newScore,
3136
- reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)}) \u2192 ${multiplier.toFixed(2)}x`
3137
- }
3138
- ]
3139
- };
3140
- });
3141
- }
3277
+ name: source.name,
3278
+ kind: "signal",
3279
+ liveOnly: true,
3280
+ transform: (cards, context) => applyEloDistance(cards, context, resolved, source)
3142
3281
  };
3143
3282
  }
3144
- var DEFAULT_HALF_LIFE, DEFAULT_MIN_MULTIPLIER, DEFAULT_MAX_MULTIPLIER;
3283
+ var DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, COUNT_ONLY_SENTINEL, DEFAULT_CARD_ELO, MULTI_DIM_ELO_KEY, multiDimElo, EloDistanceFilter;
3145
3284
  var init_eloDistance = __esm({
3146
3285
  "src/core/navigators/filters/eloDistance.ts"() {
3147
3286
  "use strict";
3148
- DEFAULT_HALF_LIFE = 200;
3149
- DEFAULT_MIN_MULTIPLIER = 0.3;
3150
- DEFAULT_MAX_MULTIPLIER = 1;
3287
+ init_navigators();
3288
+ init_logger();
3289
+ DEFAULT_ELO_DISTANCE_CONFIG = {
3290
+ halfLife: 300,
3291
+ minMultiplier: 0.05,
3292
+ maxMultiplier: 1,
3293
+ tagAware: false,
3294
+ minTagCount: 3
3295
+ };
3296
+ TAG_CONFIDENCE_HALF = 10;
3297
+ COUNT_ONLY_SENTINEL = -1;
3298
+ DEFAULT_CARD_ELO = 1e3;
3299
+ MULTI_DIM_ELO_KEY = "skuilder:multiDimElo";
3300
+ multiDimElo = readMultiDimElo();
3301
+ mountMultiDimEloToggle();
3302
+ EloDistanceFilter = class _EloDistanceFilter extends ContentNavigator {
3303
+ name;
3304
+ /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
3305
+ static kind = "signal";
3306
+ kind = _EloDistanceFilter.kind;
3307
+ liveOnly = true;
3308
+ config;
3309
+ constructor(user, course, strategyData) {
3310
+ super(user, course, strategyData);
3311
+ this.name = strategyData.name || "ELO Distance";
3312
+ let parsed;
3313
+ try {
3314
+ parsed = strategyData.serializedData ? JSON.parse(strategyData.serializedData) : void 0;
3315
+ } catch {
3316
+ parsed = void 0;
3317
+ }
3318
+ this.config = resolveConfig(parsed);
3319
+ }
3320
+ transform(cards, context) {
3321
+ return applyEloDistance(cards, context, this.config, {
3322
+ name: this.name,
3323
+ strategyId: this.strategyId || "NAVIGATION_STRATEGY-eloDistance-default"
3324
+ });
3325
+ }
3326
+ async getWeightedCards(_limit) {
3327
+ throw new Error(
3328
+ "EloDistanceFilter is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
3329
+ );
3330
+ }
3331
+ };
3151
3332
  }
3152
3333
  });
3153
3334
 
@@ -3164,10 +3345,13 @@ var init_hierarchyDefinition = __esm({
3164
3345
  import_common6 = require("@vue-skuilder/common");
3165
3346
  init_logger();
3166
3347
  DEFAULT_MIN_COUNT2 = 3;
3167
- HierarchyDefinitionNavigator = class extends ContentNavigator {
3348
+ HierarchyDefinitionNavigator = class _HierarchyDefinitionNavigator extends ContentNavigator {
3168
3349
  config;
3169
3350
  /** Human-readable name for CardFilter interface */
3170
3351
  name;
3352
+ /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
3353
+ static kind = "gate";
3354
+ kind = _HierarchyDefinitionNavigator.kind;
3171
3355
  constructor(user, course, strategyData) {
3172
3356
  super(user, course, strategyData);
3173
3357
  this.config = this.parseConfig(strategyData.serializedData);
@@ -3434,10 +3618,13 @@ var init_userTagPreference = __esm({
3434
3618
  "src/core/navigators/filters/userTagPreference.ts"() {
3435
3619
  "use strict";
3436
3620
  init_navigators();
3437
- UserTagPreferenceFilter = class extends ContentNavigator {
3621
+ UserTagPreferenceFilter = class _UserTagPreferenceFilter extends ContentNavigator {
3438
3622
  _strategyData;
3439
3623
  /** Human-readable name for CardFilter interface */
3440
3624
  name;
3625
+ /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
3626
+ static kind = "signal";
3627
+ kind = _UserTagPreferenceFilter.kind;
3441
3628
  constructor(user, course, strategyData) {
3442
3629
  super(user, course, strategyData);
3443
3630
  this._strategyData = strategyData;
@@ -3547,6 +3734,7 @@ var init_userTagPreference = __esm({
3547
3734
  // src/core/navigators/filters/index.ts
3548
3735
  var filters_exports = {};
3549
3736
  __export(filters_exports, {
3737
+ EloDistanceFilter: () => EloDistanceFilter,
3550
3738
  UserTagPreferenceFilter: () => UserTagPreferenceFilter,
3551
3739
  createEloDistanceFilter: () => createEloDistanceFilter
3552
3740
  });
@@ -3585,10 +3773,13 @@ var init_interferenceMitigator = __esm({
3585
3773
  DEFAULT_MIN_COUNT3 = 10;
3586
3774
  DEFAULT_MIN_ELAPSED_DAYS = 3;
3587
3775
  DEFAULT_INTERFERENCE_DECAY = 0.8;
3588
- InterferenceMitigatorNavigator = class extends ContentNavigator {
3776
+ InterferenceMitigatorNavigator = class _InterferenceMitigatorNavigator extends ContentNavigator {
3589
3777
  config;
3590
3778
  /** Human-readable name for CardFilter interface */
3591
3779
  name;
3780
+ /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
3781
+ static kind = "signal";
3782
+ kind = _InterferenceMitigatorNavigator.kind;
3592
3783
  /** Precomputed map: tag -> set of { partner, decay } it interferes with */
3593
3784
  interferenceMap;
3594
3785
  constructor(user, course, strategyData) {
@@ -3804,10 +3995,13 @@ var init_relativePriority = __esm({
3804
3995
  DEFAULT_PRIORITY = 0.5;
3805
3996
  DEFAULT_PRIORITY_INFLUENCE = 0.5;
3806
3997
  DEFAULT_COMBINE_MODE = "max";
3807
- RelativePriorityNavigator = class extends ContentNavigator {
3998
+ RelativePriorityNavigator = class _RelativePriorityNavigator extends ContentNavigator {
3808
3999
  config;
3809
4000
  /** Human-readable name for CardFilter interface */
3810
4001
  name;
4002
+ /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
4003
+ static kind = "signal";
4004
+ kind = _RelativePriorityNavigator.kind;
3811
4005
  constructor(user, course, strategyData) {
3812
4006
  super(user, course, strategyData);
3813
4007
  this.config = this.parseConfig(strategyData.serializedData);
@@ -4461,6 +4655,8 @@ var init_Pipeline = __esm({
4461
4655
  init_orchestration();
4462
4656
  init_PipelineDebugger();
4463
4657
  init_diversityRerank();
4658
+ init_regulators();
4659
+ init_SrsDebugger();
4464
4660
  VERBOSE_RESULTS = true;
4465
4661
  Pipeline = class extends ContentNavigator {
4466
4662
  generator;
@@ -4486,6 +4682,13 @@ var init_Pipeline = __esm({
4486
4682
  * getWeightedCards() call, then cleared.
4487
4683
  */
4488
4684
  _ephemeralHints = null;
4685
+ /**
4686
+ * The intake valve's clock (see regulators.ts), loaded from strategy state on
4687
+ * first use and kept in memory. Writes are chained so a presentation and a
4688
+ * run can't race each other's revision.
4689
+ */
4690
+ _intakeClock = null;
4691
+ _intakeClockWrite = Promise.resolve();
4489
4692
  /**
4490
4693
  * Create a new pipeline.
4491
4694
  *
@@ -4560,13 +4763,12 @@ var init_Pipeline = __esm({
4560
4763
  }
4561
4764
  }
4562
4765
  generatorSummaries = Array.from(genMap.entries()).map(([name, data]) => {
4563
- const newCards = data.cards.filter((c) => c.provenance[0]?.reason?.includes("new card"));
4564
- const reviewCards = data.cards.filter((c) => c.provenance[0]?.reason?.includes("review"));
4766
+ const reviewCount = data.cards.filter((c) => c.reviewID).length;
4565
4767
  return {
4566
4768
  name,
4567
4769
  cardCount: data.cards.length,
4568
- newCount: newCards.length,
4569
- reviewCount: reviewCards.length,
4770
+ newCount: data.cards.length - reviewCount,
4771
+ reviewCount,
4570
4772
  topScore: Math.max(...data.cards.map((c) => c.score), 0)
4571
4773
  };
4572
4774
  });
@@ -4602,19 +4804,24 @@ var init_Pipeline = __esm({
4602
4804
  cards.filter((c) => c.provenance.some((p) => p.strategy === "prescribed")).map((c) => c.cardId)
4603
4805
  );
4604
4806
  const filterImpacts = [];
4807
+ const generatedScores = new Map(cards.map((c) => [c.cardId, c.score]));
4808
+ const gated = /* @__PURE__ */ new Set();
4605
4809
  for (const filter of this.filters) {
4606
4810
  const beforeCount = cards.length;
4607
4811
  const beforeScores = new Map(cards.map((c) => [c.cardId, c.score]));
4608
4812
  cards = await filter.transform(cards, context);
4609
4813
  let boosted = 0, penalized = 0, passed = 0;
4610
4814
  const removed = beforeCount - cards.length;
4815
+ const kind = filter.kind ?? "gate";
4611
4816
  for (const card of cards) {
4612
4817
  const before = beforeScores.get(card.cardId) ?? 0;
4613
4818
  if (card.score > before) boosted++;
4614
- else if (card.score < before) penalized++;
4615
- else passed++;
4819
+ else if (card.score < before) {
4820
+ penalized++;
4821
+ if (kind === "gate") gated.add(card.cardId);
4822
+ } else passed++;
4616
4823
  }
4617
- filterImpacts.push({ name: filter.name, boosted, penalized, passed, removed });
4824
+ filterImpacts.push({ name: filter.name, kind, boosted, penalized, passed, removed });
4618
4825
  if (prescribedIds.size > 0) {
4619
4826
  const survivingIds = new Set(cards.map((c) => c.cardId));
4620
4827
  const killedPrescribed = [...prescribedIds].filter((id) => !survivingIds.has(id));
@@ -4630,6 +4837,7 @@ var init_Pipeline = __esm({
4630
4837
  }
4631
4838
  const scoredCards = cards;
4632
4839
  cards = cards.filter((c) => c.score > 0);
4840
+ const regulators = await this.regulate(cards, generatedScores, gated);
4633
4841
  const hints = this._ephemeralHints;
4634
4842
  if (hints) {
4635
4843
  this._ephemeralHints = null;
@@ -4666,7 +4874,8 @@ var init_Pipeline = __esm({
4666
4874
  result,
4667
4875
  context.userElo,
4668
4876
  hints ?? void 0,
4669
- scoredCards
4877
+ scoredCards,
4878
+ regulators
4670
4879
  );
4671
4880
  captureRun(report);
4672
4881
  } catch (e) {
@@ -4845,6 +5054,77 @@ var init_Pipeline = __esm({
4845
5054
  logger.info(`[Pipeline] Hints applied: ${beforeCount} \u2192 ${cards.length} cards`);
4846
5055
  return cards;
4847
5056
  }
5057
+ /**
5058
+ * The regulator stage: measure each class's pressure and scale it.
5059
+ *
5060
+ * - Review mass: every due review's SRS urgency times the filters' net
5061
+ * effect on it.
5062
+ * - Intake: servable hours since a new card was presented, applied only to
5063
+ * eligible new cards (no gate penalized them). With none eligible, the
5064
+ * clock freezes.
5065
+ *
5066
+ * Mutates `cards` in place; returns the readings for the run report.
5067
+ */
5068
+ async regulate(cards, generatedScores, gated) {
5069
+ const config = DEFAULT_REGULATOR_CONFIG;
5070
+ const reviews = cards.filter((c) => c.reviewID);
5071
+ const newCards = cards.filter((c) => !c.reviewID);
5072
+ const eligibleNew = newCards.filter((c) => !gated.has(c.cardId));
5073
+ const mass = reviewMassReading(reviews, generatedScores, config.reviewMass);
5074
+ applyReading(reviews, mass);
5075
+ noteReviewPressure(this.course.getCourseID(), {
5076
+ mass: mass.urgency,
5077
+ healthyMass: config.reviewMass.healthyMass,
5078
+ rate: config.reviewMass.rate,
5079
+ multiplier: mass.multiplier
5080
+ });
5081
+ const now = Date.now();
5082
+ const clock = await this.loadIntakeClock(now);
5083
+ const stepped = stepIntakeClock(clock, now, eligibleNew.length);
5084
+ if (stepped !== clock) this.saveIntakeClock(stepped);
5085
+ const intake = intakeReading(
5086
+ stepped,
5087
+ now,
5088
+ { eligibleNew: eligibleNew.length, newCandidates: newCards.length },
5089
+ config.intake
5090
+ );
5091
+ applyReading(eligibleNew, intake);
5092
+ logger.info(
5093
+ `[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)}`
5094
+ );
5095
+ return [mass, intake];
5096
+ }
5097
+ /**
5098
+ * A card was presented. A new card's first presentation discharges the
5099
+ * intake valve: its clock restarts. Called by the SessionController.
5100
+ */
5101
+ notePresented(card) {
5102
+ if (card.status !== "new" || card.courseId !== this.course?.getCourseID()) return;
5103
+ this.saveIntakeClock(resetIntakeClock(Date.now()));
5104
+ }
5105
+ async loadIntakeClock(nowMs) {
5106
+ if (this._intakeClock) return this._intakeClock;
5107
+ let stored = null;
5108
+ try {
5109
+ stored = await this.user.getStrategyState(
5110
+ this.course.getCourseID(),
5111
+ INTAKE_CLOCK_KEY
5112
+ );
5113
+ } catch (e) {
5114
+ logger.warn(`[Pipeline:regulators] Could not read the intake clock: ${e}`);
5115
+ }
5116
+ if (stored) {
5117
+ this._intakeClock = stored;
5118
+ } else {
5119
+ this.saveIntakeClock(resetIntakeClock(nowMs));
5120
+ }
5121
+ return this._intakeClock;
5122
+ }
5123
+ saveIntakeClock(state) {
5124
+ this._intakeClock = state;
5125
+ const courseId = this.course.getCourseID();
5126
+ 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}`));
5127
+ }
4848
5128
  /**
4849
5129
  * Build shared context for generator and filters.
4850
5130
  *
@@ -4855,10 +5135,11 @@ var init_Pipeline = __esm({
4855
5135
  */
4856
5136
  async buildContext() {
4857
5137
  let userElo = 1e3;
5138
+ let userCourseElo;
4858
5139
  try {
4859
5140
  const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
4860
- const courseElo = (0, import_common8.toCourseElo)(courseReg.elo);
4861
- userElo = courseElo.global.score;
5141
+ userCourseElo = (0, import_common8.toCourseElo)(courseReg.elo);
5142
+ userElo = userCourseElo.global.score;
4862
5143
  } catch (e) {
4863
5144
  logger.debug(`[Pipeline] Could not get user ELO, using default: ${e}`);
4864
5145
  }
@@ -4870,6 +5151,7 @@ var init_Pipeline = __esm({
4870
5151
  user: this.user,
4871
5152
  course: this.course,
4872
5153
  userElo,
5154
+ ...userCourseElo ? { userCourseElo } : {},
4873
5155
  orchestration
4874
5156
  };
4875
5157
  }
@@ -4983,7 +5265,7 @@ var init_Pipeline = __esm({
4983
5265
  cards = await this.hydrateTags(cards);
4984
5266
  const fullPool = cards.slice();
4985
5267
  const context = await this.buildContext();
4986
- for (const filter of this.filters) {
5268
+ for (const filter of this.forecastFilters()) {
4987
5269
  cards = await filter.transform(cards, context);
4988
5270
  }
4989
5271
  if (opts?.hints) {
@@ -5002,6 +5284,14 @@ var init_Pipeline = __esm({
5002
5284
  cards.sort((a, b) => b.score - a.score);
5003
5285
  return opts?.limit ? cards.slice(0, opts.limit) : cards;
5004
5286
  }
5287
+ /**
5288
+ * The filters a forecast or card-space scan applies. Those start every card at
5289
+ * 1.0 without a generator, so they skip `liveOnly` filters (ELO distance),
5290
+ * which only make sense against generator scores.
5291
+ */
5292
+ forecastFilters() {
5293
+ return this.filters.filter((f) => !f.liveOnly);
5294
+ }
5005
5295
  /**
5006
5296
  * Scan every card in the course through the filter chain and report
5007
5297
  * how many are "well indicated" (score >= threshold) for the current user.
@@ -5023,7 +5313,7 @@ var init_Pipeline = __esm({
5023
5313
  cards = await this.hydrateTags(cards);
5024
5314
  const context = await this.buildContext();
5025
5315
  const filterBreakdown = [];
5026
- for (const filter of this.filters) {
5316
+ for (const filter of this.forecastFilters()) {
5027
5317
  cards = await filter.transform(cards, context);
5028
5318
  const wi = cards.filter((c) => c.score >= THRESHOLD).length;
5029
5319
  filterBreakdown.push({ name: filter.name, wellIndicated: wi });
@@ -5087,6 +5377,7 @@ var init_Pipeline = __esm({
5087
5377
  // src/core/navigators/defaults.ts
5088
5378
  var defaults_exports = {};
5089
5379
  __export(defaults_exports, {
5380
+ createDefaultEloDistanceStrategy: () => createDefaultEloDistanceStrategy,
5090
5381
  createDefaultEloStrategy: () => createDefaultEloStrategy,
5091
5382
  createDefaultPipeline: () => createDefaultPipeline,
5092
5383
  createDefaultSrsStrategy: () => createDefaultSrsStrategy
@@ -5113,12 +5404,28 @@ function createDefaultSrsStrategy(courseId) {
5113
5404
  serializedData: ""
5114
5405
  };
5115
5406
  }
5407
+ function createDefaultEloDistanceStrategy(courseId) {
5408
+ return {
5409
+ _id: "NAVIGATION_STRATEGY-eloDistance-default",
5410
+ docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
5411
+ name: "ELO Distance (default)",
5412
+ description: "Scales every candidate, new or review, by its distance from the learner's ELO",
5413
+ implementingClass: "eloDistance" /* ELO_DISTANCE */,
5414
+ course: courseId,
5415
+ // Explicit, though the filter would default to it anyway: views show what runs.
5416
+ serializedData: JSON.stringify(DEFAULT_ELO_DISTANCE_CONFIG)
5417
+ };
5418
+ }
5116
5419
  function createDefaultPipeline(user, course) {
5117
5420
  const courseId = course.getCourseID();
5118
5421
  const eloNavigator = new ELONavigator(user, course, createDefaultEloStrategy(courseId));
5119
5422
  const srsNavigator = new SRSNavigator(user, course, createDefaultSrsStrategy(courseId));
5120
5423
  const compositeGenerator = new CompositeGenerator([eloNavigator, srsNavigator]);
5121
- const eloDistanceFilter = createEloDistanceFilter();
5424
+ const eloDistanceFilter = new EloDistanceFilter(
5425
+ user,
5426
+ course,
5427
+ createDefaultEloDistanceStrategy(courseId)
5428
+ );
5122
5429
  return new Pipeline(compositeGenerator, [eloDistanceFilter], user, course);
5123
5430
  }
5124
5431
  var init_defaults = __esm({
@@ -5134,6 +5441,131 @@ var init_defaults = __esm({
5134
5441
  }
5135
5442
  });
5136
5443
 
5444
+ // src/core/navigators/pipelinePlan.ts
5445
+ var pipelinePlan_exports = {};
5446
+ __export(pipelinePlan_exports, {
5447
+ PIPELINE_STAGES: () => PIPELINE_STAGES,
5448
+ planPipeline: () => planPipeline
5449
+ });
5450
+ function planned(strategy, role, origin) {
5451
+ const kind = role === "filter" /* FILTER */ ? getRegisteredFilterKind(strategy.implementingClass) : void 0;
5452
+ return {
5453
+ role,
5454
+ origin,
5455
+ name: strategy.name,
5456
+ implementingClass: strategy.implementingClass,
5457
+ strategy,
5458
+ ...kind ? { kind } : {}
5459
+ };
5460
+ }
5461
+ function planPipeline(strategies, courseId) {
5462
+ if (strategies.length === 0) {
5463
+ return {
5464
+ kind: "default",
5465
+ generators: [
5466
+ planned(createDefaultEloStrategy(courseId), "generator" /* GENERATOR */, "default-pipeline"),
5467
+ planned(createDefaultSrsStrategy(courseId), "generator" /* GENERATOR */, "default-pipeline")
5468
+ ],
5469
+ filters: [
5470
+ planned(
5471
+ createDefaultEloDistanceStrategy(courseId),
5472
+ "filter" /* FILTER */,
5473
+ "default-pipeline"
5474
+ )
5475
+ ],
5476
+ skipped: [],
5477
+ warnings: [],
5478
+ notes: [],
5479
+ regulators: DEFAULT_REGULATOR_CONFIG
5480
+ };
5481
+ }
5482
+ const generators = [];
5483
+ const filters = [];
5484
+ const skipped = [];
5485
+ const warnings = [];
5486
+ for (const s of strategies) {
5487
+ if (isGenerator(s.implementingClass)) {
5488
+ generators.push(planned(s, "generator" /* GENERATOR */, "strategy-doc"));
5489
+ } else if (isFilter(s.implementingClass)) {
5490
+ filters.push(planned(s, "filter" /* FILTER */, "strategy-doc"));
5491
+ } else {
5492
+ skipped.push({ strategy: s, reason: "not a registered generator or filter" });
5493
+ warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
5494
+ }
5495
+ }
5496
+ const declared = new Set(generators.map((g) => g.implementingClass));
5497
+ if (!declared.has(createDefaultEloStrategy(courseId).implementingClass)) {
5498
+ generators.push(
5499
+ planned(createDefaultEloStrategy(courseId), "generator" /* GENERATOR */, "assembler-default")
5500
+ );
5501
+ }
5502
+ if (!declared.has(createDefaultSrsStrategy(courseId).implementingClass)) {
5503
+ generators.push(
5504
+ planned(createDefaultSrsStrategy(courseId), "generator" /* GENERATOR */, "assembler-default")
5505
+ );
5506
+ }
5507
+ const eloDistance = createDefaultEloDistanceStrategy(courseId);
5508
+ if (!filters.some((f) => f.implementingClass === eloDistance.implementingClass)) {
5509
+ filters.push(planned(eloDistance, "filter" /* FILTER */, "assembler-default"));
5510
+ }
5511
+ filters.sort((a, b) => a.name.localeCompare(b.name));
5512
+ return {
5513
+ kind: "assembled",
5514
+ generators,
5515
+ filters,
5516
+ skipped,
5517
+ warnings,
5518
+ notes: [],
5519
+ regulators: DEFAULT_REGULATOR_CONFIG
5520
+ };
5521
+ }
5522
+ var PIPELINE_STAGES;
5523
+ var init_pipelinePlan = __esm({
5524
+ "src/core/navigators/pipelinePlan.ts"() {
5525
+ "use strict";
5526
+ init_navigators();
5527
+ init_regulators();
5528
+ init_defaults();
5529
+ PIPELINE_STAGES = [
5530
+ {
5531
+ key: "generate",
5532
+ title: "Generate",
5533
+ 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."
5534
+ },
5535
+ {
5536
+ key: "filter",
5537
+ title: "Filter",
5538
+ 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."
5539
+ },
5540
+ {
5541
+ key: "drop-zero",
5542
+ title: "Drop zero scores",
5543
+ summary: "Candidates whose score reached 0 leave the pool."
5544
+ },
5545
+ {
5546
+ key: "regulate",
5547
+ title: "Regulate",
5548
+ 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."
5549
+ },
5550
+ {
5551
+ key: "hints",
5552
+ title: "Apply hints",
5553
+ 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."
5554
+ },
5555
+ {
5556
+ key: "diversity",
5557
+ title: "Diversity re-rank",
5558
+ 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."
5559
+ },
5560
+ {
5561
+ key: "select",
5562
+ title: "Select",
5563
+ summary: "Highest scores first, up to the run's limit. The session mixes them into its supply queue."
5564
+ }
5565
+ ];
5566
+ }
5567
+ });
5568
+
5137
5569
  // src/core/navigators/PipelineAssembler.ts
5138
5570
  var PipelineAssembler_exports = {};
5139
5571
  __export(PipelineAssembler_exports, {
@@ -5148,16 +5580,16 @@ var init_PipelineAssembler = __esm({
5148
5580
  init_Pipeline();
5149
5581
  init_logger();
5150
5582
  init_CompositeGenerator();
5151
- init_defaults();
5583
+ init_pipelinePlan();
5152
5584
  PipelineAssembler = class {
5153
5585
  /**
5154
5586
  * Assembles a navigation pipeline from strategy documents.
5155
5587
  *
5156
- * 1. Separates into generators and filters by role
5157
- * 2. Validates at least one generator exists (or creates default ELO)
5158
- * 3. Instantiates generators - wraps multiple in CompositeGenerator
5159
- * 4. Instantiates filters
5160
- * 5. Returns Pipeline(generator, filters)
5588
+ * 1. Plans: classifies by role, adds default ELO/SRS and ELO distance, orders filters
5589
+ * (`planPipeline`)
5590
+ * 2. Instantiates generators - wraps multiple in CompositeGenerator
5591
+ * 3. Instantiates filters
5592
+ * 4. Returns Pipeline(generator, filters)
5161
5593
  *
5162
5594
  * @param input - Strategy documents plus user/course interfaces
5163
5595
  * @returns Assembled pipeline and any warnings
@@ -5173,28 +5605,17 @@ var init_PipelineAssembler = __esm({
5173
5605
  warnings
5174
5606
  };
5175
5607
  }
5176
- const generatorStrategies = [];
5177
- const filterStrategies = [];
5178
- for (const s of strategies) {
5179
- if (isGenerator(s.implementingClass)) {
5180
- generatorStrategies.push(s);
5181
- } else if (isFilter(s.implementingClass)) {
5182
- filterStrategies.push(s);
5183
- } else {
5184
- warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
5608
+ const plan = planPipeline(strategies, course.getCourseID());
5609
+ warnings.push(...plan.warnings);
5610
+ for (const n of [...plan.generators, ...plan.filters]) {
5611
+ if (n.origin === "assembler-default") {
5612
+ logger.debug(
5613
+ `[PipelineAssembler] No ${n.implementingClass} ${n.role} configured, adding default`
5614
+ );
5185
5615
  }
5186
5616
  }
5187
- const courseId = course.getCourseID();
5188
- const hasElo = generatorStrategies.some((s) => s.implementingClass === "elo" /* ELO */);
5189
- const hasSrs = generatorStrategies.some((s) => s.implementingClass === "srs" /* SRS */);
5190
- if (!hasElo) {
5191
- logger.debug("[PipelineAssembler] No ELO generator configured, adding default");
5192
- generatorStrategies.push(createDefaultEloStrategy(courseId));
5193
- }
5194
- if (!hasSrs) {
5195
- logger.debug("[PipelineAssembler] No SRS generator configured, adding default");
5196
- generatorStrategies.push(createDefaultSrsStrategy(courseId));
5197
- }
5617
+ const generatorStrategies = plan.generators.map((g) => g.strategy);
5618
+ const sortedFilterStrategies = plan.filters.map((f) => f.strategy);
5198
5619
  if (generatorStrategies.length === 0) {
5199
5620
  warnings.push("No generator strategy found");
5200
5621
  return {
@@ -5216,9 +5637,6 @@ var init_PipelineAssembler = __esm({
5216
5637
  generator = await CompositeGenerator.fromStrategies(user, course, generatorStrategies);
5217
5638
  }
5218
5639
  const filters = [];
5219
- const sortedFilterStrategies = [...filterStrategies].sort(
5220
- (a, b) => a.name.localeCompare(b.name)
5221
- );
5222
5640
  for (const filterStrategy of sortedFilterStrategies) {
5223
5641
  try {
5224
5642
  const nav = await ContentNavigator.create(user, course, filterStrategy);
@@ -5286,7 +5704,9 @@ var init_3 = __esm({
5286
5704
  "./generators/prescribed.ts": () => Promise.resolve().then(() => (init_prescribed(), prescribed_exports)),
5287
5705
  "./generators/srs.ts": () => Promise.resolve().then(() => (init_srs(), srs_exports)),
5288
5706
  "./generators/types.ts": () => Promise.resolve().then(() => (init_types(), types_exports)),
5289
- "./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports))
5707
+ "./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports)),
5708
+ "./pipelinePlan.ts": () => Promise.resolve().then(() => (init_pipelinePlan(), pipelinePlan_exports)),
5709
+ "./regulators.ts": () => Promise.resolve().then(() => (init_regulators(), regulators_exports))
5290
5710
  });
5291
5711
  }
5292
5712
  });
@@ -5307,6 +5727,7 @@ __export(navigators_exports, {
5307
5727
  drainCapturedRuns: () => drainCapturedRuns,
5308
5728
  getActivePipeline: () => getActivePipeline,
5309
5729
  getCardOrigin: () => getCardOrigin,
5730
+ getRegisteredFilterKind: () => getRegisteredFilterKind,
5310
5731
  getRegisteredNavigator: () => getRegisteredNavigator,
5311
5732
  getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
5312
5733
  getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
@@ -5335,6 +5756,10 @@ function hasRegisteredNavigator(implementingClass) {
5335
5756
  function getRegisteredNavigatorRole(implementingClass) {
5336
5757
  return navigatorRegistry.get(implementingClass)?.role;
5337
5758
  }
5759
+ function getRegisteredFilterKind(implementingClass) {
5760
+ const ctor = navigatorRegistry.get(implementingClass)?.constructor;
5761
+ return ctor?.kind;
5762
+ }
5338
5763
  function getRegisteredNavigatorNames() {
5339
5764
  return Array.from(navigatorRegistry.keys());
5340
5765
  }
@@ -5352,17 +5777,20 @@ async function initializeNavigatorRegistry() {
5352
5777
  hierarchyModule,
5353
5778
  interferenceModule,
5354
5779
  relativePriorityModule,
5355
- userTagPreferenceModule
5780
+ userTagPreferenceModule,
5781
+ eloDistanceModule
5356
5782
  ] = await Promise.all([
5357
5783
  Promise.resolve().then(() => (init_hierarchyDefinition(), hierarchyDefinition_exports)),
5358
5784
  Promise.resolve().then(() => (init_interferenceMitigator(), interferenceMitigator_exports)),
5359
5785
  Promise.resolve().then(() => (init_relativePriority(), relativePriority_exports)),
5360
- Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports))
5786
+ Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports)),
5787
+ Promise.resolve().then(() => (init_eloDistance(), eloDistance_exports))
5361
5788
  ]);
5362
5789
  registerNavigator("hierarchyDefinition", hierarchyModule.default);
5363
5790
  registerNavigator("interferenceMitigator", interferenceModule.default);
5364
5791
  registerNavigator("relativePriority", relativePriorityModule.default);
5365
5792
  registerNavigator("userTagPreference", userTagPreferenceModule.default);
5793
+ registerNavigator("eloDistance", eloDistanceModule.default);
5366
5794
  logger.debug(
5367
5795
  `[NavigatorRegistry] Initialized ${navigatorRegistry.size} navigators: ${getRegisteredNavigatorNames().join(", ")}`
5368
5796
  );
@@ -5410,6 +5838,7 @@ var init_navigators = __esm({
5410
5838
  Navigators2["INTERFERENCE"] = "interferenceMitigator";
5411
5839
  Navigators2["RELATIVE_PRIORITY"] = "relativePriority";
5412
5840
  Navigators2["USER_TAG_PREFERENCE"] = "userTagPreference";
5841
+ Navigators2["ELO_DISTANCE"] = "eloDistance";
5413
5842
  return Navigators2;
5414
5843
  })(Navigators || {});
5415
5844
  NavigatorRole = /* @__PURE__ */ ((NavigatorRole2) => {
@@ -5424,7 +5853,8 @@ var init_navigators = __esm({
5424
5853
  ["hierarchyDefinition" /* HIERARCHY */]: "filter" /* FILTER */,
5425
5854
  ["interferenceMitigator" /* INTERFERENCE */]: "filter" /* FILTER */,
5426
5855
  ["relativePriority" /* RELATIVE_PRIORITY */]: "filter" /* FILTER */,
5427
- ["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER */
5856
+ ["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER */,
5857
+ ["eloDistance" /* ELO_DISTANCE */]: "filter" /* FILTER */
5428
5858
  };
5429
5859
  ContentNavigator = class {
5430
5860
  /** User interface for this navigation session */
@@ -6158,6 +6588,14 @@ ${e.stack}` : JSON.stringify(e);
6158
6588
  setEphemeralHints(hints) {
6159
6589
  this._pendingHints = hints;
6160
6590
  }
6591
+ /**
6592
+ * Forward a presentation to the navigator (a new card restarts its intake
6593
+ * clock). Builds the navigator if the cached one has expired.
6594
+ */
6595
+ notePresented(card) {
6596
+ if (card.status !== "new") return;
6597
+ 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}`));
6598
+ }
6161
6599
  async getWeightedCards(limit) {
6162
6600
  const u = await this._getCurrentUser();
6163
6601
  try {
@@ -8207,10 +8645,11 @@ function backlogHtml(backlog) {
8207
8645
  const rows = backlog.map((b) => {
8208
8646
  const hot = b.backlogMultiplier >= 3;
8209
8647
  const multColor = b.backlogMultiplier <= 1 ? "#86efac" : hot ? "#fca5a5" : "#fcd34d";
8210
- const headroom = b.backlogMultiplier > 1 ? `climbing (\xD7${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog}-review excess, unbounded)` : "healthy \u2014 no pressure";
8648
+ const headroom = b.backlogMultiplier > 1 ? `climbing (\xD7${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog} of mass in excess, unbounded)` : "healthy \u2014 no pressure";
8649
+ const mass = b.reviewMass !== null ? ` \xB7 mass ${b.reviewMass.toFixed(1)}` : "";
8211
8650
  const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
8212
8651
  const next = b.nextDueIn ? ` <span style="opacity:.6">\xB7 next due ${esc(b.nextDueIn)}</span>` : "";
8213
- 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>`;
8652
+ 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>`;
8214
8653
  }).join("");
8215
8654
  return `<div style="margin-bottom:6px"><div style="color:#93c5fd">review backpressure</div>${rows}</div>`;
8216
8655
  }
@@ -8349,8 +8788,9 @@ function snapshotToText(s) {
8349
8788
  const headroom = b.backlogMultiplier > 1 ? "climbing" : "healthy";
8350
8789
  const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
8351
8790
  const next = b.nextDueIn ? `, next due ${b.nextDueIn}` : "";
8791
+ const mass = b.reviewMass !== null ? `, mass ${b.reviewMass.toFixed(1)}` : "";
8352
8792
  lines.push(
8353
- ` ${b.courseId.slice(0, 8)}: due ${b.dueNow}/${b.scheduledTotal} (healthy ${b.healthyBacklog})${next}; pressure \xD7${b.backlogMultiplier.toFixed(2)} ${headroom}; top review ${top}`
8793
+ ` ${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}`
8354
8794
  );
8355
8795
  }
8356
8796
  }
@@ -10832,6 +11272,7 @@ __export(core_exports, {
10832
11272
  getCardHistoryID: () => getCardHistoryID,
10833
11273
  getCardOrigin: () => getCardOrigin,
10834
11274
  getDefaultLearnableWeight: () => getDefaultLearnableWeight,
11275
+ getRegisteredFilterKind: () => getRegisteredFilterKind,
10835
11276
  getRegisteredNavigator: () => getRegisteredNavigator,
10836
11277
  getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
10837
11278
  getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
@@ -10914,6 +11355,7 @@ init_core();
10914
11355
  getCardHistoryID,
10915
11356
  getCardOrigin,
10916
11357
  getDefaultLearnableWeight,
11358
+ getRegisteredFilterKind,
10917
11359
  getRegisteredNavigator,
10918
11360
  getRegisteredNavigatorNames,
10919
11361
  getRegisteredNavigatorRole,