@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.
- package/dist/{contentSource-DpQqTG3m.d.cts → contentSource-B6FrSihy.d.cts} +218 -2
- package/dist/{contentSource-BoFBwvYa.d.ts → contentSource-CqJmbOZN.d.ts} +218 -2
- package/dist/core/index.d.cts +13 -90
- package/dist/core/index.d.ts +13 -90
- package/dist/core/index.js +621 -179
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +620 -179
- package/dist/core/index.mjs.map +1 -1
- package/dist/{dataLayerProvider-D_LJT3F4.d.ts → dataLayerProvider-B9_UCvkR.d.ts} +1 -1
- package/dist/{dataLayerProvider-Dl3cAAvQ.d.cts → dataLayerProvider-DUxDqMtZ.d.cts} +1 -1
- package/dist/diagnostics/index.d.cts +79 -6
- package/dist/diagnostics/index.d.ts +79 -6
- package/dist/diagnostics/index.js +158 -4
- package/dist/diagnostics/index.js.map +1 -1
- package/dist/diagnostics/index.mjs +156 -4
- package/dist/diagnostics/index.mjs.map +1 -1
- package/dist/impl/couch/index.d.cts +11 -2
- package/dist/impl/couch/index.d.ts +11 -2
- package/dist/impl/couch/index.js +619 -179
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +619 -179
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.d.cts +8 -2
- package/dist/impl/static/index.d.ts +8 -2
- package/dist/impl/static/index.js +616 -179
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +616 -179
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/index.d.cts +66 -5
- package/dist/index.d.ts +66 -5
- package/dist/index.js +669 -180
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +656 -180
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/interfaces/contentSource.ts +7 -0
- package/src/core/navigators/Pipeline.ts +145 -13
- package/src/core/navigators/PipelineAssembler.ts +19 -40
- package/src/core/navigators/PipelineDebugger.ts +11 -2
- 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 +320 -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 +31 -5
- package/src/core/navigators/pipelinePlan.ts +245 -0
- package/src/core/navigators/regulators.ts +230 -0
- package/src/core/types/studySession.ts +3 -0
- package/src/diagnostics/dataset.ts +13 -2
- package/src/diagnostics/index.ts +3 -0
- package/src/diagnostics/loader.ts +5 -2
- package/src/diagnostics/pipeline.ts +236 -0
- package/src/diagnostics/text.ts +26 -3
- package/src/impl/couch/courseDB.ts +13 -0
- package/src/impl/static/courseDB.ts +9 -0
- package/src/index.ts +4 -0
- package/src/study/SessionController.ts +20 -0
- 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/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, scoredCards) {
|
|
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)
|
|
@@ -787,7 +787,8 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
|
|
|
787
787
|
newSelected,
|
|
788
788
|
cards,
|
|
789
789
|
unselectedNew,
|
|
790
|
-
discardedTail
|
|
790
|
+
discardedTail,
|
|
791
|
+
...regulators ? { regulators } : {}
|
|
791
792
|
};
|
|
792
793
|
}
|
|
793
794
|
function formatProvenance(provenance) {
|
|
@@ -1511,11 +1512,23 @@ var SrsDebugger_exports = {};
|
|
|
1511
1512
|
__export(SrsDebugger_exports, {
|
|
1512
1513
|
captureSrsBacklog: () => captureSrsBacklog,
|
|
1513
1514
|
clearSrsBacklogDebug: () => clearSrsBacklogDebug,
|
|
1514
|
-
getSrsBacklogDebug: () => getSrsBacklogDebug
|
|
1515
|
+
getSrsBacklogDebug: () => getSrsBacklogDebug,
|
|
1516
|
+
noteReviewPressure: () => noteReviewPressure
|
|
1515
1517
|
});
|
|
1516
1518
|
function captureSrsBacklog(snapshot) {
|
|
1517
1519
|
snapshots.set(snapshot.courseId, snapshot);
|
|
1518
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
|
+
}
|
|
1519
1532
|
function getSrsBacklogDebug() {
|
|
1520
1533
|
return [...snapshots.values()].sort((a, b) => b.timestamp - a.timestamp);
|
|
1521
1534
|
}
|
|
@@ -1794,13 +1807,12 @@ __export(elo_exports, {
|
|
|
1794
1807
|
default: () => ELONavigator
|
|
1795
1808
|
});
|
|
1796
1809
|
import { toCourseElo as toCourseElo2 } from "@vue-skuilder/common";
|
|
1797
|
-
var
|
|
1810
|
+
var ELONavigator;
|
|
1798
1811
|
var init_elo = __esm({
|
|
1799
1812
|
"src/core/navigators/generators/elo.ts"() {
|
|
1800
1813
|
"use strict";
|
|
1801
1814
|
init_navigators();
|
|
1802
1815
|
init_logger();
|
|
1803
|
-
ELO_RELEVANCE_SIGMA = 300;
|
|
1804
1816
|
ELONavigator = class extends ContentNavigator {
|
|
1805
1817
|
/** Human-readable name for CardGenerator interface */
|
|
1806
1818
|
name;
|
|
@@ -1809,10 +1821,8 @@ var init_elo = __esm({
|
|
|
1809
1821
|
this.name = strategyData?.name || "ELO";
|
|
1810
1822
|
}
|
|
1811
1823
|
/**
|
|
1812
|
-
* Get new cards
|
|
1813
|
-
*
|
|
1814
|
-
* Cards closer to user's ELO get higher scores.
|
|
1815
|
-
* 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.
|
|
1816
1826
|
*
|
|
1817
1827
|
* NOTE: This generator only handles NEW cards. Reviews are handled by
|
|
1818
1828
|
* SRSNavigator. Use CompositeGenerator to combine both.
|
|
@@ -1840,20 +1850,20 @@ var init_elo = __esm({
|
|
|
1840
1850
|
const scored = newCards.map((c) => {
|
|
1841
1851
|
const cardElo = c.elo ?? 1e3;
|
|
1842
1852
|
const distance = Math.abs(cardElo - userGlobalElo);
|
|
1843
|
-
const
|
|
1844
|
-
const samplingKey = relevance * (0.5 + 0.5 * Math.random());
|
|
1853
|
+
const jitter = 0.5 + 0.5 * Math.random();
|
|
1845
1854
|
return {
|
|
1846
1855
|
cardId: c.cardID,
|
|
1847
1856
|
courseId: c.courseID,
|
|
1848
|
-
score:
|
|
1857
|
+
score: jitter,
|
|
1858
|
+
cardElo,
|
|
1849
1859
|
provenance: [
|
|
1850
1860
|
{
|
|
1851
1861
|
strategy: "elo",
|
|
1852
1862
|
strategyName: this.strategyName || this.name,
|
|
1853
1863
|
strategyId: this.strategyId || "NAVIGATION_STRATEGY-ELO-default",
|
|
1854
1864
|
action: "generated",
|
|
1855
|
-
score:
|
|
1856
|
-
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)}`
|
|
1857
1867
|
}
|
|
1858
1868
|
]
|
|
1859
1869
|
};
|
|
@@ -2729,43 +2739,132 @@ var init_prescribed = __esm({
|
|
|
2729
2739
|
}
|
|
2730
2740
|
});
|
|
2731
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
|
+
|
|
2732
2848
|
// src/core/navigators/generators/srs.ts
|
|
2733
2849
|
var srs_exports = {};
|
|
2734
2850
|
__export(srs_exports, {
|
|
2735
2851
|
default: () => SRSNavigator
|
|
2736
2852
|
});
|
|
2737
2853
|
import moment from "moment";
|
|
2738
|
-
var
|
|
2854
|
+
var SRSNavigator;
|
|
2739
2855
|
var init_srs = __esm({
|
|
2740
2856
|
"src/core/navigators/generators/srs.ts"() {
|
|
2741
2857
|
"use strict";
|
|
2742
2858
|
init_navigators();
|
|
2743
2859
|
init_SrsDebugger();
|
|
2860
|
+
init_regulators();
|
|
2744
2861
|
init_logger();
|
|
2745
|
-
DEFAULT_HEALTHY_BACKLOG = 20;
|
|
2746
|
-
BACKLOG_GROWTH_RATE = 2;
|
|
2747
2862
|
SRSNavigator = class extends ContentNavigator {
|
|
2748
2863
|
/** Human-readable name for CardGenerator interface */
|
|
2749
2864
|
name;
|
|
2750
|
-
/** Healthy backlog threshold - when exceeded, backlog pressure kicks in */
|
|
2751
|
-
healthyBacklog;
|
|
2752
2865
|
constructor(user, course, strategyData) {
|
|
2753
2866
|
super(user, course, strategyData);
|
|
2754
2867
|
this.name = strategyData?.name || "SRS";
|
|
2755
|
-
const config = this.parseConfig(strategyData?.serializedData);
|
|
2756
|
-
this.healthyBacklog = config.healthyBacklog ?? DEFAULT_HEALTHY_BACKLOG;
|
|
2757
|
-
}
|
|
2758
|
-
/**
|
|
2759
|
-
* Parse configuration from serialized JSON.
|
|
2760
|
-
*/
|
|
2761
|
-
parseConfig(serializedData) {
|
|
2762
|
-
if (!serializedData) return {};
|
|
2763
|
-
try {
|
|
2764
|
-
return JSON.parse(serializedData);
|
|
2765
|
-
} catch {
|
|
2766
|
-
logger.warn("[SRS] Failed to parse strategy config, using defaults");
|
|
2767
|
-
return {};
|
|
2768
|
-
}
|
|
2769
2868
|
}
|
|
2770
2869
|
/**
|
|
2771
2870
|
* Get review cards scored by urgency.
|
|
@@ -2773,7 +2872,6 @@ var init_srs = __esm({
|
|
|
2773
2872
|
* Score formula combines:
|
|
2774
2873
|
* - Relative overdueness: hoursOverdue / intervalHours
|
|
2775
2874
|
* - Interval recency: exponential decay favoring shorter intervals
|
|
2776
|
-
* - Backlog pressure: boost when due reviews exceed healthy threshold
|
|
2777
2875
|
*
|
|
2778
2876
|
* Cards not yet due are excluded (not scored as 0).
|
|
2779
2877
|
*
|
|
@@ -2810,7 +2908,6 @@ var init_srs = __esm({
|
|
|
2810
2908
|
}
|
|
2811
2909
|
}
|
|
2812
2910
|
}
|
|
2813
|
-
const backlogMultiplier = this.computeBacklogMultiplier(dueReviews.length);
|
|
2814
2911
|
const notDue = reviews.filter((r) => !now.isAfter(moment.utc(r.reviewTime)));
|
|
2815
2912
|
let nextDueIn = null;
|
|
2816
2913
|
if (notDue.length > 0) {
|
|
@@ -2821,9 +2918,8 @@ var init_srs = __esm({
|
|
|
2821
2918
|
nextDueIn = until.asHours() < 1 ? `${Math.round(until.asMinutes())}m` : until.asHours() < 24 ? `${Math.round(until.asHours())}h` : `${Math.round(until.asDays())}d`;
|
|
2822
2919
|
}
|
|
2823
2920
|
if (dueReviews.length > 0) {
|
|
2824
|
-
const pressureNote = backlogMultiplier > 1 ? ` [backlog pressure: \xD7${backlogMultiplier.toFixed(2)}]` : ` [healthy backlog]`;
|
|
2825
2921
|
logger.info(
|
|
2826
|
-
`[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)`
|
|
2827
2923
|
);
|
|
2828
2924
|
} else if (reviews.length > 0) {
|
|
2829
2925
|
const sortedByDue = [...reviews].sort(
|
|
@@ -2840,11 +2936,12 @@ var init_srs = __esm({
|
|
|
2840
2936
|
logger.info(`[SRS] Course ${courseId}: No reviews scheduled`);
|
|
2841
2937
|
}
|
|
2842
2938
|
const scored = dueReviews.map((review) => {
|
|
2843
|
-
const { score, reason } = this.computeUrgencyScore(review, now
|
|
2939
|
+
const { score, urgency, reason } = this.computeUrgencyScore(review, now);
|
|
2844
2940
|
return {
|
|
2845
2941
|
cardId: review.cardId,
|
|
2846
2942
|
courseId: review.courseId,
|
|
2847
2943
|
score,
|
|
2944
|
+
reviewUrgency: urgency,
|
|
2848
2945
|
reviewID: review._id,
|
|
2849
2946
|
provenance: [
|
|
2850
2947
|
{
|
|
@@ -2863,47 +2960,20 @@ var init_srs = __esm({
|
|
|
2863
2960
|
courseId,
|
|
2864
2961
|
scheduledTotal: reviews.length,
|
|
2865
2962
|
dueNow: dueReviews.length,
|
|
2866
|
-
healthyBacklog:
|
|
2867
|
-
|
|
2868
|
-
|
|
2963
|
+
healthyBacklog: DEFAULT_REGULATOR_CONFIG.reviewMass.healthyMass,
|
|
2964
|
+
reviewMass: null,
|
|
2965
|
+
backlogMultiplier: 1,
|
|
2966
|
+
backlogGrowthRate: DEFAULT_REGULATOR_CONFIG.reviewMass.rate,
|
|
2869
2967
|
topReviewScore: sorted.length > 0 ? sorted[0].score : null,
|
|
2870
2968
|
nextDueIn,
|
|
2871
2969
|
timestamp: Date.now()
|
|
2872
2970
|
});
|
|
2873
2971
|
return { cards: sorted.slice(0, limit) };
|
|
2874
2972
|
}
|
|
2875
|
-
/**
|
|
2876
|
-
* Compute the multiplicative backlog pressure based on number of due reviews.
|
|
2877
|
-
*
|
|
2878
|
-
* ×1.0 at or below the healthy threshold (no boost); above it, grows as
|
|
2879
|
-
* BACKLOG_GROWTH_RATE raised to the excess expressed in multiples of the
|
|
2880
|
-
* healthy threshold. Uncapped — self-regulating instead: reviews winning
|
|
2881
|
-
* slots depletes dueCount, which drops the ratio and relaxes the multiplier
|
|
2882
|
-
* next run.
|
|
2883
|
-
*
|
|
2884
|
-
* Examples (with default healthyBacklog=20, BACKLOG_GROWTH_RATE=1.5):
|
|
2885
|
-
* - 10 due reviews → ×1.00 (healthy)
|
|
2886
|
-
* - 20 due reviews → ×1.00 (at threshold, ratio 0)
|
|
2887
|
-
* - 40 due reviews → ×1.50 (ratio 1, 2x threshold)
|
|
2888
|
-
* - 60 due reviews → ×2.25 (ratio 2, 3x threshold — old hard cap was ×2.00 here)
|
|
2889
|
-
* - 100 due reviews → ×5.06 (ratio 4, 5x threshold)
|
|
2890
|
-
* - 160 due reviews → ×17.09 (ratio 7, 8x threshold)
|
|
2891
|
-
*
|
|
2892
|
-
* @param dueCount - Number of reviews currently due
|
|
2893
|
-
* @returns Multiplier applied to review urgency (>= 1.0, unbounded)
|
|
2894
|
-
*/
|
|
2895
|
-
computeBacklogMultiplier(dueCount) {
|
|
2896
|
-
if (dueCount <= this.healthyBacklog) {
|
|
2897
|
-
return 1;
|
|
2898
|
-
}
|
|
2899
|
-
const excess = dueCount - this.healthyBacklog;
|
|
2900
|
-
const ratio = excess / this.healthyBacklog;
|
|
2901
|
-
return Math.pow(BACKLOG_GROWTH_RATE, ratio);
|
|
2902
|
-
}
|
|
2903
2973
|
/**
|
|
2904
2974
|
* Compute urgency score for a review card.
|
|
2905
2975
|
*
|
|
2906
|
-
*
|
|
2976
|
+
* Two factors:
|
|
2907
2977
|
* 1. Relative overdueness = hoursOverdue / intervalHours
|
|
2908
2978
|
* - 2 days overdue on 3-day interval = 0.67 (urgent)
|
|
2909
2979
|
* - 2 days overdue on 180-day interval = 0.01 (not urgent)
|
|
@@ -2913,20 +2983,14 @@ var init_srs = __esm({
|
|
|
2913
2983
|
* - 30 days (720h) → ~0.56
|
|
2914
2984
|
* - 180 days → ~0.30
|
|
2915
2985
|
*
|
|
2916
|
-
*
|
|
2917
|
-
*
|
|
2918
|
-
*
|
|
2919
|
-
* Combined: (base 0.5 + urgency factors * 0.45) × backlog multiplier.
|
|
2920
|
-
* Per-card range before pressure: ~0.57–0.95. NOT clamped to 1.0 — under a
|
|
2921
|
-
* heavy backlog reviews scale onto the open scale to compete with (and exceed)
|
|
2922
|
-
* new cards; there's no ceiling at all now, so a bad enough backlog always
|
|
2923
|
-
* 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).
|
|
2924
2989
|
*
|
|
2925
2990
|
* @param review - The scheduled card to score
|
|
2926
2991
|
* @param now - Current time
|
|
2927
|
-
* @param backlogMultiplier - Pre-computed backlog multiplier (>= 1.0, unbounded)
|
|
2928
2992
|
*/
|
|
2929
|
-
computeUrgencyScore(review, now
|
|
2993
|
+
computeUrgencyScore(review, now) {
|
|
2930
2994
|
const scheduledAt = moment.utc(review.scheduledAt);
|
|
2931
2995
|
const due = moment.utc(review.reviewTime);
|
|
2932
2996
|
const intervalHours = Math.max(1, due.diff(scheduledAt, "hours"));
|
|
@@ -2935,20 +2999,16 @@ var init_srs = __esm({
|
|
|
2935
2999
|
const recencyFactor = 0.3 + 0.7 * Math.exp(-intervalHours / 720);
|
|
2936
3000
|
const overdueContribution = Math.min(1, Math.max(0, relativeOverdue));
|
|
2937
3001
|
const urgency = overdueContribution * 0.5 + recencyFactor * 0.5;
|
|
2938
|
-
const
|
|
2939
|
-
const score = baseScore * backlogMultiplier;
|
|
3002
|
+
const score = 0.5 + urgency * 0.45;
|
|
2940
3003
|
const reasonParts = [
|
|
2941
3004
|
`${Math.round(hoursOverdue)}h overdue`,
|
|
2942
3005
|
`interval: ${Math.round(intervalHours)}h`,
|
|
2943
3006
|
`relative: ${relativeOverdue.toFixed(2)}`,
|
|
2944
3007
|
`recency: ${recencyFactor.toFixed(2)}`
|
|
2945
3008
|
];
|
|
2946
|
-
if (backlogMultiplier > 1) {
|
|
2947
|
-
reasonParts.push(`backlog: \xD7${backlogMultiplier.toFixed(2)}`);
|
|
2948
|
-
}
|
|
2949
3009
|
reasonParts.push("review");
|
|
2950
3010
|
const reason = reasonParts.join(", ");
|
|
2951
|
-
return { score, reason };
|
|
3011
|
+
return { score, urgency, reason };
|
|
2952
3012
|
}
|
|
2953
3013
|
};
|
|
2954
3014
|
}
|
|
@@ -3003,6 +3063,8 @@ var init_WeightedFilter = __esm({
|
|
|
3003
3063
|
init_contentNavigationStrategy();
|
|
3004
3064
|
WeightedFilter = class {
|
|
3005
3065
|
name;
|
|
3066
|
+
kind;
|
|
3067
|
+
liveOnly;
|
|
3006
3068
|
inner;
|
|
3007
3069
|
learnable;
|
|
3008
3070
|
staticWeight;
|
|
@@ -3010,6 +3072,8 @@ var init_WeightedFilter = __esm({
|
|
|
3010
3072
|
constructor(inner, learnable = DEFAULT_LEARNABLE_WEIGHT, staticWeight = false, strategyId) {
|
|
3011
3073
|
this.inner = inner;
|
|
3012
3074
|
this.name = inner.name;
|
|
3075
|
+
this.kind = inner.kind;
|
|
3076
|
+
this.liveOnly = inner.liveOnly;
|
|
3013
3077
|
this.learnable = learnable;
|
|
3014
3078
|
this.staticWeight = staticWeight;
|
|
3015
3079
|
this.strategyId = strategyId;
|
|
@@ -3074,58 +3138,175 @@ var init_WeightedFilter = __esm({
|
|
|
3074
3138
|
// src/core/navigators/filters/eloDistance.ts
|
|
3075
3139
|
var eloDistance_exports = {};
|
|
3076
3140
|
__export(eloDistance_exports, {
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3141
|
+
DEFAULT_ELO_DISTANCE_CONFIG: () => DEFAULT_ELO_DISTANCE_CONFIG,
|
|
3142
|
+
createEloDistanceFilter: () => createEloDistanceFilter,
|
|
3143
|
+
default: () => EloDistanceFilter,
|
|
3144
|
+
mountMultiDimEloToggle: () => mountMultiDimEloToggle,
|
|
3145
|
+
tagAwareGap: () => tagAwareGap
|
|
3081
3146
|
});
|
|
3082
3147
|
function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
|
|
3083
3148
|
const normalizedDistance = distance / halfLife;
|
|
3084
3149
|
const decay = Math.exp(-(normalizedDistance * normalizedDistance));
|
|
3085
3150
|
return minMultiplier + (maxMultiplier - minMultiplier) * decay;
|
|
3086
3151
|
}
|
|
3152
|
+
function resolveConfig(config) {
|
|
3153
|
+
return { ...DEFAULT_ELO_DISTANCE_CONFIG, ...config };
|
|
3154
|
+
}
|
|
3155
|
+
function readMultiDimElo() {
|
|
3156
|
+
try {
|
|
3157
|
+
return typeof localStorage !== "undefined" && localStorage.getItem(MULTI_DIM_ELO_KEY) === "true";
|
|
3158
|
+
} catch {
|
|
3159
|
+
return false;
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
function mountMultiDimEloToggle() {
|
|
3163
|
+
if (typeof window === "undefined") return;
|
|
3164
|
+
const win = window;
|
|
3165
|
+
win.skuilder = win.skuilder || {};
|
|
3166
|
+
Object.defineProperty(win.skuilder, "multiDimElo", {
|
|
3167
|
+
configurable: true,
|
|
3168
|
+
enumerable: true,
|
|
3169
|
+
get: () => multiDimElo,
|
|
3170
|
+
set: (on) => {
|
|
3171
|
+
multiDimElo = on === true;
|
|
3172
|
+
try {
|
|
3173
|
+
if (multiDimElo) localStorage.setItem(MULTI_DIM_ELO_KEY, "true");
|
|
3174
|
+
else localStorage.removeItem(MULTI_DIM_ELO_KEY);
|
|
3175
|
+
} catch (e) {
|
|
3176
|
+
logger.warn(`[EloDistance] multiDimElo not persisted (localStorage unavailable): ${e}`);
|
|
3177
|
+
}
|
|
3178
|
+
logger.info(
|
|
3179
|
+
`[EloDistance] multiDimElo ${multiDimElo ? "on: tag-aware" : "off: per strategy config"} ELO distance from the next replan`
|
|
3180
|
+
);
|
|
3181
|
+
}
|
|
3182
|
+
});
|
|
3183
|
+
}
|
|
3184
|
+
function tagAwareGap(cardTags, cardElo, userElo, minTagCount) {
|
|
3185
|
+
const globalGap = cardElo.global.score - userElo.global.score;
|
|
3186
|
+
const tags = [];
|
|
3187
|
+
for (const tag of cardTags) {
|
|
3188
|
+
const user = userElo.tags[tag];
|
|
3189
|
+
if (!user || user.score === COUNT_ONLY_SENTINEL || user.count < minTagCount) continue;
|
|
3190
|
+
const card = cardElo.tags[tag]?.score ?? cardElo.global.score;
|
|
3191
|
+
tags.push({
|
|
3192
|
+
tag,
|
|
3193
|
+
gap: card - user.score,
|
|
3194
|
+
weight: user.count / (user.count + TAG_CONFIDENCE_HALF)
|
|
3195
|
+
});
|
|
3196
|
+
}
|
|
3197
|
+
if (tags.length === 0) return { gap: globalGap, globalGap, tags };
|
|
3198
|
+
const total = tags.reduce((w, t) => w + t.weight, 0);
|
|
3199
|
+
const tagGap = tags.reduce((g, t) => g + t.weight * t.gap, 0) / total;
|
|
3200
|
+
const lambda = total / (total + 1);
|
|
3201
|
+
return { gap: lambda * tagGap + (1 - lambda) * globalGap, globalGap, tags };
|
|
3202
|
+
}
|
|
3203
|
+
function tagReason(tags, globalGap) {
|
|
3204
|
+
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(", ");
|
|
3205
|
+
const more = tags.length > 3 ? `, +${tags.length - 3} more` : "";
|
|
3206
|
+
return ` on ${tags.length} shared tag(s) [${shown}${more}] (global ${globalGap >= 0 ? "+" : ""}${Math.round(globalGap)})`;
|
|
3207
|
+
}
|
|
3208
|
+
async function applyEloDistance(cards, context, config, source) {
|
|
3209
|
+
const { course, userElo, userCourseElo } = context;
|
|
3210
|
+
const { halfLife, minMultiplier, maxMultiplier } = config;
|
|
3211
|
+
const tagAware = (config.tagAware || multiDimElo) && userCourseElo !== void 0;
|
|
3212
|
+
const missing = cards.filter((c) => tagAware || c.cardElo === void 0).map((c) => c.cardId);
|
|
3213
|
+
const fetched = /* @__PURE__ */ new Map();
|
|
3214
|
+
if (missing.length > 0) {
|
|
3215
|
+
const elos = await course.getCardEloData(missing);
|
|
3216
|
+
missing.forEach((id, i) => {
|
|
3217
|
+
if (elos[i]) fetched.set(id, elos[i]);
|
|
3218
|
+
});
|
|
3219
|
+
}
|
|
3220
|
+
return cards.map((card) => {
|
|
3221
|
+
const full = fetched.get(card.cardId);
|
|
3222
|
+
const cardElo = full?.global?.score ?? card.cardElo ?? DEFAULT_CARD_ELO;
|
|
3223
|
+
let distance = Math.abs(cardElo - userElo);
|
|
3224
|
+
let how = "";
|
|
3225
|
+
if (tagAware) {
|
|
3226
|
+
const t = full ? tagAwareGap(card.tags ?? [], full, userCourseElo, config.minTagCount) : void 0;
|
|
3227
|
+
if (t) distance = Math.abs(t.gap);
|
|
3228
|
+
how = t?.tags.length ? `, tag-aware${tagReason(t.tags, t.globalGap)}` : ", tag-aware: global (no shared tags)";
|
|
3229
|
+
}
|
|
3230
|
+
const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
|
|
3231
|
+
const newScore = card.score * multiplier;
|
|
3232
|
+
const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
|
|
3233
|
+
return {
|
|
3234
|
+
...card,
|
|
3235
|
+
cardElo,
|
|
3236
|
+
score: newScore,
|
|
3237
|
+
provenance: [
|
|
3238
|
+
...card.provenance,
|
|
3239
|
+
{
|
|
3240
|
+
strategy: "eloDistance",
|
|
3241
|
+
strategyName: source.name,
|
|
3242
|
+
strategyId: source.strategyId,
|
|
3243
|
+
action,
|
|
3244
|
+
score: newScore,
|
|
3245
|
+
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)})${how} \u2192 ${multiplier.toFixed(2)}x`
|
|
3246
|
+
}
|
|
3247
|
+
]
|
|
3248
|
+
};
|
|
3249
|
+
});
|
|
3250
|
+
}
|
|
3087
3251
|
function createEloDistanceFilter(config) {
|
|
3088
|
-
const
|
|
3089
|
-
const
|
|
3090
|
-
const maxMultiplier = config?.maxMultiplier ?? DEFAULT_MAX_MULTIPLIER;
|
|
3252
|
+
const resolved = resolveConfig(config);
|
|
3253
|
+
const source = { name: "ELO Distance Filter", strategyId: "ELO_DISTANCE_FILTER" };
|
|
3091
3254
|
return {
|
|
3092
|
-
name:
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
const cardElos = await course.getCardEloData(cardIds);
|
|
3097
|
-
return cards.map((card, i) => {
|
|
3098
|
-
const cardElo = cardElos[i]?.global?.score ?? 1e3;
|
|
3099
|
-
const distance = Math.abs(cardElo - userElo);
|
|
3100
|
-
const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
|
|
3101
|
-
const newScore = card.score * multiplier;
|
|
3102
|
-
const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
|
|
3103
|
-
return {
|
|
3104
|
-
...card,
|
|
3105
|
-
score: newScore,
|
|
3106
|
-
provenance: [
|
|
3107
|
-
...card.provenance,
|
|
3108
|
-
{
|
|
3109
|
-
strategy: "eloDistance",
|
|
3110
|
-
strategyName: "ELO Distance Filter",
|
|
3111
|
-
strategyId: "ELO_DISTANCE_FILTER",
|
|
3112
|
-
action,
|
|
3113
|
-
score: newScore,
|
|
3114
|
-
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)}) \u2192 ${multiplier.toFixed(2)}x`
|
|
3115
|
-
}
|
|
3116
|
-
]
|
|
3117
|
-
};
|
|
3118
|
-
});
|
|
3119
|
-
}
|
|
3255
|
+
name: source.name,
|
|
3256
|
+
kind: "signal",
|
|
3257
|
+
liveOnly: true,
|
|
3258
|
+
transform: (cards, context) => applyEloDistance(cards, context, resolved, source)
|
|
3120
3259
|
};
|
|
3121
3260
|
}
|
|
3122
|
-
var
|
|
3261
|
+
var DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, COUNT_ONLY_SENTINEL, DEFAULT_CARD_ELO, MULTI_DIM_ELO_KEY, multiDimElo, EloDistanceFilter;
|
|
3123
3262
|
var init_eloDistance = __esm({
|
|
3124
3263
|
"src/core/navigators/filters/eloDistance.ts"() {
|
|
3125
3264
|
"use strict";
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3265
|
+
init_navigators();
|
|
3266
|
+
init_logger();
|
|
3267
|
+
DEFAULT_ELO_DISTANCE_CONFIG = {
|
|
3268
|
+
halfLife: 300,
|
|
3269
|
+
minMultiplier: 0.05,
|
|
3270
|
+
maxMultiplier: 1,
|
|
3271
|
+
tagAware: false,
|
|
3272
|
+
minTagCount: 3
|
|
3273
|
+
};
|
|
3274
|
+
TAG_CONFIDENCE_HALF = 10;
|
|
3275
|
+
COUNT_ONLY_SENTINEL = -1;
|
|
3276
|
+
DEFAULT_CARD_ELO = 1e3;
|
|
3277
|
+
MULTI_DIM_ELO_KEY = "skuilder:multiDimElo";
|
|
3278
|
+
multiDimElo = readMultiDimElo();
|
|
3279
|
+
mountMultiDimEloToggle();
|
|
3280
|
+
EloDistanceFilter = class _EloDistanceFilter extends ContentNavigator {
|
|
3281
|
+
name;
|
|
3282
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3283
|
+
static kind = "signal";
|
|
3284
|
+
kind = _EloDistanceFilter.kind;
|
|
3285
|
+
liveOnly = true;
|
|
3286
|
+
config;
|
|
3287
|
+
constructor(user, course, strategyData) {
|
|
3288
|
+
super(user, course, strategyData);
|
|
3289
|
+
this.name = strategyData.name || "ELO Distance";
|
|
3290
|
+
let parsed;
|
|
3291
|
+
try {
|
|
3292
|
+
parsed = strategyData.serializedData ? JSON.parse(strategyData.serializedData) : void 0;
|
|
3293
|
+
} catch {
|
|
3294
|
+
parsed = void 0;
|
|
3295
|
+
}
|
|
3296
|
+
this.config = resolveConfig(parsed);
|
|
3297
|
+
}
|
|
3298
|
+
transform(cards, context) {
|
|
3299
|
+
return applyEloDistance(cards, context, this.config, {
|
|
3300
|
+
name: this.name,
|
|
3301
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-eloDistance-default"
|
|
3302
|
+
});
|
|
3303
|
+
}
|
|
3304
|
+
async getWeightedCards(_limit) {
|
|
3305
|
+
throw new Error(
|
|
3306
|
+
"EloDistanceFilter is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
|
|
3307
|
+
);
|
|
3308
|
+
}
|
|
3309
|
+
};
|
|
3129
3310
|
}
|
|
3130
3311
|
});
|
|
3131
3312
|
|
|
@@ -3142,10 +3323,13 @@ var init_hierarchyDefinition = __esm({
|
|
|
3142
3323
|
init_navigators();
|
|
3143
3324
|
init_logger();
|
|
3144
3325
|
DEFAULT_MIN_COUNT2 = 3;
|
|
3145
|
-
HierarchyDefinitionNavigator = class extends ContentNavigator {
|
|
3326
|
+
HierarchyDefinitionNavigator = class _HierarchyDefinitionNavigator extends ContentNavigator {
|
|
3146
3327
|
config;
|
|
3147
3328
|
/** Human-readable name for CardFilter interface */
|
|
3148
3329
|
name;
|
|
3330
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3331
|
+
static kind = "gate";
|
|
3332
|
+
kind = _HierarchyDefinitionNavigator.kind;
|
|
3149
3333
|
constructor(user, course, strategyData) {
|
|
3150
3334
|
super(user, course, strategyData);
|
|
3151
3335
|
this.config = this.parseConfig(strategyData.serializedData);
|
|
@@ -3412,10 +3596,13 @@ var init_userTagPreference = __esm({
|
|
|
3412
3596
|
"src/core/navigators/filters/userTagPreference.ts"() {
|
|
3413
3597
|
"use strict";
|
|
3414
3598
|
init_navigators();
|
|
3415
|
-
UserTagPreferenceFilter = class extends ContentNavigator {
|
|
3599
|
+
UserTagPreferenceFilter = class _UserTagPreferenceFilter extends ContentNavigator {
|
|
3416
3600
|
_strategyData;
|
|
3417
3601
|
/** Human-readable name for CardFilter interface */
|
|
3418
3602
|
name;
|
|
3603
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3604
|
+
static kind = "signal";
|
|
3605
|
+
kind = _UserTagPreferenceFilter.kind;
|
|
3419
3606
|
constructor(user, course, strategyData) {
|
|
3420
3607
|
super(user, course, strategyData);
|
|
3421
3608
|
this._strategyData = strategyData;
|
|
@@ -3525,6 +3712,7 @@ var init_userTagPreference = __esm({
|
|
|
3525
3712
|
// src/core/navigators/filters/index.ts
|
|
3526
3713
|
var filters_exports = {};
|
|
3527
3714
|
__export(filters_exports, {
|
|
3715
|
+
EloDistanceFilter: () => EloDistanceFilter,
|
|
3528
3716
|
UserTagPreferenceFilter: () => UserTagPreferenceFilter,
|
|
3529
3717
|
createEloDistanceFilter: () => createEloDistanceFilter
|
|
3530
3718
|
});
|
|
@@ -3563,10 +3751,13 @@ var init_interferenceMitigator = __esm({
|
|
|
3563
3751
|
DEFAULT_MIN_COUNT3 = 10;
|
|
3564
3752
|
DEFAULT_MIN_ELAPSED_DAYS = 3;
|
|
3565
3753
|
DEFAULT_INTERFERENCE_DECAY = 0.8;
|
|
3566
|
-
InterferenceMitigatorNavigator = class extends ContentNavigator {
|
|
3754
|
+
InterferenceMitigatorNavigator = class _InterferenceMitigatorNavigator extends ContentNavigator {
|
|
3567
3755
|
config;
|
|
3568
3756
|
/** Human-readable name for CardFilter interface */
|
|
3569
3757
|
name;
|
|
3758
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3759
|
+
static kind = "signal";
|
|
3760
|
+
kind = _InterferenceMitigatorNavigator.kind;
|
|
3570
3761
|
/** Precomputed map: tag -> set of { partner, decay } it interferes with */
|
|
3571
3762
|
interferenceMap;
|
|
3572
3763
|
constructor(user, course, strategyData) {
|
|
@@ -3782,10 +3973,13 @@ var init_relativePriority = __esm({
|
|
|
3782
3973
|
DEFAULT_PRIORITY = 0.5;
|
|
3783
3974
|
DEFAULT_PRIORITY_INFLUENCE = 0.5;
|
|
3784
3975
|
DEFAULT_COMBINE_MODE = "max";
|
|
3785
|
-
RelativePriorityNavigator = class extends ContentNavigator {
|
|
3976
|
+
RelativePriorityNavigator = class _RelativePriorityNavigator extends ContentNavigator {
|
|
3786
3977
|
config;
|
|
3787
3978
|
/** Human-readable name for CardFilter interface */
|
|
3788
3979
|
name;
|
|
3980
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3981
|
+
static kind = "signal";
|
|
3982
|
+
kind = _RelativePriorityNavigator.kind;
|
|
3789
3983
|
constructor(user, course, strategyData) {
|
|
3790
3984
|
super(user, course, strategyData);
|
|
3791
3985
|
this.config = this.parseConfig(strategyData.serializedData);
|
|
@@ -4439,6 +4633,8 @@ var init_Pipeline = __esm({
|
|
|
4439
4633
|
init_orchestration();
|
|
4440
4634
|
init_PipelineDebugger();
|
|
4441
4635
|
init_diversityRerank();
|
|
4636
|
+
init_regulators();
|
|
4637
|
+
init_SrsDebugger();
|
|
4442
4638
|
VERBOSE_RESULTS = true;
|
|
4443
4639
|
Pipeline = class extends ContentNavigator {
|
|
4444
4640
|
generator;
|
|
@@ -4464,6 +4660,13 @@ var init_Pipeline = __esm({
|
|
|
4464
4660
|
* getWeightedCards() call, then cleared.
|
|
4465
4661
|
*/
|
|
4466
4662
|
_ephemeralHints = null;
|
|
4663
|
+
/**
|
|
4664
|
+
* The intake valve's clock (see regulators.ts), loaded from strategy state on
|
|
4665
|
+
* first use and kept in memory. Writes are chained so a presentation and a
|
|
4666
|
+
* run can't race each other's revision.
|
|
4667
|
+
*/
|
|
4668
|
+
_intakeClock = null;
|
|
4669
|
+
_intakeClockWrite = Promise.resolve();
|
|
4467
4670
|
/**
|
|
4468
4671
|
* Create a new pipeline.
|
|
4469
4672
|
*
|
|
@@ -4538,13 +4741,12 @@ var init_Pipeline = __esm({
|
|
|
4538
4741
|
}
|
|
4539
4742
|
}
|
|
4540
4743
|
generatorSummaries = Array.from(genMap.entries()).map(([name, data]) => {
|
|
4541
|
-
const
|
|
4542
|
-
const reviewCards = data.cards.filter((c) => c.provenance[0]?.reason?.includes("review"));
|
|
4744
|
+
const reviewCount = data.cards.filter((c) => c.reviewID).length;
|
|
4543
4745
|
return {
|
|
4544
4746
|
name,
|
|
4545
4747
|
cardCount: data.cards.length,
|
|
4546
|
-
newCount:
|
|
4547
|
-
reviewCount
|
|
4748
|
+
newCount: data.cards.length - reviewCount,
|
|
4749
|
+
reviewCount,
|
|
4548
4750
|
topScore: Math.max(...data.cards.map((c) => c.score), 0)
|
|
4549
4751
|
};
|
|
4550
4752
|
});
|
|
@@ -4580,19 +4782,24 @@ var init_Pipeline = __esm({
|
|
|
4580
4782
|
cards.filter((c) => c.provenance.some((p) => p.strategy === "prescribed")).map((c) => c.cardId)
|
|
4581
4783
|
);
|
|
4582
4784
|
const filterImpacts = [];
|
|
4785
|
+
const generatedScores = new Map(cards.map((c) => [c.cardId, c.score]));
|
|
4786
|
+
const gated = /* @__PURE__ */ new Set();
|
|
4583
4787
|
for (const filter of this.filters) {
|
|
4584
4788
|
const beforeCount = cards.length;
|
|
4585
4789
|
const beforeScores = new Map(cards.map((c) => [c.cardId, c.score]));
|
|
4586
4790
|
cards = await filter.transform(cards, context);
|
|
4587
4791
|
let boosted = 0, penalized = 0, passed = 0;
|
|
4588
4792
|
const removed = beforeCount - cards.length;
|
|
4793
|
+
const kind = filter.kind ?? "gate";
|
|
4589
4794
|
for (const card of cards) {
|
|
4590
4795
|
const before = beforeScores.get(card.cardId) ?? 0;
|
|
4591
4796
|
if (card.score > before) boosted++;
|
|
4592
|
-
else if (card.score < before)
|
|
4593
|
-
|
|
4797
|
+
else if (card.score < before) {
|
|
4798
|
+
penalized++;
|
|
4799
|
+
if (kind === "gate") gated.add(card.cardId);
|
|
4800
|
+
} else passed++;
|
|
4594
4801
|
}
|
|
4595
|
-
filterImpacts.push({ name: filter.name, boosted, penalized, passed, removed });
|
|
4802
|
+
filterImpacts.push({ name: filter.name, kind, boosted, penalized, passed, removed });
|
|
4596
4803
|
if (prescribedIds.size > 0) {
|
|
4597
4804
|
const survivingIds = new Set(cards.map((c) => c.cardId));
|
|
4598
4805
|
const killedPrescribed = [...prescribedIds].filter((id) => !survivingIds.has(id));
|
|
@@ -4608,6 +4815,7 @@ var init_Pipeline = __esm({
|
|
|
4608
4815
|
}
|
|
4609
4816
|
const scoredCards = cards;
|
|
4610
4817
|
cards = cards.filter((c) => c.score > 0);
|
|
4818
|
+
const regulators = await this.regulate(cards, generatedScores, gated);
|
|
4611
4819
|
const hints = this._ephemeralHints;
|
|
4612
4820
|
if (hints) {
|
|
4613
4821
|
this._ephemeralHints = null;
|
|
@@ -4644,7 +4852,8 @@ var init_Pipeline = __esm({
|
|
|
4644
4852
|
result,
|
|
4645
4853
|
context.userElo,
|
|
4646
4854
|
hints ?? void 0,
|
|
4647
|
-
scoredCards
|
|
4855
|
+
scoredCards,
|
|
4856
|
+
regulators
|
|
4648
4857
|
);
|
|
4649
4858
|
captureRun(report);
|
|
4650
4859
|
} catch (e) {
|
|
@@ -4823,6 +5032,77 @@ var init_Pipeline = __esm({
|
|
|
4823
5032
|
logger.info(`[Pipeline] Hints applied: ${beforeCount} \u2192 ${cards.length} cards`);
|
|
4824
5033
|
return cards;
|
|
4825
5034
|
}
|
|
5035
|
+
/**
|
|
5036
|
+
* The regulator stage: measure each class's pressure and scale it.
|
|
5037
|
+
*
|
|
5038
|
+
* - Review mass: every due review's SRS urgency times the filters' net
|
|
5039
|
+
* effect on it.
|
|
5040
|
+
* - Intake: servable hours since a new card was presented, applied only to
|
|
5041
|
+
* eligible new cards (no gate penalized them). With none eligible, the
|
|
5042
|
+
* clock freezes.
|
|
5043
|
+
*
|
|
5044
|
+
* Mutates `cards` in place; returns the readings for the run report.
|
|
5045
|
+
*/
|
|
5046
|
+
async regulate(cards, generatedScores, gated) {
|
|
5047
|
+
const config = DEFAULT_REGULATOR_CONFIG;
|
|
5048
|
+
const reviews = cards.filter((c) => c.reviewID);
|
|
5049
|
+
const newCards = cards.filter((c) => !c.reviewID);
|
|
5050
|
+
const eligibleNew = newCards.filter((c) => !gated.has(c.cardId));
|
|
5051
|
+
const mass = reviewMassReading(reviews, generatedScores, config.reviewMass);
|
|
5052
|
+
applyReading(reviews, mass);
|
|
5053
|
+
noteReviewPressure(this.course.getCourseID(), {
|
|
5054
|
+
mass: mass.urgency,
|
|
5055
|
+
healthyMass: config.reviewMass.healthyMass,
|
|
5056
|
+
rate: config.reviewMass.rate,
|
|
5057
|
+
multiplier: mass.multiplier
|
|
5058
|
+
});
|
|
5059
|
+
const now = Date.now();
|
|
5060
|
+
const clock = await this.loadIntakeClock(now);
|
|
5061
|
+
const stepped = stepIntakeClock(clock, now, eligibleNew.length);
|
|
5062
|
+
if (stepped !== clock) this.saveIntakeClock(stepped);
|
|
5063
|
+
const intake = intakeReading(
|
|
5064
|
+
stepped,
|
|
5065
|
+
now,
|
|
5066
|
+
{ eligibleNew: eligibleNew.length, newCandidates: newCards.length },
|
|
5067
|
+
config.intake
|
|
5068
|
+
);
|
|
5069
|
+
applyReading(eligibleNew, intake);
|
|
5070
|
+
logger.info(
|
|
5071
|
+
`[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)}`
|
|
5072
|
+
);
|
|
5073
|
+
return [mass, intake];
|
|
5074
|
+
}
|
|
5075
|
+
/**
|
|
5076
|
+
* A card was presented. A new card's first presentation discharges the
|
|
5077
|
+
* intake valve: its clock restarts. Called by the SessionController.
|
|
5078
|
+
*/
|
|
5079
|
+
notePresented(card) {
|
|
5080
|
+
if (card.status !== "new" || card.courseId !== this.course?.getCourseID()) return;
|
|
5081
|
+
this.saveIntakeClock(resetIntakeClock(Date.now()));
|
|
5082
|
+
}
|
|
5083
|
+
async loadIntakeClock(nowMs) {
|
|
5084
|
+
if (this._intakeClock) return this._intakeClock;
|
|
5085
|
+
let stored = null;
|
|
5086
|
+
try {
|
|
5087
|
+
stored = await this.user.getStrategyState(
|
|
5088
|
+
this.course.getCourseID(),
|
|
5089
|
+
INTAKE_CLOCK_KEY
|
|
5090
|
+
);
|
|
5091
|
+
} catch (e) {
|
|
5092
|
+
logger.warn(`[Pipeline:regulators] Could not read the intake clock: ${e}`);
|
|
5093
|
+
}
|
|
5094
|
+
if (stored) {
|
|
5095
|
+
this._intakeClock = stored;
|
|
5096
|
+
} else {
|
|
5097
|
+
this.saveIntakeClock(resetIntakeClock(nowMs));
|
|
5098
|
+
}
|
|
5099
|
+
return this._intakeClock;
|
|
5100
|
+
}
|
|
5101
|
+
saveIntakeClock(state) {
|
|
5102
|
+
this._intakeClock = state;
|
|
5103
|
+
const courseId = this.course.getCourseID();
|
|
5104
|
+
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}`));
|
|
5105
|
+
}
|
|
4826
5106
|
/**
|
|
4827
5107
|
* Build shared context for generator and filters.
|
|
4828
5108
|
*
|
|
@@ -4833,10 +5113,11 @@ var init_Pipeline = __esm({
|
|
|
4833
5113
|
*/
|
|
4834
5114
|
async buildContext() {
|
|
4835
5115
|
let userElo = 1e3;
|
|
5116
|
+
let userCourseElo;
|
|
4836
5117
|
try {
|
|
4837
5118
|
const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
|
|
4838
|
-
|
|
4839
|
-
userElo =
|
|
5119
|
+
userCourseElo = toCourseElo5(courseReg.elo);
|
|
5120
|
+
userElo = userCourseElo.global.score;
|
|
4840
5121
|
} catch (e) {
|
|
4841
5122
|
logger.debug(`[Pipeline] Could not get user ELO, using default: ${e}`);
|
|
4842
5123
|
}
|
|
@@ -4848,6 +5129,7 @@ var init_Pipeline = __esm({
|
|
|
4848
5129
|
user: this.user,
|
|
4849
5130
|
course: this.course,
|
|
4850
5131
|
userElo,
|
|
5132
|
+
...userCourseElo ? { userCourseElo } : {},
|
|
4851
5133
|
orchestration
|
|
4852
5134
|
};
|
|
4853
5135
|
}
|
|
@@ -4961,7 +5243,7 @@ var init_Pipeline = __esm({
|
|
|
4961
5243
|
cards = await this.hydrateTags(cards);
|
|
4962
5244
|
const fullPool = cards.slice();
|
|
4963
5245
|
const context = await this.buildContext();
|
|
4964
|
-
for (const filter of this.
|
|
5246
|
+
for (const filter of this.forecastFilters()) {
|
|
4965
5247
|
cards = await filter.transform(cards, context);
|
|
4966
5248
|
}
|
|
4967
5249
|
if (opts?.hints) {
|
|
@@ -4980,6 +5262,14 @@ var init_Pipeline = __esm({
|
|
|
4980
5262
|
cards.sort((a, b) => b.score - a.score);
|
|
4981
5263
|
return opts?.limit ? cards.slice(0, opts.limit) : cards;
|
|
4982
5264
|
}
|
|
5265
|
+
/**
|
|
5266
|
+
* The filters a forecast or card-space scan applies. Those start every card at
|
|
5267
|
+
* 1.0 without a generator, so they skip `liveOnly` filters (ELO distance),
|
|
5268
|
+
* which only make sense against generator scores.
|
|
5269
|
+
*/
|
|
5270
|
+
forecastFilters() {
|
|
5271
|
+
return this.filters.filter((f) => !f.liveOnly);
|
|
5272
|
+
}
|
|
4983
5273
|
/**
|
|
4984
5274
|
* Scan every card in the course through the filter chain and report
|
|
4985
5275
|
* how many are "well indicated" (score >= threshold) for the current user.
|
|
@@ -5001,7 +5291,7 @@ var init_Pipeline = __esm({
|
|
|
5001
5291
|
cards = await this.hydrateTags(cards);
|
|
5002
5292
|
const context = await this.buildContext();
|
|
5003
5293
|
const filterBreakdown = [];
|
|
5004
|
-
for (const filter of this.
|
|
5294
|
+
for (const filter of this.forecastFilters()) {
|
|
5005
5295
|
cards = await filter.transform(cards, context);
|
|
5006
5296
|
const wi = cards.filter((c) => c.score >= THRESHOLD).length;
|
|
5007
5297
|
filterBreakdown.push({ name: filter.name, wellIndicated: wi });
|
|
@@ -5065,6 +5355,7 @@ var init_Pipeline = __esm({
|
|
|
5065
5355
|
// src/core/navigators/defaults.ts
|
|
5066
5356
|
var defaults_exports = {};
|
|
5067
5357
|
__export(defaults_exports, {
|
|
5358
|
+
createDefaultEloDistanceStrategy: () => createDefaultEloDistanceStrategy,
|
|
5068
5359
|
createDefaultEloStrategy: () => createDefaultEloStrategy,
|
|
5069
5360
|
createDefaultPipeline: () => createDefaultPipeline,
|
|
5070
5361
|
createDefaultSrsStrategy: () => createDefaultSrsStrategy
|
|
@@ -5091,12 +5382,28 @@ function createDefaultSrsStrategy(courseId) {
|
|
|
5091
5382
|
serializedData: ""
|
|
5092
5383
|
};
|
|
5093
5384
|
}
|
|
5385
|
+
function createDefaultEloDistanceStrategy(courseId) {
|
|
5386
|
+
return {
|
|
5387
|
+
_id: "NAVIGATION_STRATEGY-eloDistance-default",
|
|
5388
|
+
docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
|
|
5389
|
+
name: "ELO Distance (default)",
|
|
5390
|
+
description: "Scales every candidate, new or review, by its distance from the learner's ELO",
|
|
5391
|
+
implementingClass: "eloDistance" /* ELO_DISTANCE */,
|
|
5392
|
+
course: courseId,
|
|
5393
|
+
// Explicit, though the filter would default to it anyway: views show what runs.
|
|
5394
|
+
serializedData: JSON.stringify(DEFAULT_ELO_DISTANCE_CONFIG)
|
|
5395
|
+
};
|
|
5396
|
+
}
|
|
5094
5397
|
function createDefaultPipeline(user, course) {
|
|
5095
5398
|
const courseId = course.getCourseID();
|
|
5096
5399
|
const eloNavigator = new ELONavigator(user, course, createDefaultEloStrategy(courseId));
|
|
5097
5400
|
const srsNavigator = new SRSNavigator(user, course, createDefaultSrsStrategy(courseId));
|
|
5098
5401
|
const compositeGenerator = new CompositeGenerator([eloNavigator, srsNavigator]);
|
|
5099
|
-
const eloDistanceFilter =
|
|
5402
|
+
const eloDistanceFilter = new EloDistanceFilter(
|
|
5403
|
+
user,
|
|
5404
|
+
course,
|
|
5405
|
+
createDefaultEloDistanceStrategy(courseId)
|
|
5406
|
+
);
|
|
5100
5407
|
return new Pipeline(compositeGenerator, [eloDistanceFilter], user, course);
|
|
5101
5408
|
}
|
|
5102
5409
|
var init_defaults = __esm({
|
|
@@ -5112,6 +5419,131 @@ var init_defaults = __esm({
|
|
|
5112
5419
|
}
|
|
5113
5420
|
});
|
|
5114
5421
|
|
|
5422
|
+
// src/core/navigators/pipelinePlan.ts
|
|
5423
|
+
var pipelinePlan_exports = {};
|
|
5424
|
+
__export(pipelinePlan_exports, {
|
|
5425
|
+
PIPELINE_STAGES: () => PIPELINE_STAGES,
|
|
5426
|
+
planPipeline: () => planPipeline
|
|
5427
|
+
});
|
|
5428
|
+
function planned(strategy, role, origin) {
|
|
5429
|
+
const kind = role === "filter" /* FILTER */ ? getRegisteredFilterKind(strategy.implementingClass) : void 0;
|
|
5430
|
+
return {
|
|
5431
|
+
role,
|
|
5432
|
+
origin,
|
|
5433
|
+
name: strategy.name,
|
|
5434
|
+
implementingClass: strategy.implementingClass,
|
|
5435
|
+
strategy,
|
|
5436
|
+
...kind ? { kind } : {}
|
|
5437
|
+
};
|
|
5438
|
+
}
|
|
5439
|
+
function planPipeline(strategies, courseId) {
|
|
5440
|
+
if (strategies.length === 0) {
|
|
5441
|
+
return {
|
|
5442
|
+
kind: "default",
|
|
5443
|
+
generators: [
|
|
5444
|
+
planned(createDefaultEloStrategy(courseId), "generator" /* GENERATOR */, "default-pipeline"),
|
|
5445
|
+
planned(createDefaultSrsStrategy(courseId), "generator" /* GENERATOR */, "default-pipeline")
|
|
5446
|
+
],
|
|
5447
|
+
filters: [
|
|
5448
|
+
planned(
|
|
5449
|
+
createDefaultEloDistanceStrategy(courseId),
|
|
5450
|
+
"filter" /* FILTER */,
|
|
5451
|
+
"default-pipeline"
|
|
5452
|
+
)
|
|
5453
|
+
],
|
|
5454
|
+
skipped: [],
|
|
5455
|
+
warnings: [],
|
|
5456
|
+
notes: [],
|
|
5457
|
+
regulators: DEFAULT_REGULATOR_CONFIG
|
|
5458
|
+
};
|
|
5459
|
+
}
|
|
5460
|
+
const generators = [];
|
|
5461
|
+
const filters = [];
|
|
5462
|
+
const skipped = [];
|
|
5463
|
+
const warnings = [];
|
|
5464
|
+
for (const s of strategies) {
|
|
5465
|
+
if (isGenerator(s.implementingClass)) {
|
|
5466
|
+
generators.push(planned(s, "generator" /* GENERATOR */, "strategy-doc"));
|
|
5467
|
+
} else if (isFilter(s.implementingClass)) {
|
|
5468
|
+
filters.push(planned(s, "filter" /* FILTER */, "strategy-doc"));
|
|
5469
|
+
} else {
|
|
5470
|
+
skipped.push({ strategy: s, reason: "not a registered generator or filter" });
|
|
5471
|
+
warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
|
|
5472
|
+
}
|
|
5473
|
+
}
|
|
5474
|
+
const declared = new Set(generators.map((g) => g.implementingClass));
|
|
5475
|
+
if (!declared.has(createDefaultEloStrategy(courseId).implementingClass)) {
|
|
5476
|
+
generators.push(
|
|
5477
|
+
planned(createDefaultEloStrategy(courseId), "generator" /* GENERATOR */, "assembler-default")
|
|
5478
|
+
);
|
|
5479
|
+
}
|
|
5480
|
+
if (!declared.has(createDefaultSrsStrategy(courseId).implementingClass)) {
|
|
5481
|
+
generators.push(
|
|
5482
|
+
planned(createDefaultSrsStrategy(courseId), "generator" /* GENERATOR */, "assembler-default")
|
|
5483
|
+
);
|
|
5484
|
+
}
|
|
5485
|
+
const eloDistance = createDefaultEloDistanceStrategy(courseId);
|
|
5486
|
+
if (!filters.some((f) => f.implementingClass === eloDistance.implementingClass)) {
|
|
5487
|
+
filters.push(planned(eloDistance, "filter" /* FILTER */, "assembler-default"));
|
|
5488
|
+
}
|
|
5489
|
+
filters.sort((a, b) => a.name.localeCompare(b.name));
|
|
5490
|
+
return {
|
|
5491
|
+
kind: "assembled",
|
|
5492
|
+
generators,
|
|
5493
|
+
filters,
|
|
5494
|
+
skipped,
|
|
5495
|
+
warnings,
|
|
5496
|
+
notes: [],
|
|
5497
|
+
regulators: DEFAULT_REGULATOR_CONFIG
|
|
5498
|
+
};
|
|
5499
|
+
}
|
|
5500
|
+
var PIPELINE_STAGES;
|
|
5501
|
+
var init_pipelinePlan = __esm({
|
|
5502
|
+
"src/core/navigators/pipelinePlan.ts"() {
|
|
5503
|
+
"use strict";
|
|
5504
|
+
init_navigators();
|
|
5505
|
+
init_regulators();
|
|
5506
|
+
init_defaults();
|
|
5507
|
+
PIPELINE_STAGES = [
|
|
5508
|
+
{
|
|
5509
|
+
key: "generate",
|
|
5510
|
+
title: "Generate",
|
|
5511
|
+
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."
|
|
5512
|
+
},
|
|
5513
|
+
{
|
|
5514
|
+
key: "filter",
|
|
5515
|
+
title: "Filter",
|
|
5516
|
+
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."
|
|
5517
|
+
},
|
|
5518
|
+
{
|
|
5519
|
+
key: "drop-zero",
|
|
5520
|
+
title: "Drop zero scores",
|
|
5521
|
+
summary: "Candidates whose score reached 0 leave the pool."
|
|
5522
|
+
},
|
|
5523
|
+
{
|
|
5524
|
+
key: "regulate",
|
|
5525
|
+
title: "Regulate",
|
|
5526
|
+
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."
|
|
5527
|
+
},
|
|
5528
|
+
{
|
|
5529
|
+
key: "hints",
|
|
5530
|
+
title: "Apply hints",
|
|
5531
|
+
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."
|
|
5532
|
+
},
|
|
5533
|
+
{
|
|
5534
|
+
key: "diversity",
|
|
5535
|
+
title: "Diversity re-rank",
|
|
5536
|
+
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."
|
|
5537
|
+
},
|
|
5538
|
+
{
|
|
5539
|
+
key: "select",
|
|
5540
|
+
title: "Select",
|
|
5541
|
+
summary: "Highest scores first, up to the run's limit. The session mixes them into its supply queue."
|
|
5542
|
+
}
|
|
5543
|
+
];
|
|
5544
|
+
}
|
|
5545
|
+
});
|
|
5546
|
+
|
|
5115
5547
|
// src/core/navigators/PipelineAssembler.ts
|
|
5116
5548
|
var PipelineAssembler_exports = {};
|
|
5117
5549
|
__export(PipelineAssembler_exports, {
|
|
@@ -5126,16 +5558,16 @@ var init_PipelineAssembler = __esm({
|
|
|
5126
5558
|
init_Pipeline();
|
|
5127
5559
|
init_logger();
|
|
5128
5560
|
init_CompositeGenerator();
|
|
5129
|
-
|
|
5561
|
+
init_pipelinePlan();
|
|
5130
5562
|
PipelineAssembler = class {
|
|
5131
5563
|
/**
|
|
5132
5564
|
* Assembles a navigation pipeline from strategy documents.
|
|
5133
5565
|
*
|
|
5134
|
-
* 1.
|
|
5135
|
-
*
|
|
5136
|
-
*
|
|
5137
|
-
*
|
|
5138
|
-
*
|
|
5566
|
+
* 1. Plans: classifies by role, adds default ELO/SRS and ELO distance, orders filters
|
|
5567
|
+
* (`planPipeline`)
|
|
5568
|
+
* 2. Instantiates generators - wraps multiple in CompositeGenerator
|
|
5569
|
+
* 3. Instantiates filters
|
|
5570
|
+
* 4. Returns Pipeline(generator, filters)
|
|
5139
5571
|
*
|
|
5140
5572
|
* @param input - Strategy documents plus user/course interfaces
|
|
5141
5573
|
* @returns Assembled pipeline and any warnings
|
|
@@ -5151,28 +5583,17 @@ var init_PipelineAssembler = __esm({
|
|
|
5151
5583
|
warnings
|
|
5152
5584
|
};
|
|
5153
5585
|
}
|
|
5154
|
-
const
|
|
5155
|
-
|
|
5156
|
-
for (const
|
|
5157
|
-
if (
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
} else {
|
|
5162
|
-
warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
|
|
5586
|
+
const plan = planPipeline(strategies, course.getCourseID());
|
|
5587
|
+
warnings.push(...plan.warnings);
|
|
5588
|
+
for (const n of [...plan.generators, ...plan.filters]) {
|
|
5589
|
+
if (n.origin === "assembler-default") {
|
|
5590
|
+
logger.debug(
|
|
5591
|
+
`[PipelineAssembler] No ${n.implementingClass} ${n.role} configured, adding default`
|
|
5592
|
+
);
|
|
5163
5593
|
}
|
|
5164
5594
|
}
|
|
5165
|
-
const
|
|
5166
|
-
const
|
|
5167
|
-
const hasSrs = generatorStrategies.some((s) => s.implementingClass === "srs" /* SRS */);
|
|
5168
|
-
if (!hasElo) {
|
|
5169
|
-
logger.debug("[PipelineAssembler] No ELO generator configured, adding default");
|
|
5170
|
-
generatorStrategies.push(createDefaultEloStrategy(courseId));
|
|
5171
|
-
}
|
|
5172
|
-
if (!hasSrs) {
|
|
5173
|
-
logger.debug("[PipelineAssembler] No SRS generator configured, adding default");
|
|
5174
|
-
generatorStrategies.push(createDefaultSrsStrategy(courseId));
|
|
5175
|
-
}
|
|
5595
|
+
const generatorStrategies = plan.generators.map((g) => g.strategy);
|
|
5596
|
+
const sortedFilterStrategies = plan.filters.map((f) => f.strategy);
|
|
5176
5597
|
if (generatorStrategies.length === 0) {
|
|
5177
5598
|
warnings.push("No generator strategy found");
|
|
5178
5599
|
return {
|
|
@@ -5194,9 +5615,6 @@ var init_PipelineAssembler = __esm({
|
|
|
5194
5615
|
generator = await CompositeGenerator.fromStrategies(user, course, generatorStrategies);
|
|
5195
5616
|
}
|
|
5196
5617
|
const filters = [];
|
|
5197
|
-
const sortedFilterStrategies = [...filterStrategies].sort(
|
|
5198
|
-
(a, b) => a.name.localeCompare(b.name)
|
|
5199
|
-
);
|
|
5200
5618
|
for (const filterStrategy of sortedFilterStrategies) {
|
|
5201
5619
|
try {
|
|
5202
5620
|
const nav = await ContentNavigator.create(user, course, filterStrategy);
|
|
@@ -5264,7 +5682,9 @@ var init_3 = __esm({
|
|
|
5264
5682
|
"./generators/prescribed.ts": () => Promise.resolve().then(() => (init_prescribed(), prescribed_exports)),
|
|
5265
5683
|
"./generators/srs.ts": () => Promise.resolve().then(() => (init_srs(), srs_exports)),
|
|
5266
5684
|
"./generators/types.ts": () => Promise.resolve().then(() => (init_types(), types_exports)),
|
|
5267
|
-
"./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports))
|
|
5685
|
+
"./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports)),
|
|
5686
|
+
"./pipelinePlan.ts": () => Promise.resolve().then(() => (init_pipelinePlan(), pipelinePlan_exports)),
|
|
5687
|
+
"./regulators.ts": () => Promise.resolve().then(() => (init_regulators(), regulators_exports))
|
|
5268
5688
|
});
|
|
5269
5689
|
}
|
|
5270
5690
|
});
|
|
@@ -5285,6 +5705,7 @@ __export(navigators_exports, {
|
|
|
5285
5705
|
drainCapturedRuns: () => drainCapturedRuns,
|
|
5286
5706
|
getActivePipeline: () => getActivePipeline,
|
|
5287
5707
|
getCardOrigin: () => getCardOrigin,
|
|
5708
|
+
getRegisteredFilterKind: () => getRegisteredFilterKind,
|
|
5288
5709
|
getRegisteredNavigator: () => getRegisteredNavigator,
|
|
5289
5710
|
getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
|
|
5290
5711
|
getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
|
|
@@ -5313,6 +5734,10 @@ function hasRegisteredNavigator(implementingClass) {
|
|
|
5313
5734
|
function getRegisteredNavigatorRole(implementingClass) {
|
|
5314
5735
|
return navigatorRegistry.get(implementingClass)?.role;
|
|
5315
5736
|
}
|
|
5737
|
+
function getRegisteredFilterKind(implementingClass) {
|
|
5738
|
+
const ctor = navigatorRegistry.get(implementingClass)?.constructor;
|
|
5739
|
+
return ctor?.kind;
|
|
5740
|
+
}
|
|
5316
5741
|
function getRegisteredNavigatorNames() {
|
|
5317
5742
|
return Array.from(navigatorRegistry.keys());
|
|
5318
5743
|
}
|
|
@@ -5330,17 +5755,20 @@ async function initializeNavigatorRegistry() {
|
|
|
5330
5755
|
hierarchyModule,
|
|
5331
5756
|
interferenceModule,
|
|
5332
5757
|
relativePriorityModule,
|
|
5333
|
-
userTagPreferenceModule
|
|
5758
|
+
userTagPreferenceModule,
|
|
5759
|
+
eloDistanceModule
|
|
5334
5760
|
] = await Promise.all([
|
|
5335
5761
|
Promise.resolve().then(() => (init_hierarchyDefinition(), hierarchyDefinition_exports)),
|
|
5336
5762
|
Promise.resolve().then(() => (init_interferenceMitigator(), interferenceMitigator_exports)),
|
|
5337
5763
|
Promise.resolve().then(() => (init_relativePriority(), relativePriority_exports)),
|
|
5338
|
-
Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports))
|
|
5764
|
+
Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports)),
|
|
5765
|
+
Promise.resolve().then(() => (init_eloDistance(), eloDistance_exports))
|
|
5339
5766
|
]);
|
|
5340
5767
|
registerNavigator("hierarchyDefinition", hierarchyModule.default);
|
|
5341
5768
|
registerNavigator("interferenceMitigator", interferenceModule.default);
|
|
5342
5769
|
registerNavigator("relativePriority", relativePriorityModule.default);
|
|
5343
5770
|
registerNavigator("userTagPreference", userTagPreferenceModule.default);
|
|
5771
|
+
registerNavigator("eloDistance", eloDistanceModule.default);
|
|
5344
5772
|
logger.debug(
|
|
5345
5773
|
`[NavigatorRegistry] Initialized ${navigatorRegistry.size} navigators: ${getRegisteredNavigatorNames().join(", ")}`
|
|
5346
5774
|
);
|
|
@@ -5388,6 +5816,7 @@ var init_navigators = __esm({
|
|
|
5388
5816
|
Navigators2["INTERFERENCE"] = "interferenceMitigator";
|
|
5389
5817
|
Navigators2["RELATIVE_PRIORITY"] = "relativePriority";
|
|
5390
5818
|
Navigators2["USER_TAG_PREFERENCE"] = "userTagPreference";
|
|
5819
|
+
Navigators2["ELO_DISTANCE"] = "eloDistance";
|
|
5391
5820
|
return Navigators2;
|
|
5392
5821
|
})(Navigators || {});
|
|
5393
5822
|
NavigatorRole = /* @__PURE__ */ ((NavigatorRole2) => {
|
|
@@ -5402,7 +5831,8 @@ var init_navigators = __esm({
|
|
|
5402
5831
|
["hierarchyDefinition" /* HIERARCHY */]: "filter" /* FILTER */,
|
|
5403
5832
|
["interferenceMitigator" /* INTERFERENCE */]: "filter" /* FILTER */,
|
|
5404
5833
|
["relativePriority" /* RELATIVE_PRIORITY */]: "filter" /* FILTER */,
|
|
5405
|
-
["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER
|
|
5834
|
+
["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER */,
|
|
5835
|
+
["eloDistance" /* ELO_DISTANCE */]: "filter" /* FILTER */
|
|
5406
5836
|
};
|
|
5407
5837
|
ContentNavigator = class {
|
|
5408
5838
|
/** User interface for this navigation session */
|
|
@@ -6141,6 +6571,14 @@ ${e.stack}` : JSON.stringify(e);
|
|
|
6141
6571
|
setEphemeralHints(hints) {
|
|
6142
6572
|
this._pendingHints = hints;
|
|
6143
6573
|
}
|
|
6574
|
+
/**
|
|
6575
|
+
* Forward a presentation to the navigator (a new card restarts its intake
|
|
6576
|
+
* clock). Builds the navigator if the cached one has expired.
|
|
6577
|
+
*/
|
|
6578
|
+
notePresented(card) {
|
|
6579
|
+
if (card.status !== "new") return;
|
|
6580
|
+
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}`));
|
|
6581
|
+
}
|
|
6144
6582
|
async getWeightedCards(limit) {
|
|
6145
6583
|
const u = await this._getCurrentUser();
|
|
6146
6584
|
try {
|
|
@@ -8192,10 +8630,11 @@ function backlogHtml(backlog) {
|
|
|
8192
8630
|
const rows = backlog.map((b) => {
|
|
8193
8631
|
const hot = b.backlogMultiplier >= 3;
|
|
8194
8632
|
const multColor = b.backlogMultiplier <= 1 ? "#86efac" : hot ? "#fca5a5" : "#fcd34d";
|
|
8195
|
-
const headroom = b.backlogMultiplier > 1 ? `climbing (\xD7${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog}
|
|
8633
|
+
const headroom = b.backlogMultiplier > 1 ? `climbing (\xD7${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog} of mass in excess, unbounded)` : "healthy \u2014 no pressure";
|
|
8634
|
+
const mass = b.reviewMass !== null ? ` \xB7 mass ${b.reviewMass.toFixed(1)}` : "";
|
|
8196
8635
|
const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
|
|
8197
8636
|
const next = b.nextDueIn ? ` <span style="opacity:.6">\xB7 next due ${esc(b.nextDueIn)}</span>` : "";
|
|
8198
|
-
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>`;
|
|
8637
|
+
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>`;
|
|
8199
8638
|
}).join("");
|
|
8200
8639
|
return `<div style="margin-bottom:6px"><div style="color:#93c5fd">review backpressure</div>${rows}</div>`;
|
|
8201
8640
|
}
|
|
@@ -8334,8 +8773,9 @@ function snapshotToText(s) {
|
|
|
8334
8773
|
const headroom = b.backlogMultiplier > 1 ? "climbing" : "healthy";
|
|
8335
8774
|
const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
|
|
8336
8775
|
const next = b.nextDueIn ? `, next due ${b.nextDueIn}` : "";
|
|
8776
|
+
const mass = b.reviewMass !== null ? `, mass ${b.reviewMass.toFixed(1)}` : "";
|
|
8337
8777
|
lines.push(
|
|
8338
|
-
` ${b.courseId.slice(0, 8)}: due ${b.dueNow}/${b.scheduledTotal} (healthy ${b.healthyBacklog})${next}; pressure \xD7${b.backlogMultiplier.toFixed(2)} ${headroom}; top review ${top}`
|
|
8778
|
+
` ${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}`
|
|
8339
8779
|
);
|
|
8340
8780
|
}
|
|
8341
8781
|
}
|
|
@@ -10832,6 +11272,7 @@ export {
|
|
|
10832
11272
|
getCardHistoryID,
|
|
10833
11273
|
getCardOrigin,
|
|
10834
11274
|
getDefaultLearnableWeight,
|
|
11275
|
+
getRegisteredFilterKind,
|
|
10835
11276
|
getRegisteredNavigator,
|
|
10836
11277
|
getRegisteredNavigatorNames,
|
|
10837
11278
|
getRegisteredNavigatorRole,
|