@vue-skuilder/db 0.2.28 → 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/{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 +587 -179
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +586 -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 +585 -179
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +585 -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 +582 -179
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +582 -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 +635 -180
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +622 -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 +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 +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,141 @@ 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
|
+
tagAwareGap: () => tagAwareGap
|
|
3081
3145
|
});
|
|
3082
3146
|
function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
|
|
3083
3147
|
const normalizedDistance = distance / halfLife;
|
|
3084
3148
|
const decay = Math.exp(-(normalizedDistance * normalizedDistance));
|
|
3085
3149
|
return minMultiplier + (maxMultiplier - minMultiplier) * decay;
|
|
3086
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
|
+
}
|
|
3087
3221
|
function createEloDistanceFilter(config) {
|
|
3088
|
-
const
|
|
3089
|
-
const
|
|
3090
|
-
const maxMultiplier = config?.maxMultiplier ?? DEFAULT_MAX_MULTIPLIER;
|
|
3222
|
+
const resolved = resolveConfig(config);
|
|
3223
|
+
const source = { name: "ELO Distance Filter", strategyId: "ELO_DISTANCE_FILTER" };
|
|
3091
3224
|
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
|
-
}
|
|
3225
|
+
name: source.name,
|
|
3226
|
+
kind: "signal",
|
|
3227
|
+
liveOnly: true,
|
|
3228
|
+
transform: (cards, context) => applyEloDistance(cards, context, resolved, source)
|
|
3120
3229
|
};
|
|
3121
3230
|
}
|
|
3122
|
-
var
|
|
3231
|
+
var DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, COUNT_ONLY_SENTINEL, DEFAULT_CARD_ELO, EloDistanceFilter;
|
|
3123
3232
|
var init_eloDistance = __esm({
|
|
3124
3233
|
"src/core/navigators/filters/eloDistance.ts"() {
|
|
3125
3234
|
"use strict";
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
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
|
+
};
|
|
3129
3276
|
}
|
|
3130
3277
|
});
|
|
3131
3278
|
|
|
@@ -3142,10 +3289,13 @@ var init_hierarchyDefinition = __esm({
|
|
|
3142
3289
|
init_navigators();
|
|
3143
3290
|
init_logger();
|
|
3144
3291
|
DEFAULT_MIN_COUNT2 = 3;
|
|
3145
|
-
HierarchyDefinitionNavigator = class extends ContentNavigator {
|
|
3292
|
+
HierarchyDefinitionNavigator = class _HierarchyDefinitionNavigator extends ContentNavigator {
|
|
3146
3293
|
config;
|
|
3147
3294
|
/** Human-readable name for CardFilter interface */
|
|
3148
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;
|
|
3149
3299
|
constructor(user, course, strategyData) {
|
|
3150
3300
|
super(user, course, strategyData);
|
|
3151
3301
|
this.config = this.parseConfig(strategyData.serializedData);
|
|
@@ -3412,10 +3562,13 @@ var init_userTagPreference = __esm({
|
|
|
3412
3562
|
"src/core/navigators/filters/userTagPreference.ts"() {
|
|
3413
3563
|
"use strict";
|
|
3414
3564
|
init_navigators();
|
|
3415
|
-
UserTagPreferenceFilter = class extends ContentNavigator {
|
|
3565
|
+
UserTagPreferenceFilter = class _UserTagPreferenceFilter extends ContentNavigator {
|
|
3416
3566
|
_strategyData;
|
|
3417
3567
|
/** Human-readable name for CardFilter interface */
|
|
3418
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;
|
|
3419
3572
|
constructor(user, course, strategyData) {
|
|
3420
3573
|
super(user, course, strategyData);
|
|
3421
3574
|
this._strategyData = strategyData;
|
|
@@ -3525,6 +3678,7 @@ var init_userTagPreference = __esm({
|
|
|
3525
3678
|
// src/core/navigators/filters/index.ts
|
|
3526
3679
|
var filters_exports = {};
|
|
3527
3680
|
__export(filters_exports, {
|
|
3681
|
+
EloDistanceFilter: () => EloDistanceFilter,
|
|
3528
3682
|
UserTagPreferenceFilter: () => UserTagPreferenceFilter,
|
|
3529
3683
|
createEloDistanceFilter: () => createEloDistanceFilter
|
|
3530
3684
|
});
|
|
@@ -3563,10 +3717,13 @@ var init_interferenceMitigator = __esm({
|
|
|
3563
3717
|
DEFAULT_MIN_COUNT3 = 10;
|
|
3564
3718
|
DEFAULT_MIN_ELAPSED_DAYS = 3;
|
|
3565
3719
|
DEFAULT_INTERFERENCE_DECAY = 0.8;
|
|
3566
|
-
InterferenceMitigatorNavigator = class extends ContentNavigator {
|
|
3720
|
+
InterferenceMitigatorNavigator = class _InterferenceMitigatorNavigator extends ContentNavigator {
|
|
3567
3721
|
config;
|
|
3568
3722
|
/** Human-readable name for CardFilter interface */
|
|
3569
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;
|
|
3570
3727
|
/** Precomputed map: tag -> set of { partner, decay } it interferes with */
|
|
3571
3728
|
interferenceMap;
|
|
3572
3729
|
constructor(user, course, strategyData) {
|
|
@@ -3782,10 +3939,13 @@ var init_relativePriority = __esm({
|
|
|
3782
3939
|
DEFAULT_PRIORITY = 0.5;
|
|
3783
3940
|
DEFAULT_PRIORITY_INFLUENCE = 0.5;
|
|
3784
3941
|
DEFAULT_COMBINE_MODE = "max";
|
|
3785
|
-
RelativePriorityNavigator = class extends ContentNavigator {
|
|
3942
|
+
RelativePriorityNavigator = class _RelativePriorityNavigator extends ContentNavigator {
|
|
3786
3943
|
config;
|
|
3787
3944
|
/** Human-readable name for CardFilter interface */
|
|
3788
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;
|
|
3789
3949
|
constructor(user, course, strategyData) {
|
|
3790
3950
|
super(user, course, strategyData);
|
|
3791
3951
|
this.config = this.parseConfig(strategyData.serializedData);
|
|
@@ -4439,6 +4599,8 @@ var init_Pipeline = __esm({
|
|
|
4439
4599
|
init_orchestration();
|
|
4440
4600
|
init_PipelineDebugger();
|
|
4441
4601
|
init_diversityRerank();
|
|
4602
|
+
init_regulators();
|
|
4603
|
+
init_SrsDebugger();
|
|
4442
4604
|
VERBOSE_RESULTS = true;
|
|
4443
4605
|
Pipeline = class extends ContentNavigator {
|
|
4444
4606
|
generator;
|
|
@@ -4464,6 +4626,13 @@ var init_Pipeline = __esm({
|
|
|
4464
4626
|
* getWeightedCards() call, then cleared.
|
|
4465
4627
|
*/
|
|
4466
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();
|
|
4467
4636
|
/**
|
|
4468
4637
|
* Create a new pipeline.
|
|
4469
4638
|
*
|
|
@@ -4538,13 +4707,12 @@ var init_Pipeline = __esm({
|
|
|
4538
4707
|
}
|
|
4539
4708
|
}
|
|
4540
4709
|
generatorSummaries = Array.from(genMap.entries()).map(([name, data]) => {
|
|
4541
|
-
const
|
|
4542
|
-
const reviewCards = data.cards.filter((c) => c.provenance[0]?.reason?.includes("review"));
|
|
4710
|
+
const reviewCount = data.cards.filter((c) => c.reviewID).length;
|
|
4543
4711
|
return {
|
|
4544
4712
|
name,
|
|
4545
4713
|
cardCount: data.cards.length,
|
|
4546
|
-
newCount:
|
|
4547
|
-
reviewCount
|
|
4714
|
+
newCount: data.cards.length - reviewCount,
|
|
4715
|
+
reviewCount,
|
|
4548
4716
|
topScore: Math.max(...data.cards.map((c) => c.score), 0)
|
|
4549
4717
|
};
|
|
4550
4718
|
});
|
|
@@ -4580,19 +4748,24 @@ var init_Pipeline = __esm({
|
|
|
4580
4748
|
cards.filter((c) => c.provenance.some((p) => p.strategy === "prescribed")).map((c) => c.cardId)
|
|
4581
4749
|
);
|
|
4582
4750
|
const filterImpacts = [];
|
|
4751
|
+
const generatedScores = new Map(cards.map((c) => [c.cardId, c.score]));
|
|
4752
|
+
const gated = /* @__PURE__ */ new Set();
|
|
4583
4753
|
for (const filter of this.filters) {
|
|
4584
4754
|
const beforeCount = cards.length;
|
|
4585
4755
|
const beforeScores = new Map(cards.map((c) => [c.cardId, c.score]));
|
|
4586
4756
|
cards = await filter.transform(cards, context);
|
|
4587
4757
|
let boosted = 0, penalized = 0, passed = 0;
|
|
4588
4758
|
const removed = beforeCount - cards.length;
|
|
4759
|
+
const kind = filter.kind ?? "gate";
|
|
4589
4760
|
for (const card of cards) {
|
|
4590
4761
|
const before = beforeScores.get(card.cardId) ?? 0;
|
|
4591
4762
|
if (card.score > before) boosted++;
|
|
4592
|
-
else if (card.score < before)
|
|
4593
|
-
|
|
4763
|
+
else if (card.score < before) {
|
|
4764
|
+
penalized++;
|
|
4765
|
+
if (kind === "gate") gated.add(card.cardId);
|
|
4766
|
+
} else passed++;
|
|
4594
4767
|
}
|
|
4595
|
-
filterImpacts.push({ name: filter.name, boosted, penalized, passed, removed });
|
|
4768
|
+
filterImpacts.push({ name: filter.name, kind, boosted, penalized, passed, removed });
|
|
4596
4769
|
if (prescribedIds.size > 0) {
|
|
4597
4770
|
const survivingIds = new Set(cards.map((c) => c.cardId));
|
|
4598
4771
|
const killedPrescribed = [...prescribedIds].filter((id) => !survivingIds.has(id));
|
|
@@ -4608,6 +4781,7 @@ var init_Pipeline = __esm({
|
|
|
4608
4781
|
}
|
|
4609
4782
|
const scoredCards = cards;
|
|
4610
4783
|
cards = cards.filter((c) => c.score > 0);
|
|
4784
|
+
const regulators = await this.regulate(cards, generatedScores, gated);
|
|
4611
4785
|
const hints = this._ephemeralHints;
|
|
4612
4786
|
if (hints) {
|
|
4613
4787
|
this._ephemeralHints = null;
|
|
@@ -4644,7 +4818,8 @@ var init_Pipeline = __esm({
|
|
|
4644
4818
|
result,
|
|
4645
4819
|
context.userElo,
|
|
4646
4820
|
hints ?? void 0,
|
|
4647
|
-
scoredCards
|
|
4821
|
+
scoredCards,
|
|
4822
|
+
regulators
|
|
4648
4823
|
);
|
|
4649
4824
|
captureRun(report);
|
|
4650
4825
|
} catch (e) {
|
|
@@ -4823,6 +4998,77 @@ var init_Pipeline = __esm({
|
|
|
4823
4998
|
logger.info(`[Pipeline] Hints applied: ${beforeCount} \u2192 ${cards.length} cards`);
|
|
4824
4999
|
return cards;
|
|
4825
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
|
+
}
|
|
4826
5072
|
/**
|
|
4827
5073
|
* Build shared context for generator and filters.
|
|
4828
5074
|
*
|
|
@@ -4833,10 +5079,11 @@ var init_Pipeline = __esm({
|
|
|
4833
5079
|
*/
|
|
4834
5080
|
async buildContext() {
|
|
4835
5081
|
let userElo = 1e3;
|
|
5082
|
+
let userCourseElo;
|
|
4836
5083
|
try {
|
|
4837
5084
|
const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
|
|
4838
|
-
|
|
4839
|
-
userElo =
|
|
5085
|
+
userCourseElo = toCourseElo5(courseReg.elo);
|
|
5086
|
+
userElo = userCourseElo.global.score;
|
|
4840
5087
|
} catch (e) {
|
|
4841
5088
|
logger.debug(`[Pipeline] Could not get user ELO, using default: ${e}`);
|
|
4842
5089
|
}
|
|
@@ -4848,6 +5095,7 @@ var init_Pipeline = __esm({
|
|
|
4848
5095
|
user: this.user,
|
|
4849
5096
|
course: this.course,
|
|
4850
5097
|
userElo,
|
|
5098
|
+
...userCourseElo ? { userCourseElo } : {},
|
|
4851
5099
|
orchestration
|
|
4852
5100
|
};
|
|
4853
5101
|
}
|
|
@@ -4961,7 +5209,7 @@ var init_Pipeline = __esm({
|
|
|
4961
5209
|
cards = await this.hydrateTags(cards);
|
|
4962
5210
|
const fullPool = cards.slice();
|
|
4963
5211
|
const context = await this.buildContext();
|
|
4964
|
-
for (const filter of this.
|
|
5212
|
+
for (const filter of this.forecastFilters()) {
|
|
4965
5213
|
cards = await filter.transform(cards, context);
|
|
4966
5214
|
}
|
|
4967
5215
|
if (opts?.hints) {
|
|
@@ -4980,6 +5228,14 @@ var init_Pipeline = __esm({
|
|
|
4980
5228
|
cards.sort((a, b) => b.score - a.score);
|
|
4981
5229
|
return opts?.limit ? cards.slice(0, opts.limit) : cards;
|
|
4982
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
|
+
}
|
|
4983
5239
|
/**
|
|
4984
5240
|
* Scan every card in the course through the filter chain and report
|
|
4985
5241
|
* how many are "well indicated" (score >= threshold) for the current user.
|
|
@@ -5001,7 +5257,7 @@ var init_Pipeline = __esm({
|
|
|
5001
5257
|
cards = await this.hydrateTags(cards);
|
|
5002
5258
|
const context = await this.buildContext();
|
|
5003
5259
|
const filterBreakdown = [];
|
|
5004
|
-
for (const filter of this.
|
|
5260
|
+
for (const filter of this.forecastFilters()) {
|
|
5005
5261
|
cards = await filter.transform(cards, context);
|
|
5006
5262
|
const wi = cards.filter((c) => c.score >= THRESHOLD).length;
|
|
5007
5263
|
filterBreakdown.push({ name: filter.name, wellIndicated: wi });
|
|
@@ -5065,6 +5321,7 @@ var init_Pipeline = __esm({
|
|
|
5065
5321
|
// src/core/navigators/defaults.ts
|
|
5066
5322
|
var defaults_exports = {};
|
|
5067
5323
|
__export(defaults_exports, {
|
|
5324
|
+
createDefaultEloDistanceStrategy: () => createDefaultEloDistanceStrategy,
|
|
5068
5325
|
createDefaultEloStrategy: () => createDefaultEloStrategy,
|
|
5069
5326
|
createDefaultPipeline: () => createDefaultPipeline,
|
|
5070
5327
|
createDefaultSrsStrategy: () => createDefaultSrsStrategy
|
|
@@ -5091,12 +5348,28 @@ function createDefaultSrsStrategy(courseId) {
|
|
|
5091
5348
|
serializedData: ""
|
|
5092
5349
|
};
|
|
5093
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
|
+
}
|
|
5094
5363
|
function createDefaultPipeline(user, course) {
|
|
5095
5364
|
const courseId = course.getCourseID();
|
|
5096
5365
|
const eloNavigator = new ELONavigator(user, course, createDefaultEloStrategy(courseId));
|
|
5097
5366
|
const srsNavigator = new SRSNavigator(user, course, createDefaultSrsStrategy(courseId));
|
|
5098
5367
|
const compositeGenerator = new CompositeGenerator([eloNavigator, srsNavigator]);
|
|
5099
|
-
const eloDistanceFilter =
|
|
5368
|
+
const eloDistanceFilter = new EloDistanceFilter(
|
|
5369
|
+
user,
|
|
5370
|
+
course,
|
|
5371
|
+
createDefaultEloDistanceStrategy(courseId)
|
|
5372
|
+
);
|
|
5100
5373
|
return new Pipeline(compositeGenerator, [eloDistanceFilter], user, course);
|
|
5101
5374
|
}
|
|
5102
5375
|
var init_defaults = __esm({
|
|
@@ -5112,6 +5385,131 @@ var init_defaults = __esm({
|
|
|
5112
5385
|
}
|
|
5113
5386
|
});
|
|
5114
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
|
+
|
|
5115
5513
|
// src/core/navigators/PipelineAssembler.ts
|
|
5116
5514
|
var PipelineAssembler_exports = {};
|
|
5117
5515
|
__export(PipelineAssembler_exports, {
|
|
@@ -5126,16 +5524,16 @@ var init_PipelineAssembler = __esm({
|
|
|
5126
5524
|
init_Pipeline();
|
|
5127
5525
|
init_logger();
|
|
5128
5526
|
init_CompositeGenerator();
|
|
5129
|
-
|
|
5527
|
+
init_pipelinePlan();
|
|
5130
5528
|
PipelineAssembler = class {
|
|
5131
5529
|
/**
|
|
5132
5530
|
* Assembles a navigation pipeline from strategy documents.
|
|
5133
5531
|
*
|
|
5134
|
-
* 1.
|
|
5135
|
-
*
|
|
5136
|
-
*
|
|
5137
|
-
*
|
|
5138
|
-
*
|
|
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)
|
|
5139
5537
|
*
|
|
5140
5538
|
* @param input - Strategy documents plus user/course interfaces
|
|
5141
5539
|
* @returns Assembled pipeline and any warnings
|
|
@@ -5151,28 +5549,17 @@ var init_PipelineAssembler = __esm({
|
|
|
5151
5549
|
warnings
|
|
5152
5550
|
};
|
|
5153
5551
|
}
|
|
5154
|
-
const
|
|
5155
|
-
|
|
5156
|
-
for (const
|
|
5157
|
-
if (
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
} else {
|
|
5162
|
-
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
|
+
);
|
|
5163
5559
|
}
|
|
5164
5560
|
}
|
|
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
|
-
}
|
|
5561
|
+
const generatorStrategies = plan.generators.map((g) => g.strategy);
|
|
5562
|
+
const sortedFilterStrategies = plan.filters.map((f) => f.strategy);
|
|
5176
5563
|
if (generatorStrategies.length === 0) {
|
|
5177
5564
|
warnings.push("No generator strategy found");
|
|
5178
5565
|
return {
|
|
@@ -5194,9 +5581,6 @@ var init_PipelineAssembler = __esm({
|
|
|
5194
5581
|
generator = await CompositeGenerator.fromStrategies(user, course, generatorStrategies);
|
|
5195
5582
|
}
|
|
5196
5583
|
const filters = [];
|
|
5197
|
-
const sortedFilterStrategies = [...filterStrategies].sort(
|
|
5198
|
-
(a, b) => a.name.localeCompare(b.name)
|
|
5199
|
-
);
|
|
5200
5584
|
for (const filterStrategy of sortedFilterStrategies) {
|
|
5201
5585
|
try {
|
|
5202
5586
|
const nav = await ContentNavigator.create(user, course, filterStrategy);
|
|
@@ -5264,7 +5648,9 @@ var init_3 = __esm({
|
|
|
5264
5648
|
"./generators/prescribed.ts": () => Promise.resolve().then(() => (init_prescribed(), prescribed_exports)),
|
|
5265
5649
|
"./generators/srs.ts": () => Promise.resolve().then(() => (init_srs(), srs_exports)),
|
|
5266
5650
|
"./generators/types.ts": () => Promise.resolve().then(() => (init_types(), types_exports)),
|
|
5267
|
-
"./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))
|
|
5268
5654
|
});
|
|
5269
5655
|
}
|
|
5270
5656
|
});
|
|
@@ -5285,6 +5671,7 @@ __export(navigators_exports, {
|
|
|
5285
5671
|
drainCapturedRuns: () => drainCapturedRuns,
|
|
5286
5672
|
getActivePipeline: () => getActivePipeline,
|
|
5287
5673
|
getCardOrigin: () => getCardOrigin,
|
|
5674
|
+
getRegisteredFilterKind: () => getRegisteredFilterKind,
|
|
5288
5675
|
getRegisteredNavigator: () => getRegisteredNavigator,
|
|
5289
5676
|
getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
|
|
5290
5677
|
getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
|
|
@@ -5313,6 +5700,10 @@ function hasRegisteredNavigator(implementingClass) {
|
|
|
5313
5700
|
function getRegisteredNavigatorRole(implementingClass) {
|
|
5314
5701
|
return navigatorRegistry.get(implementingClass)?.role;
|
|
5315
5702
|
}
|
|
5703
|
+
function getRegisteredFilterKind(implementingClass) {
|
|
5704
|
+
const ctor = navigatorRegistry.get(implementingClass)?.constructor;
|
|
5705
|
+
return ctor?.kind;
|
|
5706
|
+
}
|
|
5316
5707
|
function getRegisteredNavigatorNames() {
|
|
5317
5708
|
return Array.from(navigatorRegistry.keys());
|
|
5318
5709
|
}
|
|
@@ -5330,17 +5721,20 @@ async function initializeNavigatorRegistry() {
|
|
|
5330
5721
|
hierarchyModule,
|
|
5331
5722
|
interferenceModule,
|
|
5332
5723
|
relativePriorityModule,
|
|
5333
|
-
userTagPreferenceModule
|
|
5724
|
+
userTagPreferenceModule,
|
|
5725
|
+
eloDistanceModule
|
|
5334
5726
|
] = await Promise.all([
|
|
5335
5727
|
Promise.resolve().then(() => (init_hierarchyDefinition(), hierarchyDefinition_exports)),
|
|
5336
5728
|
Promise.resolve().then(() => (init_interferenceMitigator(), interferenceMitigator_exports)),
|
|
5337
5729
|
Promise.resolve().then(() => (init_relativePriority(), relativePriority_exports)),
|
|
5338
|
-
Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports))
|
|
5730
|
+
Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports)),
|
|
5731
|
+
Promise.resolve().then(() => (init_eloDistance(), eloDistance_exports))
|
|
5339
5732
|
]);
|
|
5340
5733
|
registerNavigator("hierarchyDefinition", hierarchyModule.default);
|
|
5341
5734
|
registerNavigator("interferenceMitigator", interferenceModule.default);
|
|
5342
5735
|
registerNavigator("relativePriority", relativePriorityModule.default);
|
|
5343
5736
|
registerNavigator("userTagPreference", userTagPreferenceModule.default);
|
|
5737
|
+
registerNavigator("eloDistance", eloDistanceModule.default);
|
|
5344
5738
|
logger.debug(
|
|
5345
5739
|
`[NavigatorRegistry] Initialized ${navigatorRegistry.size} navigators: ${getRegisteredNavigatorNames().join(", ")}`
|
|
5346
5740
|
);
|
|
@@ -5388,6 +5782,7 @@ var init_navigators = __esm({
|
|
|
5388
5782
|
Navigators2["INTERFERENCE"] = "interferenceMitigator";
|
|
5389
5783
|
Navigators2["RELATIVE_PRIORITY"] = "relativePriority";
|
|
5390
5784
|
Navigators2["USER_TAG_PREFERENCE"] = "userTagPreference";
|
|
5785
|
+
Navigators2["ELO_DISTANCE"] = "eloDistance";
|
|
5391
5786
|
return Navigators2;
|
|
5392
5787
|
})(Navigators || {});
|
|
5393
5788
|
NavigatorRole = /* @__PURE__ */ ((NavigatorRole2) => {
|
|
@@ -5402,7 +5797,8 @@ var init_navigators = __esm({
|
|
|
5402
5797
|
["hierarchyDefinition" /* HIERARCHY */]: "filter" /* FILTER */,
|
|
5403
5798
|
["interferenceMitigator" /* INTERFERENCE */]: "filter" /* FILTER */,
|
|
5404
5799
|
["relativePriority" /* RELATIVE_PRIORITY */]: "filter" /* FILTER */,
|
|
5405
|
-
["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER
|
|
5800
|
+
["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER */,
|
|
5801
|
+
["eloDistance" /* ELO_DISTANCE */]: "filter" /* FILTER */
|
|
5406
5802
|
};
|
|
5407
5803
|
ContentNavigator = class {
|
|
5408
5804
|
/** User interface for this navigation session */
|
|
@@ -6141,6 +6537,14 @@ ${e.stack}` : JSON.stringify(e);
|
|
|
6141
6537
|
setEphemeralHints(hints) {
|
|
6142
6538
|
this._pendingHints = hints;
|
|
6143
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
|
+
}
|
|
6144
6548
|
async getWeightedCards(limit) {
|
|
6145
6549
|
const u = await this._getCurrentUser();
|
|
6146
6550
|
try {
|
|
@@ -8192,10 +8596,11 @@ function backlogHtml(backlog) {
|
|
|
8192
8596
|
const rows = backlog.map((b) => {
|
|
8193
8597
|
const hot = b.backlogMultiplier >= 3;
|
|
8194
8598
|
const multColor = b.backlogMultiplier <= 1 ? "#86efac" : hot ? "#fca5a5" : "#fcd34d";
|
|
8195
|
-
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)}` : "";
|
|
8196
8601
|
const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
|
|
8197
8602
|
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>`;
|
|
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>`;
|
|
8199
8604
|
}).join("");
|
|
8200
8605
|
return `<div style="margin-bottom:6px"><div style="color:#93c5fd">review backpressure</div>${rows}</div>`;
|
|
8201
8606
|
}
|
|
@@ -8334,8 +8739,9 @@ function snapshotToText(s) {
|
|
|
8334
8739
|
const headroom = b.backlogMultiplier > 1 ? "climbing" : "healthy";
|
|
8335
8740
|
const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
|
|
8336
8741
|
const next = b.nextDueIn ? `, next due ${b.nextDueIn}` : "";
|
|
8742
|
+
const mass = b.reviewMass !== null ? `, mass ${b.reviewMass.toFixed(1)}` : "";
|
|
8337
8743
|
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}`
|
|
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}`
|
|
8339
8745
|
);
|
|
8340
8746
|
}
|
|
8341
8747
|
}
|
|
@@ -10832,6 +11238,7 @@ export {
|
|
|
10832
11238
|
getCardHistoryID,
|
|
10833
11239
|
getCardOrigin,
|
|
10834
11240
|
getDefaultLearnableWeight,
|
|
11241
|
+
getRegisteredFilterKind,
|
|
10835
11242
|
getRegisteredNavigator,
|
|
10836
11243
|
getRegisteredNavigatorNames,
|
|
10837
11244
|
getRegisteredNavigatorRole,
|