@vue-skuilder/db 0.2.27 → 0.2.29
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.
- package/dist/classroomDB-DLTtLZct.d.cts +86 -0
- package/dist/classroomDB-DLTtLZct.d.ts +86 -0
- package/dist/{contentSource-LPf044hY.d.ts → contentSource-B6FrSihy.d.cts} +282 -99
- package/dist/{contentSource-D3c1fMAk.d.cts → contentSource-CqJmbOZN.d.ts} +282 -99
- package/dist/core/index.d.cts +16 -92
- package/dist/core/index.d.ts +16 -92
- package/dist/core/index.js +607 -179
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +606 -179
- package/dist/core/index.mjs.map +1 -1
- package/dist/{dataLayerProvider-DaAootVV.d.ts → dataLayerProvider-B9_UCvkR.d.ts} +2 -8
- package/dist/{dataLayerProvider-CeLiFbHv.d.cts → dataLayerProvider-DUxDqMtZ.d.cts} +2 -8
- package/dist/diagnostics/index.d.cts +443 -0
- package/dist/diagnostics/index.d.ts +443 -0
- package/dist/diagnostics/index.js +932 -0
- package/dist/diagnostics/index.js.map +1 -0
- package/dist/diagnostics/index.mjs +881 -0
- package/dist/diagnostics/index.mjs.map +1 -0
- package/dist/impl/couch/index.d.cts +13 -3
- package/dist/impl/couch/index.d.ts +13 -3
- package/dist/impl/couch/index.js +605 -179
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +605 -179
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.d.cts +11 -5
- package/dist/impl/static/index.d.ts +11 -5
- package/dist/impl/static/index.js +602 -185
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +602 -185
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/{index-BkBJlGDX.d.ts → index-CVGehe_t.d.ts} +1 -1
- package/dist/{index-D7WdMDAs.d.cts → index-Ktg72jKb.d.cts} +1 -1
- package/dist/index.d.cts +73 -11
- package/dist/index.d.ts +73 -11
- package/dist/index.js +696 -200
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +683 -200
- package/dist/index.mjs.map +1 -1
- package/dist/{types-DjiFOZxJ.d.cts → types-D0oQeJAi.d.cts} +1 -1
- package/dist/{types-uJ2Xn3_X.d.ts → types-dXWfyz9B.d.ts} +1 -1
- package/dist/{types-legacy-CrwyZIvI.d.cts → types-legacy-BkOYOR6U.d.cts} +1 -1
- package/dist/{types-legacy-CrwyZIvI.d.ts → types-legacy-BkOYOR6U.d.ts} +1 -1
- package/dist/util/packer/index.d.cts +3 -3
- package/dist/util/packer/index.d.ts +3 -3
- package/package.json +15 -3
- package/src/core/interfaces/contentSource.ts +7 -0
- package/src/core/interfaces/dataLayerProvider.ts +3 -8
- package/src/core/navigators/Pipeline.ts +149 -14
- package/src/core/navigators/PipelineAssembler.ts +19 -40
- package/src/core/navigators/PipelineDebugger.ts +74 -17
- package/src/core/navigators/SrsDebugger.ts +37 -12
- package/src/core/navigators/defaults.ts +29 -5
- package/src/core/navigators/filters/WeightedFilter.ts +5 -1
- package/src/core/navigators/filters/eloDistance.ts +261 -76
- package/src/core/navigators/filters/hierarchyDefinition.ts +5 -1
- package/src/core/navigators/filters/index.ts +2 -2
- package/src/core/navigators/filters/interferenceMitigator.ts +5 -1
- package/src/core/navigators/filters/relativePriority.ts +5 -1
- package/src/core/navigators/filters/types.ts +24 -1
- package/src/core/navigators/filters/userTagPreference.ts +5 -1
- package/src/core/navigators/generators/elo.ts +23 -53
- package/src/core/navigators/generators/srs.ts +27 -124
- package/src/core/navigators/index.ts +32 -5
- package/src/core/navigators/pipelinePlan.ts +245 -0
- package/src/core/navigators/regulators.ts +230 -0
- package/src/core/types/studySession.ts +40 -0
- package/src/diagnostics/dataset.ts +242 -0
- package/src/diagnostics/derive.ts +555 -0
- package/src/diagnostics/index.ts +27 -0
- package/src/diagnostics/loader.ts +194 -0
- package/src/diagnostics/pipeline.ts +236 -0
- package/src/diagnostics/text.ts +265 -0
- package/src/impl/couch/PouchDataLayerProvider.ts +0 -23
- package/src/impl/couch/courseDB.ts +13 -0
- package/src/impl/static/StaticDataLayerProvider.ts +0 -11
- package/src/impl/static/courseDB.ts +9 -0
- package/src/index.ts +4 -0
- package/src/study/SessionController.ts +76 -2
- package/src/study/SessionOverlay.ts +7 -4
- package/tests/core/navigators/PipelineAssembler.test.ts +20 -5
- package/tests/core/navigators/eloDistanceFilter.test.ts +9 -9
- package/tsup.config.ts +1 -0
package/dist/core/index.mjs
CHANGED
|
@@ -701,7 +701,7 @@ function parseCardElo(provenance) {
|
|
|
701
701
|
const match = eloEntry.reason.match(/card:\s*(\d+)/);
|
|
702
702
|
return match ? parseInt(match[1], 10) : void 0;
|
|
703
703
|
}
|
|
704
|
-
function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints) {
|
|
704
|
+
function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints, scoredCards, regulators) {
|
|
705
705
|
const selectedIds = new Set(selectedCards.map((c) => c.cardId));
|
|
706
706
|
const toReport = (card) => ({
|
|
707
707
|
cardId: card.cardId,
|
|
@@ -709,7 +709,7 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
|
|
|
709
709
|
origin: getOrigin(card),
|
|
710
710
|
generator: card.provenance[0]?.strategyName || card.provenance[0]?.strategy,
|
|
711
711
|
finalScore: card.score,
|
|
712
|
-
cardElo: parseCardElo(card.provenance),
|
|
712
|
+
cardElo: card.cardElo ?? parseCardElo(card.provenance),
|
|
713
713
|
provenance: card.provenance,
|
|
714
714
|
tags: card.tags,
|
|
715
715
|
selected: selectedIds.has(card.cardId)
|
|
@@ -754,6 +754,23 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
|
|
|
754
754
|
note: `${discardedTailCards.length} additional candidate(s) scored below the top ${DISCARDED_KEEP_TOP} near-misses and were not retained (score ${scoreMin.toExponential(2)}\u2013${scoreMax.toExponential(2)}${eloFragment}). Likely ELO-window pull remnants filtered out by hierarchy/lesson/priority gates.`
|
|
755
755
|
};
|
|
756
756
|
}
|
|
757
|
+
const isUnselectedNew = (c) => !c.reviewID && !selectedIds.has(c.cardId);
|
|
758
|
+
const generatorScore = (c) => c.provenance[0]?.score ?? 0;
|
|
759
|
+
const keptIds = new Set(allCards.map((c) => c.cardId));
|
|
760
|
+
const hintExcluded = (c) => c.score > 0 && !keptIds.has(c.cardId);
|
|
761
|
+
let nextInLine;
|
|
762
|
+
for (const c of allCards) {
|
|
763
|
+
if (isUnselectedNew(c) && (!nextInLine || c.score > nextInLine.score)) nextInLine = c;
|
|
764
|
+
}
|
|
765
|
+
let topGenerated;
|
|
766
|
+
for (const c of scoredCards ?? allCards) {
|
|
767
|
+
if (!isUnselectedNew(c) || hintExcluded(c)) continue;
|
|
768
|
+
if (!topGenerated || generatorScore(c) > generatorScore(topGenerated)) topGenerated = c;
|
|
769
|
+
}
|
|
770
|
+
const unselectedNew = nextInLine || topGenerated ? {
|
|
771
|
+
...nextInLine ? { nextInLine: toReport(nextInLine) } : {},
|
|
772
|
+
...topGenerated && topGenerated.cardId !== nextInLine?.cardId ? { topGenerated: toReport(topGenerated) } : {}
|
|
773
|
+
} : void 0;
|
|
757
774
|
const reviewsSelected = selectedCards.filter((c) => getOrigin(c) === "review").length;
|
|
758
775
|
const newSelected = selectedCards.filter((c) => getOrigin(c) === "new").length;
|
|
759
776
|
return {
|
|
@@ -769,7 +786,9 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
|
|
|
769
786
|
reviewsSelected,
|
|
770
787
|
newSelected,
|
|
771
788
|
cards,
|
|
772
|
-
|
|
789
|
+
unselectedNew,
|
|
790
|
+
discardedTail,
|
|
791
|
+
...regulators ? { regulators } : {}
|
|
773
792
|
};
|
|
774
793
|
}
|
|
775
794
|
function formatProvenance(provenance) {
|
|
@@ -1493,11 +1512,23 @@ var SrsDebugger_exports = {};
|
|
|
1493
1512
|
__export(SrsDebugger_exports, {
|
|
1494
1513
|
captureSrsBacklog: () => captureSrsBacklog,
|
|
1495
1514
|
clearSrsBacklogDebug: () => clearSrsBacklogDebug,
|
|
1496
|
-
getSrsBacklogDebug: () => getSrsBacklogDebug
|
|
1515
|
+
getSrsBacklogDebug: () => getSrsBacklogDebug,
|
|
1516
|
+
noteReviewPressure: () => noteReviewPressure
|
|
1497
1517
|
});
|
|
1498
1518
|
function captureSrsBacklog(snapshot) {
|
|
1499
1519
|
snapshots.set(snapshot.courseId, snapshot);
|
|
1500
1520
|
}
|
|
1521
|
+
function noteReviewPressure(courseId, pressure) {
|
|
1522
|
+
const snapshot = snapshots.get(courseId);
|
|
1523
|
+
if (!snapshot) return;
|
|
1524
|
+
snapshots.set(courseId, {
|
|
1525
|
+
...snapshot,
|
|
1526
|
+
reviewMass: pressure.mass,
|
|
1527
|
+
healthyBacklog: pressure.healthyMass,
|
|
1528
|
+
backlogGrowthRate: pressure.rate,
|
|
1529
|
+
backlogMultiplier: pressure.multiplier
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1501
1532
|
function getSrsBacklogDebug() {
|
|
1502
1533
|
return [...snapshots.values()].sort((a, b) => b.timestamp - a.timestamp);
|
|
1503
1534
|
}
|
|
@@ -1776,13 +1807,12 @@ __export(elo_exports, {
|
|
|
1776
1807
|
default: () => ELONavigator
|
|
1777
1808
|
});
|
|
1778
1809
|
import { toCourseElo as toCourseElo2 } from "@vue-skuilder/common";
|
|
1779
|
-
var
|
|
1810
|
+
var ELONavigator;
|
|
1780
1811
|
var init_elo = __esm({
|
|
1781
1812
|
"src/core/navigators/generators/elo.ts"() {
|
|
1782
1813
|
"use strict";
|
|
1783
1814
|
init_navigators();
|
|
1784
1815
|
init_logger();
|
|
1785
|
-
ELO_RELEVANCE_SIGMA = 300;
|
|
1786
1816
|
ELONavigator = class extends ContentNavigator {
|
|
1787
1817
|
/** Human-readable name for CardGenerator interface */
|
|
1788
1818
|
name;
|
|
@@ -1791,10 +1821,8 @@ var init_elo = __esm({
|
|
|
1791
1821
|
this.name = strategyData?.name || "ELO";
|
|
1792
1822
|
}
|
|
1793
1823
|
/**
|
|
1794
|
-
* Get new cards
|
|
1795
|
-
*
|
|
1796
|
-
* Cards closer to user's ELO get higher scores.
|
|
1797
|
-
* Score formula: max(0, 1 - distance / 500)
|
|
1824
|
+
* Get the new cards nearest the learner's ELO, each scored with a flat
|
|
1825
|
+
* jitter in [0.5, 1]. Carries each card's ELO for the ELO distance filter.
|
|
1798
1826
|
*
|
|
1799
1827
|
* NOTE: This generator only handles NEW cards. Reviews are handled by
|
|
1800
1828
|
* SRSNavigator. Use CompositeGenerator to combine both.
|
|
@@ -1822,20 +1850,20 @@ var init_elo = __esm({
|
|
|
1822
1850
|
const scored = newCards.map((c) => {
|
|
1823
1851
|
const cardElo = c.elo ?? 1e3;
|
|
1824
1852
|
const distance = Math.abs(cardElo - userGlobalElo);
|
|
1825
|
-
const
|
|
1826
|
-
const samplingKey = relevance * (0.5 + 0.5 * Math.random());
|
|
1853
|
+
const jitter = 0.5 + 0.5 * Math.random();
|
|
1827
1854
|
return {
|
|
1828
1855
|
cardId: c.cardID,
|
|
1829
1856
|
courseId: c.courseID,
|
|
1830
|
-
score:
|
|
1857
|
+
score: jitter,
|
|
1858
|
+
cardElo,
|
|
1831
1859
|
provenance: [
|
|
1832
1860
|
{
|
|
1833
1861
|
strategy: "elo",
|
|
1834
1862
|
strategyName: this.strategyName || this.name,
|
|
1835
1863
|
strategyId: this.strategyId || "NAVIGATION_STRATEGY-ELO-default",
|
|
1836
1864
|
action: "generated",
|
|
1837
|
-
score:
|
|
1838
|
-
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}),
|
|
1865
|
+
score: jitter,
|
|
1866
|
+
reason: `new card near learner ELO: distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}), jitter ${jitter.toFixed(3)}`
|
|
1839
1867
|
}
|
|
1840
1868
|
]
|
|
1841
1869
|
};
|
|
@@ -2711,43 +2739,132 @@ var init_prescribed = __esm({
|
|
|
2711
2739
|
}
|
|
2712
2740
|
});
|
|
2713
2741
|
|
|
2742
|
+
// src/core/navigators/regulators.ts
|
|
2743
|
+
var regulators_exports = {};
|
|
2744
|
+
__export(regulators_exports, {
|
|
2745
|
+
DEFAULT_REGULATOR_CONFIG: () => DEFAULT_REGULATOR_CONFIG,
|
|
2746
|
+
INTAKE_CLOCK_KEY: () => INTAKE_CLOCK_KEY,
|
|
2747
|
+
applyReading: () => applyReading,
|
|
2748
|
+
frozenMsAt: () => frozenMsAt,
|
|
2749
|
+
intakeHours: () => intakeHours,
|
|
2750
|
+
intakeReading: () => intakeReading,
|
|
2751
|
+
resetIntakeClock: () => resetIntakeClock,
|
|
2752
|
+
reviewMassReading: () => reviewMassReading,
|
|
2753
|
+
reviewWeight: () => reviewWeight,
|
|
2754
|
+
stepIntakeClock: () => stepIntakeClock
|
|
2755
|
+
});
|
|
2756
|
+
function clamp01(x) {
|
|
2757
|
+
return Math.min(1, Math.max(0, x));
|
|
2758
|
+
}
|
|
2759
|
+
function reviewWeight(card, generatedScore, referenceScore) {
|
|
2760
|
+
if (card.reviewUrgency !== void 0 && generatedScore !== void 0 && generatedScore > 0) {
|
|
2761
|
+
return clamp01(card.reviewUrgency * (card.score / generatedScore));
|
|
2762
|
+
}
|
|
2763
|
+
return clamp01(card.score / referenceScore);
|
|
2764
|
+
}
|
|
2765
|
+
function reviewMassReading(reviews, generatedScores, config = DEFAULT_REGULATOR_CONFIG.reviewMass) {
|
|
2766
|
+
const mass = reviews.reduce(
|
|
2767
|
+
(m, c) => m + reviewWeight(c, generatedScores.get(c.cardId), config.referenceScore),
|
|
2768
|
+
0
|
|
2769
|
+
);
|
|
2770
|
+
const multiplier = mass > config.healthyMass ? Math.pow(config.rate, (mass - config.healthyMass) / config.healthyMass) : 1;
|
|
2771
|
+
return {
|
|
2772
|
+
name: "review-mass",
|
|
2773
|
+
class: "review",
|
|
2774
|
+
urgency: mass,
|
|
2775
|
+
multiplier,
|
|
2776
|
+
applied: reviews.length,
|
|
2777
|
+
inputs: { due: reviews.length, mass, healthyMass: config.healthyMass }
|
|
2778
|
+
};
|
|
2779
|
+
}
|
|
2780
|
+
function resetIntakeClock(nowMs) {
|
|
2781
|
+
return { lastNewAt: new Date(nowMs).toISOString(), frozenMs: 0, unservableSince: null };
|
|
2782
|
+
}
|
|
2783
|
+
function frozenMsAt(state, nowMs) {
|
|
2784
|
+
const open = state.unservableSince ? Math.max(0, nowMs - Date.parse(state.unservableSince)) : 0;
|
|
2785
|
+
return state.frozenMs + open;
|
|
2786
|
+
}
|
|
2787
|
+
function intakeHours(state, nowMs) {
|
|
2788
|
+
const elapsed = nowMs - Date.parse(state.lastNewAt);
|
|
2789
|
+
return Math.max(0, elapsed - frozenMsAt(state, nowMs)) / 36e5;
|
|
2790
|
+
}
|
|
2791
|
+
function stepIntakeClock(state, nowMs, eligibleNew) {
|
|
2792
|
+
if (eligibleNew === 0 && !state.unservableSince) {
|
|
2793
|
+
return { ...state, unservableSince: new Date(nowMs).toISOString() };
|
|
2794
|
+
}
|
|
2795
|
+
if (eligibleNew > 0 && state.unservableSince) {
|
|
2796
|
+
return { ...state, frozenMs: frozenMsAt(state, nowMs), unservableSince: null };
|
|
2797
|
+
}
|
|
2798
|
+
return state;
|
|
2799
|
+
}
|
|
2800
|
+
function intakeReading(state, nowMs, counts, config = DEFAULT_REGULATOR_CONFIG.intake) {
|
|
2801
|
+
const hours = intakeHours(state, nowMs);
|
|
2802
|
+
const multiplier = counts.eligibleNew > 0 ? Math.pow(config.rate, hours / config.scaleHours) : 1;
|
|
2803
|
+
return {
|
|
2804
|
+
name: "intake",
|
|
2805
|
+
class: "new",
|
|
2806
|
+
urgency: hours,
|
|
2807
|
+
multiplier,
|
|
2808
|
+
applied: counts.eligibleNew,
|
|
2809
|
+
inputs: {
|
|
2810
|
+
hoursSinceNew: hours,
|
|
2811
|
+
frozenHours: frozenMsAt(state, nowMs) / 36e5,
|
|
2812
|
+
eligibleNew: counts.eligibleNew,
|
|
2813
|
+
newCandidates: counts.newCandidates
|
|
2814
|
+
}
|
|
2815
|
+
};
|
|
2816
|
+
}
|
|
2817
|
+
function applyReading(cards, reading) {
|
|
2818
|
+
if (reading.multiplier === 1) return;
|
|
2819
|
+
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)}`;
|
|
2820
|
+
for (const card of cards) {
|
|
2821
|
+
card.score *= reading.multiplier;
|
|
2822
|
+
card.provenance.push({
|
|
2823
|
+
strategy: "regulator",
|
|
2824
|
+
strategyName: `Regulator: ${REGULATOR_LABEL[reading.name]}`,
|
|
2825
|
+
strategyId: `regulator-${reading.name}`,
|
|
2826
|
+
action: reading.multiplier > 1 ? "boosted" : "penalized",
|
|
2827
|
+
score: card.score,
|
|
2828
|
+
reason
|
|
2829
|
+
});
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
var DEFAULT_REGULATOR_CONFIG, INTAKE_CLOCK_KEY, REGULATOR_LABEL;
|
|
2833
|
+
var init_regulators = __esm({
|
|
2834
|
+
"src/core/navigators/regulators.ts"() {
|
|
2835
|
+
"use strict";
|
|
2836
|
+
DEFAULT_REGULATOR_CONFIG = {
|
|
2837
|
+
reviewMass: { referenceScore: 0.95, healthyMass: 20, rate: 2 },
|
|
2838
|
+
intake: { rate: 2, scaleHours: 24 }
|
|
2839
|
+
};
|
|
2840
|
+
INTAKE_CLOCK_KEY = "IntakeClock";
|
|
2841
|
+
REGULATOR_LABEL = {
|
|
2842
|
+
"review-mass": "Review mass",
|
|
2843
|
+
intake: "Intake"
|
|
2844
|
+
};
|
|
2845
|
+
}
|
|
2846
|
+
});
|
|
2847
|
+
|
|
2714
2848
|
// src/core/navigators/generators/srs.ts
|
|
2715
2849
|
var srs_exports = {};
|
|
2716
2850
|
__export(srs_exports, {
|
|
2717
2851
|
default: () => SRSNavigator
|
|
2718
2852
|
});
|
|
2719
2853
|
import moment from "moment";
|
|
2720
|
-
var
|
|
2854
|
+
var SRSNavigator;
|
|
2721
2855
|
var init_srs = __esm({
|
|
2722
2856
|
"src/core/navigators/generators/srs.ts"() {
|
|
2723
2857
|
"use strict";
|
|
2724
2858
|
init_navigators();
|
|
2725
2859
|
init_SrsDebugger();
|
|
2860
|
+
init_regulators();
|
|
2726
2861
|
init_logger();
|
|
2727
|
-
DEFAULT_HEALTHY_BACKLOG = 20;
|
|
2728
|
-
BACKLOG_GROWTH_RATE = 2;
|
|
2729
2862
|
SRSNavigator = class extends ContentNavigator {
|
|
2730
2863
|
/** Human-readable name for CardGenerator interface */
|
|
2731
2864
|
name;
|
|
2732
|
-
/** Healthy backlog threshold - when exceeded, backlog pressure kicks in */
|
|
2733
|
-
healthyBacklog;
|
|
2734
2865
|
constructor(user, course, strategyData) {
|
|
2735
2866
|
super(user, course, strategyData);
|
|
2736
2867
|
this.name = strategyData?.name || "SRS";
|
|
2737
|
-
const config = this.parseConfig(strategyData?.serializedData);
|
|
2738
|
-
this.healthyBacklog = config.healthyBacklog ?? DEFAULT_HEALTHY_BACKLOG;
|
|
2739
|
-
}
|
|
2740
|
-
/**
|
|
2741
|
-
* Parse configuration from serialized JSON.
|
|
2742
|
-
*/
|
|
2743
|
-
parseConfig(serializedData) {
|
|
2744
|
-
if (!serializedData) return {};
|
|
2745
|
-
try {
|
|
2746
|
-
return JSON.parse(serializedData);
|
|
2747
|
-
} catch {
|
|
2748
|
-
logger.warn("[SRS] Failed to parse strategy config, using defaults");
|
|
2749
|
-
return {};
|
|
2750
|
-
}
|
|
2751
2868
|
}
|
|
2752
2869
|
/**
|
|
2753
2870
|
* Get review cards scored by urgency.
|
|
@@ -2755,7 +2872,6 @@ var init_srs = __esm({
|
|
|
2755
2872
|
* Score formula combines:
|
|
2756
2873
|
* - Relative overdueness: hoursOverdue / intervalHours
|
|
2757
2874
|
* - Interval recency: exponential decay favoring shorter intervals
|
|
2758
|
-
* - Backlog pressure: boost when due reviews exceed healthy threshold
|
|
2759
2875
|
*
|
|
2760
2876
|
* Cards not yet due are excluded (not scored as 0).
|
|
2761
2877
|
*
|
|
@@ -2792,7 +2908,6 @@ var init_srs = __esm({
|
|
|
2792
2908
|
}
|
|
2793
2909
|
}
|
|
2794
2910
|
}
|
|
2795
|
-
const backlogMultiplier = this.computeBacklogMultiplier(dueReviews.length);
|
|
2796
2911
|
const notDue = reviews.filter((r) => !now.isAfter(moment.utc(r.reviewTime)));
|
|
2797
2912
|
let nextDueIn = null;
|
|
2798
2913
|
if (notDue.length > 0) {
|
|
@@ -2803,9 +2918,8 @@ var init_srs = __esm({
|
|
|
2803
2918
|
nextDueIn = until.asHours() < 1 ? `${Math.round(until.asMinutes())}m` : until.asHours() < 24 ? `${Math.round(until.asHours())}h` : `${Math.round(until.asDays())}d`;
|
|
2804
2919
|
}
|
|
2805
2920
|
if (dueReviews.length > 0) {
|
|
2806
|
-
const pressureNote = backlogMultiplier > 1 ? ` [backlog pressure: \xD7${backlogMultiplier.toFixed(2)}]` : ` [healthy backlog]`;
|
|
2807
2921
|
logger.info(
|
|
2808
|
-
`[SRS] Course ${courseId}: ${dueReviews.length} reviews due now (of ${reviews.length} scheduled)
|
|
2922
|
+
`[SRS] Course ${courseId}: ${dueReviews.length} reviews due now (of ${reviews.length} scheduled)`
|
|
2809
2923
|
);
|
|
2810
2924
|
} else if (reviews.length > 0) {
|
|
2811
2925
|
const sortedByDue = [...reviews].sort(
|
|
@@ -2822,11 +2936,12 @@ var init_srs = __esm({
|
|
|
2822
2936
|
logger.info(`[SRS] Course ${courseId}: No reviews scheduled`);
|
|
2823
2937
|
}
|
|
2824
2938
|
const scored = dueReviews.map((review) => {
|
|
2825
|
-
const { score, reason } = this.computeUrgencyScore(review, now
|
|
2939
|
+
const { score, urgency, reason } = this.computeUrgencyScore(review, now);
|
|
2826
2940
|
return {
|
|
2827
2941
|
cardId: review.cardId,
|
|
2828
2942
|
courseId: review.courseId,
|
|
2829
2943
|
score,
|
|
2944
|
+
reviewUrgency: urgency,
|
|
2830
2945
|
reviewID: review._id,
|
|
2831
2946
|
provenance: [
|
|
2832
2947
|
{
|
|
@@ -2845,47 +2960,20 @@ var init_srs = __esm({
|
|
|
2845
2960
|
courseId,
|
|
2846
2961
|
scheduledTotal: reviews.length,
|
|
2847
2962
|
dueNow: dueReviews.length,
|
|
2848
|
-
healthyBacklog:
|
|
2849
|
-
|
|
2850
|
-
|
|
2963
|
+
healthyBacklog: DEFAULT_REGULATOR_CONFIG.reviewMass.healthyMass,
|
|
2964
|
+
reviewMass: null,
|
|
2965
|
+
backlogMultiplier: 1,
|
|
2966
|
+
backlogGrowthRate: DEFAULT_REGULATOR_CONFIG.reviewMass.rate,
|
|
2851
2967
|
topReviewScore: sorted.length > 0 ? sorted[0].score : null,
|
|
2852
2968
|
nextDueIn,
|
|
2853
2969
|
timestamp: Date.now()
|
|
2854
2970
|
});
|
|
2855
2971
|
return { cards: sorted.slice(0, limit) };
|
|
2856
2972
|
}
|
|
2857
|
-
/**
|
|
2858
|
-
* Compute the multiplicative backlog pressure based on number of due reviews.
|
|
2859
|
-
*
|
|
2860
|
-
* ×1.0 at or below the healthy threshold (no boost); above it, grows as
|
|
2861
|
-
* BACKLOG_GROWTH_RATE raised to the excess expressed in multiples of the
|
|
2862
|
-
* healthy threshold. Uncapped — self-regulating instead: reviews winning
|
|
2863
|
-
* slots depletes dueCount, which drops the ratio and relaxes the multiplier
|
|
2864
|
-
* next run.
|
|
2865
|
-
*
|
|
2866
|
-
* Examples (with default healthyBacklog=20, BACKLOG_GROWTH_RATE=1.5):
|
|
2867
|
-
* - 10 due reviews → ×1.00 (healthy)
|
|
2868
|
-
* - 20 due reviews → ×1.00 (at threshold, ratio 0)
|
|
2869
|
-
* - 40 due reviews → ×1.50 (ratio 1, 2x threshold)
|
|
2870
|
-
* - 60 due reviews → ×2.25 (ratio 2, 3x threshold — old hard cap was ×2.00 here)
|
|
2871
|
-
* - 100 due reviews → ×5.06 (ratio 4, 5x threshold)
|
|
2872
|
-
* - 160 due reviews → ×17.09 (ratio 7, 8x threshold)
|
|
2873
|
-
*
|
|
2874
|
-
* @param dueCount - Number of reviews currently due
|
|
2875
|
-
* @returns Multiplier applied to review urgency (>= 1.0, unbounded)
|
|
2876
|
-
*/
|
|
2877
|
-
computeBacklogMultiplier(dueCount) {
|
|
2878
|
-
if (dueCount <= this.healthyBacklog) {
|
|
2879
|
-
return 1;
|
|
2880
|
-
}
|
|
2881
|
-
const excess = dueCount - this.healthyBacklog;
|
|
2882
|
-
const ratio = excess / this.healthyBacklog;
|
|
2883
|
-
return Math.pow(BACKLOG_GROWTH_RATE, ratio);
|
|
2884
|
-
}
|
|
2885
2973
|
/**
|
|
2886
2974
|
* Compute urgency score for a review card.
|
|
2887
2975
|
*
|
|
2888
|
-
*
|
|
2976
|
+
* Two factors:
|
|
2889
2977
|
* 1. Relative overdueness = hoursOverdue / intervalHours
|
|
2890
2978
|
* - 2 days overdue on 3-day interval = 0.67 (urgent)
|
|
2891
2979
|
* - 2 days overdue on 180-day interval = 0.01 (not urgent)
|
|
@@ -2895,20 +2983,14 @@ var init_srs = __esm({
|
|
|
2895
2983
|
* - 30 days (720h) → ~0.56
|
|
2896
2984
|
* - 180 days → ~0.30
|
|
2897
2985
|
*
|
|
2898
|
-
*
|
|
2899
|
-
*
|
|
2900
|
-
*
|
|
2901
|
-
* Combined: (base 0.5 + urgency factors * 0.45) × backlog multiplier.
|
|
2902
|
-
* Per-card range before pressure: ~0.57–0.95. NOT clamped to 1.0 — under a
|
|
2903
|
-
* heavy backlog reviews scale onto the open scale to compete with (and exceed)
|
|
2904
|
-
* new cards; there's no ceiling at all now, so a bad enough backlog always
|
|
2905
|
-
* wins eventually — self-regulating because winning slots depletes dueCount.
|
|
2986
|
+
* Combined: base 0.5 + urgency factors * 0.45, so ~0.57–0.95 per card.
|
|
2987
|
+
* Backlog pressure is applied later, by the regulator stage, which can lift
|
|
2988
|
+
* reviews onto the open scale above new cards (see regulators.ts).
|
|
2906
2989
|
*
|
|
2907
2990
|
* @param review - The scheduled card to score
|
|
2908
2991
|
* @param now - Current time
|
|
2909
|
-
* @param backlogMultiplier - Pre-computed backlog multiplier (>= 1.0, unbounded)
|
|
2910
2992
|
*/
|
|
2911
|
-
computeUrgencyScore(review, now
|
|
2993
|
+
computeUrgencyScore(review, now) {
|
|
2912
2994
|
const scheduledAt = moment.utc(review.scheduledAt);
|
|
2913
2995
|
const due = moment.utc(review.reviewTime);
|
|
2914
2996
|
const intervalHours = Math.max(1, due.diff(scheduledAt, "hours"));
|
|
@@ -2917,20 +2999,16 @@ var init_srs = __esm({
|
|
|
2917
2999
|
const recencyFactor = 0.3 + 0.7 * Math.exp(-intervalHours / 720);
|
|
2918
3000
|
const overdueContribution = Math.min(1, Math.max(0, relativeOverdue));
|
|
2919
3001
|
const urgency = overdueContribution * 0.5 + recencyFactor * 0.5;
|
|
2920
|
-
const
|
|
2921
|
-
const score = baseScore * backlogMultiplier;
|
|
3002
|
+
const score = 0.5 + urgency * 0.45;
|
|
2922
3003
|
const reasonParts = [
|
|
2923
3004
|
`${Math.round(hoursOverdue)}h overdue`,
|
|
2924
3005
|
`interval: ${Math.round(intervalHours)}h`,
|
|
2925
3006
|
`relative: ${relativeOverdue.toFixed(2)}`,
|
|
2926
3007
|
`recency: ${recencyFactor.toFixed(2)}`
|
|
2927
3008
|
];
|
|
2928
|
-
if (backlogMultiplier > 1) {
|
|
2929
|
-
reasonParts.push(`backlog: \xD7${backlogMultiplier.toFixed(2)}`);
|
|
2930
|
-
}
|
|
2931
3009
|
reasonParts.push("review");
|
|
2932
3010
|
const reason = reasonParts.join(", ");
|
|
2933
|
-
return { score, reason };
|
|
3011
|
+
return { score, urgency, reason };
|
|
2934
3012
|
}
|
|
2935
3013
|
};
|
|
2936
3014
|
}
|
|
@@ -2985,6 +3063,8 @@ var init_WeightedFilter = __esm({
|
|
|
2985
3063
|
init_contentNavigationStrategy();
|
|
2986
3064
|
WeightedFilter = class {
|
|
2987
3065
|
name;
|
|
3066
|
+
kind;
|
|
3067
|
+
liveOnly;
|
|
2988
3068
|
inner;
|
|
2989
3069
|
learnable;
|
|
2990
3070
|
staticWeight;
|
|
@@ -2992,6 +3072,8 @@ var init_WeightedFilter = __esm({
|
|
|
2992
3072
|
constructor(inner, learnable = DEFAULT_LEARNABLE_WEIGHT, staticWeight = false, strategyId) {
|
|
2993
3073
|
this.inner = inner;
|
|
2994
3074
|
this.name = inner.name;
|
|
3075
|
+
this.kind = inner.kind;
|
|
3076
|
+
this.liveOnly = inner.liveOnly;
|
|
2995
3077
|
this.learnable = learnable;
|
|
2996
3078
|
this.staticWeight = staticWeight;
|
|
2997
3079
|
this.strategyId = strategyId;
|
|
@@ -3056,58 +3138,141 @@ var init_WeightedFilter = __esm({
|
|
|
3056
3138
|
// src/core/navigators/filters/eloDistance.ts
|
|
3057
3139
|
var eloDistance_exports = {};
|
|
3058
3140
|
__export(eloDistance_exports, {
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3141
|
+
DEFAULT_ELO_DISTANCE_CONFIG: () => DEFAULT_ELO_DISTANCE_CONFIG,
|
|
3142
|
+
createEloDistanceFilter: () => createEloDistanceFilter,
|
|
3143
|
+
default: () => EloDistanceFilter,
|
|
3144
|
+
tagAwareGap: () => tagAwareGap
|
|
3063
3145
|
});
|
|
3064
3146
|
function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
|
|
3065
3147
|
const normalizedDistance = distance / halfLife;
|
|
3066
3148
|
const decay = Math.exp(-(normalizedDistance * normalizedDistance));
|
|
3067
3149
|
return minMultiplier + (maxMultiplier - minMultiplier) * decay;
|
|
3068
3150
|
}
|
|
3151
|
+
function resolveConfig(config) {
|
|
3152
|
+
return { ...DEFAULT_ELO_DISTANCE_CONFIG, ...config };
|
|
3153
|
+
}
|
|
3154
|
+
function tagAwareGap(cardTags, cardElo, userElo, minTagCount) {
|
|
3155
|
+
const globalGap = cardElo.global.score - userElo.global.score;
|
|
3156
|
+
const tags = [];
|
|
3157
|
+
for (const tag of cardTags) {
|
|
3158
|
+
const user = userElo.tags[tag];
|
|
3159
|
+
if (!user || user.score === COUNT_ONLY_SENTINEL || user.count < minTagCount) continue;
|
|
3160
|
+
const card = cardElo.tags[tag]?.score ?? cardElo.global.score;
|
|
3161
|
+
tags.push({
|
|
3162
|
+
tag,
|
|
3163
|
+
gap: card - user.score,
|
|
3164
|
+
weight: user.count / (user.count + TAG_CONFIDENCE_HALF)
|
|
3165
|
+
});
|
|
3166
|
+
}
|
|
3167
|
+
if (tags.length === 0) return { gap: globalGap, globalGap, tags };
|
|
3168
|
+
const total = tags.reduce((w, t) => w + t.weight, 0);
|
|
3169
|
+
const tagGap = tags.reduce((g, t) => g + t.weight * t.gap, 0) / total;
|
|
3170
|
+
const lambda = total / (total + 1);
|
|
3171
|
+
return { gap: lambda * tagGap + (1 - lambda) * globalGap, globalGap, tags };
|
|
3172
|
+
}
|
|
3173
|
+
function tagReason(tags, globalGap) {
|
|
3174
|
+
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(", ");
|
|
3175
|
+
const more = tags.length > 3 ? `, +${tags.length - 3} more` : "";
|
|
3176
|
+
return ` on ${tags.length} shared tag(s) [${shown}${more}] (global ${globalGap >= 0 ? "+" : ""}${Math.round(globalGap)})`;
|
|
3177
|
+
}
|
|
3178
|
+
async function applyEloDistance(cards, context, config, source) {
|
|
3179
|
+
const { course, userElo, userCourseElo } = context;
|
|
3180
|
+
const { halfLife, minMultiplier, maxMultiplier } = config;
|
|
3181
|
+
const tagAware = config.tagAware && userCourseElo !== void 0;
|
|
3182
|
+
const missing = cards.filter((c) => tagAware || c.cardElo === void 0).map((c) => c.cardId);
|
|
3183
|
+
const fetched = /* @__PURE__ */ new Map();
|
|
3184
|
+
if (missing.length > 0) {
|
|
3185
|
+
const elos = await course.getCardEloData(missing);
|
|
3186
|
+
missing.forEach((id, i) => {
|
|
3187
|
+
if (elos[i]) fetched.set(id, elos[i]);
|
|
3188
|
+
});
|
|
3189
|
+
}
|
|
3190
|
+
return cards.map((card) => {
|
|
3191
|
+
const full = fetched.get(card.cardId);
|
|
3192
|
+
const cardElo = full?.global?.score ?? card.cardElo ?? DEFAULT_CARD_ELO;
|
|
3193
|
+
let distance = Math.abs(cardElo - userElo);
|
|
3194
|
+
let how = "";
|
|
3195
|
+
if (tagAware && full) {
|
|
3196
|
+
const t = tagAwareGap(card.tags ?? [], full, userCourseElo, config.minTagCount);
|
|
3197
|
+
distance = Math.abs(t.gap);
|
|
3198
|
+
if (t.tags.length > 0) how = tagReason(t.tags, t.globalGap);
|
|
3199
|
+
}
|
|
3200
|
+
const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
|
|
3201
|
+
const newScore = card.score * multiplier;
|
|
3202
|
+
const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
|
|
3203
|
+
return {
|
|
3204
|
+
...card,
|
|
3205
|
+
cardElo,
|
|
3206
|
+
score: newScore,
|
|
3207
|
+
provenance: [
|
|
3208
|
+
...card.provenance,
|
|
3209
|
+
{
|
|
3210
|
+
strategy: "eloDistance",
|
|
3211
|
+
strategyName: source.name,
|
|
3212
|
+
strategyId: source.strategyId,
|
|
3213
|
+
action,
|
|
3214
|
+
score: newScore,
|
|
3215
|
+
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)})${how} \u2192 ${multiplier.toFixed(2)}x`
|
|
3216
|
+
}
|
|
3217
|
+
]
|
|
3218
|
+
};
|
|
3219
|
+
});
|
|
3220
|
+
}
|
|
3069
3221
|
function createEloDistanceFilter(config) {
|
|
3070
|
-
const
|
|
3071
|
-
const
|
|
3072
|
-
const maxMultiplier = config?.maxMultiplier ?? DEFAULT_MAX_MULTIPLIER;
|
|
3222
|
+
const resolved = resolveConfig(config);
|
|
3223
|
+
const source = { name: "ELO Distance Filter", strategyId: "ELO_DISTANCE_FILTER" };
|
|
3073
3224
|
return {
|
|
3074
|
-
name:
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
const cardElos = await course.getCardEloData(cardIds);
|
|
3079
|
-
return cards.map((card, i) => {
|
|
3080
|
-
const cardElo = cardElos[i]?.global?.score ?? 1e3;
|
|
3081
|
-
const distance = Math.abs(cardElo - userElo);
|
|
3082
|
-
const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
|
|
3083
|
-
const newScore = card.score * multiplier;
|
|
3084
|
-
const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
|
|
3085
|
-
return {
|
|
3086
|
-
...card,
|
|
3087
|
-
score: newScore,
|
|
3088
|
-
provenance: [
|
|
3089
|
-
...card.provenance,
|
|
3090
|
-
{
|
|
3091
|
-
strategy: "eloDistance",
|
|
3092
|
-
strategyName: "ELO Distance Filter",
|
|
3093
|
-
strategyId: "ELO_DISTANCE_FILTER",
|
|
3094
|
-
action,
|
|
3095
|
-
score: newScore,
|
|
3096
|
-
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)}) \u2192 ${multiplier.toFixed(2)}x`
|
|
3097
|
-
}
|
|
3098
|
-
]
|
|
3099
|
-
};
|
|
3100
|
-
});
|
|
3101
|
-
}
|
|
3225
|
+
name: source.name,
|
|
3226
|
+
kind: "signal",
|
|
3227
|
+
liveOnly: true,
|
|
3228
|
+
transform: (cards, context) => applyEloDistance(cards, context, resolved, source)
|
|
3102
3229
|
};
|
|
3103
3230
|
}
|
|
3104
|
-
var
|
|
3231
|
+
var DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, COUNT_ONLY_SENTINEL, DEFAULT_CARD_ELO, EloDistanceFilter;
|
|
3105
3232
|
var init_eloDistance = __esm({
|
|
3106
3233
|
"src/core/navigators/filters/eloDistance.ts"() {
|
|
3107
3234
|
"use strict";
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3235
|
+
init_navigators();
|
|
3236
|
+
DEFAULT_ELO_DISTANCE_CONFIG = {
|
|
3237
|
+
halfLife: 300,
|
|
3238
|
+
minMultiplier: 0.05,
|
|
3239
|
+
maxMultiplier: 1,
|
|
3240
|
+
tagAware: true,
|
|
3241
|
+
minTagCount: 3
|
|
3242
|
+
};
|
|
3243
|
+
TAG_CONFIDENCE_HALF = 10;
|
|
3244
|
+
COUNT_ONLY_SENTINEL = -1;
|
|
3245
|
+
DEFAULT_CARD_ELO = 1e3;
|
|
3246
|
+
EloDistanceFilter = class _EloDistanceFilter extends ContentNavigator {
|
|
3247
|
+
name;
|
|
3248
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3249
|
+
static kind = "signal";
|
|
3250
|
+
kind = _EloDistanceFilter.kind;
|
|
3251
|
+
liveOnly = true;
|
|
3252
|
+
config;
|
|
3253
|
+
constructor(user, course, strategyData) {
|
|
3254
|
+
super(user, course, strategyData);
|
|
3255
|
+
this.name = strategyData.name || "ELO Distance";
|
|
3256
|
+
let parsed;
|
|
3257
|
+
try {
|
|
3258
|
+
parsed = strategyData.serializedData ? JSON.parse(strategyData.serializedData) : void 0;
|
|
3259
|
+
} catch {
|
|
3260
|
+
parsed = void 0;
|
|
3261
|
+
}
|
|
3262
|
+
this.config = resolveConfig(parsed);
|
|
3263
|
+
}
|
|
3264
|
+
transform(cards, context) {
|
|
3265
|
+
return applyEloDistance(cards, context, this.config, {
|
|
3266
|
+
name: this.name,
|
|
3267
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-eloDistance-default"
|
|
3268
|
+
});
|
|
3269
|
+
}
|
|
3270
|
+
async getWeightedCards(_limit) {
|
|
3271
|
+
throw new Error(
|
|
3272
|
+
"EloDistanceFilter is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
|
|
3273
|
+
);
|
|
3274
|
+
}
|
|
3275
|
+
};
|
|
3111
3276
|
}
|
|
3112
3277
|
});
|
|
3113
3278
|
|
|
@@ -3124,10 +3289,13 @@ var init_hierarchyDefinition = __esm({
|
|
|
3124
3289
|
init_navigators();
|
|
3125
3290
|
init_logger();
|
|
3126
3291
|
DEFAULT_MIN_COUNT2 = 3;
|
|
3127
|
-
HierarchyDefinitionNavigator = class extends ContentNavigator {
|
|
3292
|
+
HierarchyDefinitionNavigator = class _HierarchyDefinitionNavigator extends ContentNavigator {
|
|
3128
3293
|
config;
|
|
3129
3294
|
/** Human-readable name for CardFilter interface */
|
|
3130
3295
|
name;
|
|
3296
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3297
|
+
static kind = "gate";
|
|
3298
|
+
kind = _HierarchyDefinitionNavigator.kind;
|
|
3131
3299
|
constructor(user, course, strategyData) {
|
|
3132
3300
|
super(user, course, strategyData);
|
|
3133
3301
|
this.config = this.parseConfig(strategyData.serializedData);
|
|
@@ -3394,10 +3562,13 @@ var init_userTagPreference = __esm({
|
|
|
3394
3562
|
"src/core/navigators/filters/userTagPreference.ts"() {
|
|
3395
3563
|
"use strict";
|
|
3396
3564
|
init_navigators();
|
|
3397
|
-
UserTagPreferenceFilter = class extends ContentNavigator {
|
|
3565
|
+
UserTagPreferenceFilter = class _UserTagPreferenceFilter extends ContentNavigator {
|
|
3398
3566
|
_strategyData;
|
|
3399
3567
|
/** Human-readable name for CardFilter interface */
|
|
3400
3568
|
name;
|
|
3569
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3570
|
+
static kind = "signal";
|
|
3571
|
+
kind = _UserTagPreferenceFilter.kind;
|
|
3401
3572
|
constructor(user, course, strategyData) {
|
|
3402
3573
|
super(user, course, strategyData);
|
|
3403
3574
|
this._strategyData = strategyData;
|
|
@@ -3507,6 +3678,7 @@ var init_userTagPreference = __esm({
|
|
|
3507
3678
|
// src/core/navigators/filters/index.ts
|
|
3508
3679
|
var filters_exports = {};
|
|
3509
3680
|
__export(filters_exports, {
|
|
3681
|
+
EloDistanceFilter: () => EloDistanceFilter,
|
|
3510
3682
|
UserTagPreferenceFilter: () => UserTagPreferenceFilter,
|
|
3511
3683
|
createEloDistanceFilter: () => createEloDistanceFilter
|
|
3512
3684
|
});
|
|
@@ -3545,10 +3717,13 @@ var init_interferenceMitigator = __esm({
|
|
|
3545
3717
|
DEFAULT_MIN_COUNT3 = 10;
|
|
3546
3718
|
DEFAULT_MIN_ELAPSED_DAYS = 3;
|
|
3547
3719
|
DEFAULT_INTERFERENCE_DECAY = 0.8;
|
|
3548
|
-
InterferenceMitigatorNavigator = class extends ContentNavigator {
|
|
3720
|
+
InterferenceMitigatorNavigator = class _InterferenceMitigatorNavigator extends ContentNavigator {
|
|
3549
3721
|
config;
|
|
3550
3722
|
/** Human-readable name for CardFilter interface */
|
|
3551
3723
|
name;
|
|
3724
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3725
|
+
static kind = "signal";
|
|
3726
|
+
kind = _InterferenceMitigatorNavigator.kind;
|
|
3552
3727
|
/** Precomputed map: tag -> set of { partner, decay } it interferes with */
|
|
3553
3728
|
interferenceMap;
|
|
3554
3729
|
constructor(user, course, strategyData) {
|
|
@@ -3764,10 +3939,13 @@ var init_relativePriority = __esm({
|
|
|
3764
3939
|
DEFAULT_PRIORITY = 0.5;
|
|
3765
3940
|
DEFAULT_PRIORITY_INFLUENCE = 0.5;
|
|
3766
3941
|
DEFAULT_COMBINE_MODE = "max";
|
|
3767
|
-
RelativePriorityNavigator = class extends ContentNavigator {
|
|
3942
|
+
RelativePriorityNavigator = class _RelativePriorityNavigator extends ContentNavigator {
|
|
3768
3943
|
config;
|
|
3769
3944
|
/** Human-readable name for CardFilter interface */
|
|
3770
3945
|
name;
|
|
3946
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3947
|
+
static kind = "signal";
|
|
3948
|
+
kind = _RelativePriorityNavigator.kind;
|
|
3771
3949
|
constructor(user, course, strategyData) {
|
|
3772
3950
|
super(user, course, strategyData);
|
|
3773
3951
|
this.config = this.parseConfig(strategyData.serializedData);
|
|
@@ -4421,6 +4599,8 @@ var init_Pipeline = __esm({
|
|
|
4421
4599
|
init_orchestration();
|
|
4422
4600
|
init_PipelineDebugger();
|
|
4423
4601
|
init_diversityRerank();
|
|
4602
|
+
init_regulators();
|
|
4603
|
+
init_SrsDebugger();
|
|
4424
4604
|
VERBOSE_RESULTS = true;
|
|
4425
4605
|
Pipeline = class extends ContentNavigator {
|
|
4426
4606
|
generator;
|
|
@@ -4446,6 +4626,13 @@ var init_Pipeline = __esm({
|
|
|
4446
4626
|
* getWeightedCards() call, then cleared.
|
|
4447
4627
|
*/
|
|
4448
4628
|
_ephemeralHints = null;
|
|
4629
|
+
/**
|
|
4630
|
+
* The intake valve's clock (see regulators.ts), loaded from strategy state on
|
|
4631
|
+
* first use and kept in memory. Writes are chained so a presentation and a
|
|
4632
|
+
* run can't race each other's revision.
|
|
4633
|
+
*/
|
|
4634
|
+
_intakeClock = null;
|
|
4635
|
+
_intakeClockWrite = Promise.resolve();
|
|
4449
4636
|
/**
|
|
4450
4637
|
* Create a new pipeline.
|
|
4451
4638
|
*
|
|
@@ -4520,13 +4707,12 @@ var init_Pipeline = __esm({
|
|
|
4520
4707
|
}
|
|
4521
4708
|
}
|
|
4522
4709
|
generatorSummaries = Array.from(genMap.entries()).map(([name, data]) => {
|
|
4523
|
-
const
|
|
4524
|
-
const reviewCards = data.cards.filter((c) => c.provenance[0]?.reason?.includes("review"));
|
|
4710
|
+
const reviewCount = data.cards.filter((c) => c.reviewID).length;
|
|
4525
4711
|
return {
|
|
4526
4712
|
name,
|
|
4527
4713
|
cardCount: data.cards.length,
|
|
4528
|
-
newCount:
|
|
4529
|
-
reviewCount
|
|
4714
|
+
newCount: data.cards.length - reviewCount,
|
|
4715
|
+
reviewCount,
|
|
4530
4716
|
topScore: Math.max(...data.cards.map((c) => c.score), 0)
|
|
4531
4717
|
};
|
|
4532
4718
|
});
|
|
@@ -4562,19 +4748,24 @@ var init_Pipeline = __esm({
|
|
|
4562
4748
|
cards.filter((c) => c.provenance.some((p) => p.strategy === "prescribed")).map((c) => c.cardId)
|
|
4563
4749
|
);
|
|
4564
4750
|
const filterImpacts = [];
|
|
4751
|
+
const generatedScores = new Map(cards.map((c) => [c.cardId, c.score]));
|
|
4752
|
+
const gated = /* @__PURE__ */ new Set();
|
|
4565
4753
|
for (const filter of this.filters) {
|
|
4566
4754
|
const beforeCount = cards.length;
|
|
4567
4755
|
const beforeScores = new Map(cards.map((c) => [c.cardId, c.score]));
|
|
4568
4756
|
cards = await filter.transform(cards, context);
|
|
4569
4757
|
let boosted = 0, penalized = 0, passed = 0;
|
|
4570
4758
|
const removed = beforeCount - cards.length;
|
|
4759
|
+
const kind = filter.kind ?? "gate";
|
|
4571
4760
|
for (const card of cards) {
|
|
4572
4761
|
const before = beforeScores.get(card.cardId) ?? 0;
|
|
4573
4762
|
if (card.score > before) boosted++;
|
|
4574
|
-
else if (card.score < before)
|
|
4575
|
-
|
|
4763
|
+
else if (card.score < before) {
|
|
4764
|
+
penalized++;
|
|
4765
|
+
if (kind === "gate") gated.add(card.cardId);
|
|
4766
|
+
} else passed++;
|
|
4576
4767
|
}
|
|
4577
|
-
filterImpacts.push({ name: filter.name, boosted, penalized, passed, removed });
|
|
4768
|
+
filterImpacts.push({ name: filter.name, kind, boosted, penalized, passed, removed });
|
|
4578
4769
|
if (prescribedIds.size > 0) {
|
|
4579
4770
|
const survivingIds = new Set(cards.map((c) => c.cardId));
|
|
4580
4771
|
const killedPrescribed = [...prescribedIds].filter((id) => !survivingIds.has(id));
|
|
@@ -4588,7 +4779,9 @@ var init_Pipeline = __esm({
|
|
|
4588
4779
|
}
|
|
4589
4780
|
logger.debug(`[Pipeline] Filter '${filter.name}': ${beforeScores.size} \u2192 ${cards.length} cards (\u2191${boosted} \u2193${penalized} =${passed})`);
|
|
4590
4781
|
}
|
|
4782
|
+
const scoredCards = cards;
|
|
4591
4783
|
cards = cards.filter((c) => c.score > 0);
|
|
4784
|
+
const regulators = await this.regulate(cards, generatedScores, gated);
|
|
4592
4785
|
const hints = this._ephemeralHints;
|
|
4593
4786
|
if (hints) {
|
|
4594
4787
|
this._ephemeralHints = null;
|
|
@@ -4624,7 +4817,9 @@ var init_Pipeline = __esm({
|
|
|
4624
4817
|
cards,
|
|
4625
4818
|
result,
|
|
4626
4819
|
context.userElo,
|
|
4627
|
-
hints ?? void 0
|
|
4820
|
+
hints ?? void 0,
|
|
4821
|
+
scoredCards,
|
|
4822
|
+
regulators
|
|
4628
4823
|
);
|
|
4629
4824
|
captureRun(report);
|
|
4630
4825
|
} catch (e) {
|
|
@@ -4803,6 +4998,77 @@ var init_Pipeline = __esm({
|
|
|
4803
4998
|
logger.info(`[Pipeline] Hints applied: ${beforeCount} \u2192 ${cards.length} cards`);
|
|
4804
4999
|
return cards;
|
|
4805
5000
|
}
|
|
5001
|
+
/**
|
|
5002
|
+
* The regulator stage: measure each class's pressure and scale it.
|
|
5003
|
+
*
|
|
5004
|
+
* - Review mass: every due review's SRS urgency times the filters' net
|
|
5005
|
+
* effect on it.
|
|
5006
|
+
* - Intake: servable hours since a new card was presented, applied only to
|
|
5007
|
+
* eligible new cards (no gate penalized them). With none eligible, the
|
|
5008
|
+
* clock freezes.
|
|
5009
|
+
*
|
|
5010
|
+
* Mutates `cards` in place; returns the readings for the run report.
|
|
5011
|
+
*/
|
|
5012
|
+
async regulate(cards, generatedScores, gated) {
|
|
5013
|
+
const config = DEFAULT_REGULATOR_CONFIG;
|
|
5014
|
+
const reviews = cards.filter((c) => c.reviewID);
|
|
5015
|
+
const newCards = cards.filter((c) => !c.reviewID);
|
|
5016
|
+
const eligibleNew = newCards.filter((c) => !gated.has(c.cardId));
|
|
5017
|
+
const mass = reviewMassReading(reviews, generatedScores, config.reviewMass);
|
|
5018
|
+
applyReading(reviews, mass);
|
|
5019
|
+
noteReviewPressure(this.course.getCourseID(), {
|
|
5020
|
+
mass: mass.urgency,
|
|
5021
|
+
healthyMass: config.reviewMass.healthyMass,
|
|
5022
|
+
rate: config.reviewMass.rate,
|
|
5023
|
+
multiplier: mass.multiplier
|
|
5024
|
+
});
|
|
5025
|
+
const now = Date.now();
|
|
5026
|
+
const clock = await this.loadIntakeClock(now);
|
|
5027
|
+
const stepped = stepIntakeClock(clock, now, eligibleNew.length);
|
|
5028
|
+
if (stepped !== clock) this.saveIntakeClock(stepped);
|
|
5029
|
+
const intake = intakeReading(
|
|
5030
|
+
stepped,
|
|
5031
|
+
now,
|
|
5032
|
+
{ eligibleNew: eligibleNew.length, newCandidates: newCards.length },
|
|
5033
|
+
config.intake
|
|
5034
|
+
);
|
|
5035
|
+
applyReading(eligibleNew, intake);
|
|
5036
|
+
logger.info(
|
|
5037
|
+
`[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)}`
|
|
5038
|
+
);
|
|
5039
|
+
return [mass, intake];
|
|
5040
|
+
}
|
|
5041
|
+
/**
|
|
5042
|
+
* A card was presented. A new card's first presentation discharges the
|
|
5043
|
+
* intake valve: its clock restarts. Called by the SessionController.
|
|
5044
|
+
*/
|
|
5045
|
+
notePresented(card) {
|
|
5046
|
+
if (card.status !== "new" || card.courseId !== this.course?.getCourseID()) return;
|
|
5047
|
+
this.saveIntakeClock(resetIntakeClock(Date.now()));
|
|
5048
|
+
}
|
|
5049
|
+
async loadIntakeClock(nowMs) {
|
|
5050
|
+
if (this._intakeClock) return this._intakeClock;
|
|
5051
|
+
let stored = null;
|
|
5052
|
+
try {
|
|
5053
|
+
stored = await this.user.getStrategyState(
|
|
5054
|
+
this.course.getCourseID(),
|
|
5055
|
+
INTAKE_CLOCK_KEY
|
|
5056
|
+
);
|
|
5057
|
+
} catch (e) {
|
|
5058
|
+
logger.warn(`[Pipeline:regulators] Could not read the intake clock: ${e}`);
|
|
5059
|
+
}
|
|
5060
|
+
if (stored) {
|
|
5061
|
+
this._intakeClock = stored;
|
|
5062
|
+
} else {
|
|
5063
|
+
this.saveIntakeClock(resetIntakeClock(nowMs));
|
|
5064
|
+
}
|
|
5065
|
+
return this._intakeClock;
|
|
5066
|
+
}
|
|
5067
|
+
saveIntakeClock(state) {
|
|
5068
|
+
this._intakeClock = state;
|
|
5069
|
+
const courseId = this.course.getCourseID();
|
|
5070
|
+
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}`));
|
|
5071
|
+
}
|
|
4806
5072
|
/**
|
|
4807
5073
|
* Build shared context for generator and filters.
|
|
4808
5074
|
*
|
|
@@ -4813,10 +5079,11 @@ var init_Pipeline = __esm({
|
|
|
4813
5079
|
*/
|
|
4814
5080
|
async buildContext() {
|
|
4815
5081
|
let userElo = 1e3;
|
|
5082
|
+
let userCourseElo;
|
|
4816
5083
|
try {
|
|
4817
5084
|
const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
|
|
4818
|
-
|
|
4819
|
-
userElo =
|
|
5085
|
+
userCourseElo = toCourseElo5(courseReg.elo);
|
|
5086
|
+
userElo = userCourseElo.global.score;
|
|
4820
5087
|
} catch (e) {
|
|
4821
5088
|
logger.debug(`[Pipeline] Could not get user ELO, using default: ${e}`);
|
|
4822
5089
|
}
|
|
@@ -4828,6 +5095,7 @@ var init_Pipeline = __esm({
|
|
|
4828
5095
|
user: this.user,
|
|
4829
5096
|
course: this.course,
|
|
4830
5097
|
userElo,
|
|
5098
|
+
...userCourseElo ? { userCourseElo } : {},
|
|
4831
5099
|
orchestration
|
|
4832
5100
|
};
|
|
4833
5101
|
}
|
|
@@ -4941,7 +5209,7 @@ var init_Pipeline = __esm({
|
|
|
4941
5209
|
cards = await this.hydrateTags(cards);
|
|
4942
5210
|
const fullPool = cards.slice();
|
|
4943
5211
|
const context = await this.buildContext();
|
|
4944
|
-
for (const filter of this.
|
|
5212
|
+
for (const filter of this.forecastFilters()) {
|
|
4945
5213
|
cards = await filter.transform(cards, context);
|
|
4946
5214
|
}
|
|
4947
5215
|
if (opts?.hints) {
|
|
@@ -4960,6 +5228,14 @@ var init_Pipeline = __esm({
|
|
|
4960
5228
|
cards.sort((a, b) => b.score - a.score);
|
|
4961
5229
|
return opts?.limit ? cards.slice(0, opts.limit) : cards;
|
|
4962
5230
|
}
|
|
5231
|
+
/**
|
|
5232
|
+
* The filters a forecast or card-space scan applies. Those start every card at
|
|
5233
|
+
* 1.0 without a generator, so they skip `liveOnly` filters (ELO distance),
|
|
5234
|
+
* which only make sense against generator scores.
|
|
5235
|
+
*/
|
|
5236
|
+
forecastFilters() {
|
|
5237
|
+
return this.filters.filter((f) => !f.liveOnly);
|
|
5238
|
+
}
|
|
4963
5239
|
/**
|
|
4964
5240
|
* Scan every card in the course through the filter chain and report
|
|
4965
5241
|
* how many are "well indicated" (score >= threshold) for the current user.
|
|
@@ -4981,7 +5257,7 @@ var init_Pipeline = __esm({
|
|
|
4981
5257
|
cards = await this.hydrateTags(cards);
|
|
4982
5258
|
const context = await this.buildContext();
|
|
4983
5259
|
const filterBreakdown = [];
|
|
4984
|
-
for (const filter of this.
|
|
5260
|
+
for (const filter of this.forecastFilters()) {
|
|
4985
5261
|
cards = await filter.transform(cards, context);
|
|
4986
5262
|
const wi = cards.filter((c) => c.score >= THRESHOLD).length;
|
|
4987
5263
|
filterBreakdown.push({ name: filter.name, wellIndicated: wi });
|
|
@@ -5045,6 +5321,7 @@ var init_Pipeline = __esm({
|
|
|
5045
5321
|
// src/core/navigators/defaults.ts
|
|
5046
5322
|
var defaults_exports = {};
|
|
5047
5323
|
__export(defaults_exports, {
|
|
5324
|
+
createDefaultEloDistanceStrategy: () => createDefaultEloDistanceStrategy,
|
|
5048
5325
|
createDefaultEloStrategy: () => createDefaultEloStrategy,
|
|
5049
5326
|
createDefaultPipeline: () => createDefaultPipeline,
|
|
5050
5327
|
createDefaultSrsStrategy: () => createDefaultSrsStrategy
|
|
@@ -5071,12 +5348,28 @@ function createDefaultSrsStrategy(courseId) {
|
|
|
5071
5348
|
serializedData: ""
|
|
5072
5349
|
};
|
|
5073
5350
|
}
|
|
5351
|
+
function createDefaultEloDistanceStrategy(courseId) {
|
|
5352
|
+
return {
|
|
5353
|
+
_id: "NAVIGATION_STRATEGY-eloDistance-default",
|
|
5354
|
+
docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
|
|
5355
|
+
name: "ELO Distance (default)",
|
|
5356
|
+
description: "Scales every candidate, new or review, by its distance from the learner's ELO",
|
|
5357
|
+
implementingClass: "eloDistance" /* ELO_DISTANCE */,
|
|
5358
|
+
course: courseId,
|
|
5359
|
+
// Explicit, though the filter would default to it anyway: views show what runs.
|
|
5360
|
+
serializedData: JSON.stringify(DEFAULT_ELO_DISTANCE_CONFIG)
|
|
5361
|
+
};
|
|
5362
|
+
}
|
|
5074
5363
|
function createDefaultPipeline(user, course) {
|
|
5075
5364
|
const courseId = course.getCourseID();
|
|
5076
5365
|
const eloNavigator = new ELONavigator(user, course, createDefaultEloStrategy(courseId));
|
|
5077
5366
|
const srsNavigator = new SRSNavigator(user, course, createDefaultSrsStrategy(courseId));
|
|
5078
5367
|
const compositeGenerator = new CompositeGenerator([eloNavigator, srsNavigator]);
|
|
5079
|
-
const eloDistanceFilter =
|
|
5368
|
+
const eloDistanceFilter = new EloDistanceFilter(
|
|
5369
|
+
user,
|
|
5370
|
+
course,
|
|
5371
|
+
createDefaultEloDistanceStrategy(courseId)
|
|
5372
|
+
);
|
|
5080
5373
|
return new Pipeline(compositeGenerator, [eloDistanceFilter], user, course);
|
|
5081
5374
|
}
|
|
5082
5375
|
var init_defaults = __esm({
|
|
@@ -5092,6 +5385,131 @@ var init_defaults = __esm({
|
|
|
5092
5385
|
}
|
|
5093
5386
|
});
|
|
5094
5387
|
|
|
5388
|
+
// src/core/navigators/pipelinePlan.ts
|
|
5389
|
+
var pipelinePlan_exports = {};
|
|
5390
|
+
__export(pipelinePlan_exports, {
|
|
5391
|
+
PIPELINE_STAGES: () => PIPELINE_STAGES,
|
|
5392
|
+
planPipeline: () => planPipeline
|
|
5393
|
+
});
|
|
5394
|
+
function planned(strategy, role, origin) {
|
|
5395
|
+
const kind = role === "filter" /* FILTER */ ? getRegisteredFilterKind(strategy.implementingClass) : void 0;
|
|
5396
|
+
return {
|
|
5397
|
+
role,
|
|
5398
|
+
origin,
|
|
5399
|
+
name: strategy.name,
|
|
5400
|
+
implementingClass: strategy.implementingClass,
|
|
5401
|
+
strategy,
|
|
5402
|
+
...kind ? { kind } : {}
|
|
5403
|
+
};
|
|
5404
|
+
}
|
|
5405
|
+
function planPipeline(strategies, courseId) {
|
|
5406
|
+
if (strategies.length === 0) {
|
|
5407
|
+
return {
|
|
5408
|
+
kind: "default",
|
|
5409
|
+
generators: [
|
|
5410
|
+
planned(createDefaultEloStrategy(courseId), "generator" /* GENERATOR */, "default-pipeline"),
|
|
5411
|
+
planned(createDefaultSrsStrategy(courseId), "generator" /* GENERATOR */, "default-pipeline")
|
|
5412
|
+
],
|
|
5413
|
+
filters: [
|
|
5414
|
+
planned(
|
|
5415
|
+
createDefaultEloDistanceStrategy(courseId),
|
|
5416
|
+
"filter" /* FILTER */,
|
|
5417
|
+
"default-pipeline"
|
|
5418
|
+
)
|
|
5419
|
+
],
|
|
5420
|
+
skipped: [],
|
|
5421
|
+
warnings: [],
|
|
5422
|
+
notes: [],
|
|
5423
|
+
regulators: DEFAULT_REGULATOR_CONFIG
|
|
5424
|
+
};
|
|
5425
|
+
}
|
|
5426
|
+
const generators = [];
|
|
5427
|
+
const filters = [];
|
|
5428
|
+
const skipped = [];
|
|
5429
|
+
const warnings = [];
|
|
5430
|
+
for (const s of strategies) {
|
|
5431
|
+
if (isGenerator(s.implementingClass)) {
|
|
5432
|
+
generators.push(planned(s, "generator" /* GENERATOR */, "strategy-doc"));
|
|
5433
|
+
} else if (isFilter(s.implementingClass)) {
|
|
5434
|
+
filters.push(planned(s, "filter" /* FILTER */, "strategy-doc"));
|
|
5435
|
+
} else {
|
|
5436
|
+
skipped.push({ strategy: s, reason: "not a registered generator or filter" });
|
|
5437
|
+
warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
|
|
5438
|
+
}
|
|
5439
|
+
}
|
|
5440
|
+
const declared = new Set(generators.map((g) => g.implementingClass));
|
|
5441
|
+
if (!declared.has(createDefaultEloStrategy(courseId).implementingClass)) {
|
|
5442
|
+
generators.push(
|
|
5443
|
+
planned(createDefaultEloStrategy(courseId), "generator" /* GENERATOR */, "assembler-default")
|
|
5444
|
+
);
|
|
5445
|
+
}
|
|
5446
|
+
if (!declared.has(createDefaultSrsStrategy(courseId).implementingClass)) {
|
|
5447
|
+
generators.push(
|
|
5448
|
+
planned(createDefaultSrsStrategy(courseId), "generator" /* GENERATOR */, "assembler-default")
|
|
5449
|
+
);
|
|
5450
|
+
}
|
|
5451
|
+
const eloDistance = createDefaultEloDistanceStrategy(courseId);
|
|
5452
|
+
if (!filters.some((f) => f.implementingClass === eloDistance.implementingClass)) {
|
|
5453
|
+
filters.push(planned(eloDistance, "filter" /* FILTER */, "assembler-default"));
|
|
5454
|
+
}
|
|
5455
|
+
filters.sort((a, b) => a.name.localeCompare(b.name));
|
|
5456
|
+
return {
|
|
5457
|
+
kind: "assembled",
|
|
5458
|
+
generators,
|
|
5459
|
+
filters,
|
|
5460
|
+
skipped,
|
|
5461
|
+
warnings,
|
|
5462
|
+
notes: [],
|
|
5463
|
+
regulators: DEFAULT_REGULATOR_CONFIG
|
|
5464
|
+
};
|
|
5465
|
+
}
|
|
5466
|
+
var PIPELINE_STAGES;
|
|
5467
|
+
var init_pipelinePlan = __esm({
|
|
5468
|
+
"src/core/navigators/pipelinePlan.ts"() {
|
|
5469
|
+
"use strict";
|
|
5470
|
+
init_navigators();
|
|
5471
|
+
init_regulators();
|
|
5472
|
+
init_defaults();
|
|
5473
|
+
PIPELINE_STAGES = [
|
|
5474
|
+
{
|
|
5475
|
+
key: "generate",
|
|
5476
|
+
title: "Generate",
|
|
5477
|
+
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."
|
|
5478
|
+
},
|
|
5479
|
+
{
|
|
5480
|
+
key: "filter",
|
|
5481
|
+
title: "Filter",
|
|
5482
|
+
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."
|
|
5483
|
+
},
|
|
5484
|
+
{
|
|
5485
|
+
key: "drop-zero",
|
|
5486
|
+
title: "Drop zero scores",
|
|
5487
|
+
summary: "Candidates whose score reached 0 leave the pool."
|
|
5488
|
+
},
|
|
5489
|
+
{
|
|
5490
|
+
key: "regulate",
|
|
5491
|
+
title: "Regulate",
|
|
5492
|
+
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."
|
|
5493
|
+
},
|
|
5494
|
+
{
|
|
5495
|
+
key: "hints",
|
|
5496
|
+
title: "Apply hints",
|
|
5497
|
+
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."
|
|
5498
|
+
},
|
|
5499
|
+
{
|
|
5500
|
+
key: "diversity",
|
|
5501
|
+
title: "Diversity re-rank",
|
|
5502
|
+
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."
|
|
5503
|
+
},
|
|
5504
|
+
{
|
|
5505
|
+
key: "select",
|
|
5506
|
+
title: "Select",
|
|
5507
|
+
summary: "Highest scores first, up to the run's limit. The session mixes them into its supply queue."
|
|
5508
|
+
}
|
|
5509
|
+
];
|
|
5510
|
+
}
|
|
5511
|
+
});
|
|
5512
|
+
|
|
5095
5513
|
// src/core/navigators/PipelineAssembler.ts
|
|
5096
5514
|
var PipelineAssembler_exports = {};
|
|
5097
5515
|
__export(PipelineAssembler_exports, {
|
|
@@ -5106,16 +5524,16 @@ var init_PipelineAssembler = __esm({
|
|
|
5106
5524
|
init_Pipeline();
|
|
5107
5525
|
init_logger();
|
|
5108
5526
|
init_CompositeGenerator();
|
|
5109
|
-
|
|
5527
|
+
init_pipelinePlan();
|
|
5110
5528
|
PipelineAssembler = class {
|
|
5111
5529
|
/**
|
|
5112
5530
|
* Assembles a navigation pipeline from strategy documents.
|
|
5113
5531
|
*
|
|
5114
|
-
* 1.
|
|
5115
|
-
*
|
|
5116
|
-
*
|
|
5117
|
-
*
|
|
5118
|
-
*
|
|
5532
|
+
* 1. Plans: classifies by role, adds default ELO/SRS and ELO distance, orders filters
|
|
5533
|
+
* (`planPipeline`)
|
|
5534
|
+
* 2. Instantiates generators - wraps multiple in CompositeGenerator
|
|
5535
|
+
* 3. Instantiates filters
|
|
5536
|
+
* 4. Returns Pipeline(generator, filters)
|
|
5119
5537
|
*
|
|
5120
5538
|
* @param input - Strategy documents plus user/course interfaces
|
|
5121
5539
|
* @returns Assembled pipeline and any warnings
|
|
@@ -5131,28 +5549,17 @@ var init_PipelineAssembler = __esm({
|
|
|
5131
5549
|
warnings
|
|
5132
5550
|
};
|
|
5133
5551
|
}
|
|
5134
|
-
const
|
|
5135
|
-
|
|
5136
|
-
for (const
|
|
5137
|
-
if (
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
} else {
|
|
5142
|
-
warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
|
|
5552
|
+
const plan = planPipeline(strategies, course.getCourseID());
|
|
5553
|
+
warnings.push(...plan.warnings);
|
|
5554
|
+
for (const n of [...plan.generators, ...plan.filters]) {
|
|
5555
|
+
if (n.origin === "assembler-default") {
|
|
5556
|
+
logger.debug(
|
|
5557
|
+
`[PipelineAssembler] No ${n.implementingClass} ${n.role} configured, adding default`
|
|
5558
|
+
);
|
|
5143
5559
|
}
|
|
5144
5560
|
}
|
|
5145
|
-
const
|
|
5146
|
-
const
|
|
5147
|
-
const hasSrs = generatorStrategies.some((s) => s.implementingClass === "srs" /* SRS */);
|
|
5148
|
-
if (!hasElo) {
|
|
5149
|
-
logger.debug("[PipelineAssembler] No ELO generator configured, adding default");
|
|
5150
|
-
generatorStrategies.push(createDefaultEloStrategy(courseId));
|
|
5151
|
-
}
|
|
5152
|
-
if (!hasSrs) {
|
|
5153
|
-
logger.debug("[PipelineAssembler] No SRS generator configured, adding default");
|
|
5154
|
-
generatorStrategies.push(createDefaultSrsStrategy(courseId));
|
|
5155
|
-
}
|
|
5561
|
+
const generatorStrategies = plan.generators.map((g) => g.strategy);
|
|
5562
|
+
const sortedFilterStrategies = plan.filters.map((f) => f.strategy);
|
|
5156
5563
|
if (generatorStrategies.length === 0) {
|
|
5157
5564
|
warnings.push("No generator strategy found");
|
|
5158
5565
|
return {
|
|
@@ -5174,9 +5581,6 @@ var init_PipelineAssembler = __esm({
|
|
|
5174
5581
|
generator = await CompositeGenerator.fromStrategies(user, course, generatorStrategies);
|
|
5175
5582
|
}
|
|
5176
5583
|
const filters = [];
|
|
5177
|
-
const sortedFilterStrategies = [...filterStrategies].sort(
|
|
5178
|
-
(a, b) => a.name.localeCompare(b.name)
|
|
5179
|
-
);
|
|
5180
5584
|
for (const filterStrategy of sortedFilterStrategies) {
|
|
5181
5585
|
try {
|
|
5182
5586
|
const nav = await ContentNavigator.create(user, course, filterStrategy);
|
|
@@ -5244,7 +5648,9 @@ var init_3 = __esm({
|
|
|
5244
5648
|
"./generators/prescribed.ts": () => Promise.resolve().then(() => (init_prescribed(), prescribed_exports)),
|
|
5245
5649
|
"./generators/srs.ts": () => Promise.resolve().then(() => (init_srs(), srs_exports)),
|
|
5246
5650
|
"./generators/types.ts": () => Promise.resolve().then(() => (init_types(), types_exports)),
|
|
5247
|
-
"./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports))
|
|
5651
|
+
"./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports)),
|
|
5652
|
+
"./pipelinePlan.ts": () => Promise.resolve().then(() => (init_pipelinePlan(), pipelinePlan_exports)),
|
|
5653
|
+
"./regulators.ts": () => Promise.resolve().then(() => (init_regulators(), regulators_exports))
|
|
5248
5654
|
});
|
|
5249
5655
|
}
|
|
5250
5656
|
});
|
|
@@ -5265,6 +5671,7 @@ __export(navigators_exports, {
|
|
|
5265
5671
|
drainCapturedRuns: () => drainCapturedRuns,
|
|
5266
5672
|
getActivePipeline: () => getActivePipeline,
|
|
5267
5673
|
getCardOrigin: () => getCardOrigin,
|
|
5674
|
+
getRegisteredFilterKind: () => getRegisteredFilterKind,
|
|
5268
5675
|
getRegisteredNavigator: () => getRegisteredNavigator,
|
|
5269
5676
|
getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
|
|
5270
5677
|
getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
|
|
@@ -5293,6 +5700,10 @@ function hasRegisteredNavigator(implementingClass) {
|
|
|
5293
5700
|
function getRegisteredNavigatorRole(implementingClass) {
|
|
5294
5701
|
return navigatorRegistry.get(implementingClass)?.role;
|
|
5295
5702
|
}
|
|
5703
|
+
function getRegisteredFilterKind(implementingClass) {
|
|
5704
|
+
const ctor = navigatorRegistry.get(implementingClass)?.constructor;
|
|
5705
|
+
return ctor?.kind;
|
|
5706
|
+
}
|
|
5296
5707
|
function getRegisteredNavigatorNames() {
|
|
5297
5708
|
return Array.from(navigatorRegistry.keys());
|
|
5298
5709
|
}
|
|
@@ -5310,17 +5721,20 @@ async function initializeNavigatorRegistry() {
|
|
|
5310
5721
|
hierarchyModule,
|
|
5311
5722
|
interferenceModule,
|
|
5312
5723
|
relativePriorityModule,
|
|
5313
|
-
userTagPreferenceModule
|
|
5724
|
+
userTagPreferenceModule,
|
|
5725
|
+
eloDistanceModule
|
|
5314
5726
|
] = await Promise.all([
|
|
5315
5727
|
Promise.resolve().then(() => (init_hierarchyDefinition(), hierarchyDefinition_exports)),
|
|
5316
5728
|
Promise.resolve().then(() => (init_interferenceMitigator(), interferenceMitigator_exports)),
|
|
5317
5729
|
Promise.resolve().then(() => (init_relativePriority(), relativePriority_exports)),
|
|
5318
|
-
Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports))
|
|
5730
|
+
Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports)),
|
|
5731
|
+
Promise.resolve().then(() => (init_eloDistance(), eloDistance_exports))
|
|
5319
5732
|
]);
|
|
5320
5733
|
registerNavigator("hierarchyDefinition", hierarchyModule.default);
|
|
5321
5734
|
registerNavigator("interferenceMitigator", interferenceModule.default);
|
|
5322
5735
|
registerNavigator("relativePriority", relativePriorityModule.default);
|
|
5323
5736
|
registerNavigator("userTagPreference", userTagPreferenceModule.default);
|
|
5737
|
+
registerNavigator("eloDistance", eloDistanceModule.default);
|
|
5324
5738
|
logger.debug(
|
|
5325
5739
|
`[NavigatorRegistry] Initialized ${navigatorRegistry.size} navigators: ${getRegisteredNavigatorNames().join(", ")}`
|
|
5326
5740
|
);
|
|
@@ -5368,6 +5782,7 @@ var init_navigators = __esm({
|
|
|
5368
5782
|
Navigators2["INTERFERENCE"] = "interferenceMitigator";
|
|
5369
5783
|
Navigators2["RELATIVE_PRIORITY"] = "relativePriority";
|
|
5370
5784
|
Navigators2["USER_TAG_PREFERENCE"] = "userTagPreference";
|
|
5785
|
+
Navigators2["ELO_DISTANCE"] = "eloDistance";
|
|
5371
5786
|
return Navigators2;
|
|
5372
5787
|
})(Navigators || {});
|
|
5373
5788
|
NavigatorRole = /* @__PURE__ */ ((NavigatorRole2) => {
|
|
@@ -5382,7 +5797,8 @@ var init_navigators = __esm({
|
|
|
5382
5797
|
["hierarchyDefinition" /* HIERARCHY */]: "filter" /* FILTER */,
|
|
5383
5798
|
["interferenceMitigator" /* INTERFERENCE */]: "filter" /* FILTER */,
|
|
5384
5799
|
["relativePriority" /* RELATIVE_PRIORITY */]: "filter" /* FILTER */,
|
|
5385
|
-
["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER
|
|
5800
|
+
["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER */,
|
|
5801
|
+
["eloDistance" /* ELO_DISTANCE */]: "filter" /* FILTER */
|
|
5386
5802
|
};
|
|
5387
5803
|
ContentNavigator = class {
|
|
5388
5804
|
/** User interface for this navigation session */
|
|
@@ -6121,6 +6537,14 @@ ${e.stack}` : JSON.stringify(e);
|
|
|
6121
6537
|
setEphemeralHints(hints) {
|
|
6122
6538
|
this._pendingHints = hints;
|
|
6123
6539
|
}
|
|
6540
|
+
/**
|
|
6541
|
+
* Forward a presentation to the navigator (a new card restarts its intake
|
|
6542
|
+
* clock). Builds the navigator if the cached one has expired.
|
|
6543
|
+
*/
|
|
6544
|
+
notePresented(card) {
|
|
6545
|
+
if (card.status !== "new") return;
|
|
6546
|
+
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}`));
|
|
6547
|
+
}
|
|
6124
6548
|
async getWeightedCards(limit) {
|
|
6125
6549
|
const u = await this._getCurrentUser();
|
|
6126
6550
|
try {
|
|
@@ -8172,10 +8596,11 @@ function backlogHtml(backlog) {
|
|
|
8172
8596
|
const rows = backlog.map((b) => {
|
|
8173
8597
|
const hot = b.backlogMultiplier >= 3;
|
|
8174
8598
|
const multColor = b.backlogMultiplier <= 1 ? "#86efac" : hot ? "#fca5a5" : "#fcd34d";
|
|
8175
|
-
const headroom = b.backlogMultiplier > 1 ? `climbing (\xD7${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog}
|
|
8599
|
+
const headroom = b.backlogMultiplier > 1 ? `climbing (\xD7${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog} of mass in excess, unbounded)` : "healthy \u2014 no pressure";
|
|
8600
|
+
const mass = b.reviewMass !== null ? ` \xB7 mass ${b.reviewMass.toFixed(1)}` : "";
|
|
8176
8601
|
const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
|
|
8177
8602
|
const next = b.nextDueIn ? ` <span style="opacity:.6">\xB7 next due ${esc(b.nextDueIn)}</span>` : "";
|
|
8178
|
-
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>`;
|
|
8603
|
+
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>`;
|
|
8179
8604
|
}).join("");
|
|
8180
8605
|
return `<div style="margin-bottom:6px"><div style="color:#93c5fd">review backpressure</div>${rows}</div>`;
|
|
8181
8606
|
}
|
|
@@ -8314,8 +8739,9 @@ function snapshotToText(s) {
|
|
|
8314
8739
|
const headroom = b.backlogMultiplier > 1 ? "climbing" : "healthy";
|
|
8315
8740
|
const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
|
|
8316
8741
|
const next = b.nextDueIn ? `, next due ${b.nextDueIn}` : "";
|
|
8742
|
+
const mass = b.reviewMass !== null ? `, mass ${b.reviewMass.toFixed(1)}` : "";
|
|
8317
8743
|
lines.push(
|
|
8318
|
-
` ${b.courseId.slice(0, 8)}: due ${b.dueNow}/${b.scheduledTotal} (healthy ${b.healthyBacklog})${next}; pressure \xD7${b.backlogMultiplier.toFixed(2)} ${headroom}; top review ${top}`
|
|
8744
|
+
` ${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}`
|
|
8319
8745
|
);
|
|
8320
8746
|
}
|
|
8321
8747
|
}
|
|
@@ -10812,6 +11238,7 @@ export {
|
|
|
10812
11238
|
getCardHistoryID,
|
|
10813
11239
|
getCardOrigin,
|
|
10814
11240
|
getDefaultLearnableWeight,
|
|
11241
|
+
getRegisteredFilterKind,
|
|
10815
11242
|
getRegisteredNavigator,
|
|
10816
11243
|
getRegisteredNavigatorNames,
|
|
10817
11244
|
getRegisteredNavigatorRole,
|