@vue-skuilder/db 0.2.27 → 0.2.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classroomDB-DLTtLZct.d.cts +86 -0
- package/dist/classroomDB-DLTtLZct.d.ts +86 -0
- package/dist/{contentSource-LPf044hY.d.ts → contentSource-B6FrSihy.d.cts} +282 -99
- package/dist/{contentSource-D3c1fMAk.d.cts → contentSource-CqJmbOZN.d.ts} +282 -99
- package/dist/core/index.d.cts +16 -92
- package/dist/core/index.d.ts +16 -92
- package/dist/core/index.js +607 -179
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +606 -179
- package/dist/core/index.mjs.map +1 -1
- package/dist/{dataLayerProvider-DaAootVV.d.ts → dataLayerProvider-B9_UCvkR.d.ts} +2 -8
- package/dist/{dataLayerProvider-CeLiFbHv.d.cts → dataLayerProvider-DUxDqMtZ.d.cts} +2 -8
- package/dist/diagnostics/index.d.cts +443 -0
- package/dist/diagnostics/index.d.ts +443 -0
- package/dist/diagnostics/index.js +932 -0
- package/dist/diagnostics/index.js.map +1 -0
- package/dist/diagnostics/index.mjs +881 -0
- package/dist/diagnostics/index.mjs.map +1 -0
- package/dist/impl/couch/index.d.cts +13 -3
- package/dist/impl/couch/index.d.ts +13 -3
- package/dist/impl/couch/index.js +605 -179
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +605 -179
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.d.cts +11 -5
- package/dist/impl/static/index.d.ts +11 -5
- package/dist/impl/static/index.js +602 -185
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +602 -185
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/{index-BkBJlGDX.d.ts → index-CVGehe_t.d.ts} +1 -1
- package/dist/{index-D7WdMDAs.d.cts → index-Ktg72jKb.d.cts} +1 -1
- package/dist/index.d.cts +73 -11
- package/dist/index.d.ts +73 -11
- package/dist/index.js +696 -200
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +683 -200
- package/dist/index.mjs.map +1 -1
- package/dist/{types-DjiFOZxJ.d.cts → types-D0oQeJAi.d.cts} +1 -1
- package/dist/{types-uJ2Xn3_X.d.ts → types-dXWfyz9B.d.ts} +1 -1
- package/dist/{types-legacy-CrwyZIvI.d.cts → types-legacy-BkOYOR6U.d.cts} +1 -1
- package/dist/{types-legacy-CrwyZIvI.d.ts → types-legacy-BkOYOR6U.d.ts} +1 -1
- package/dist/util/packer/index.d.cts +3 -3
- package/dist/util/packer/index.d.ts +3 -3
- package/package.json +15 -3
- package/src/core/interfaces/contentSource.ts +7 -0
- package/src/core/interfaces/dataLayerProvider.ts +3 -8
- package/src/core/navigators/Pipeline.ts +149 -14
- package/src/core/navigators/PipelineAssembler.ts +19 -40
- package/src/core/navigators/PipelineDebugger.ts +74 -17
- package/src/core/navigators/SrsDebugger.ts +37 -12
- package/src/core/navigators/defaults.ts +29 -5
- package/src/core/navigators/filters/WeightedFilter.ts +5 -1
- package/src/core/navigators/filters/eloDistance.ts +261 -76
- package/src/core/navigators/filters/hierarchyDefinition.ts +5 -1
- package/src/core/navigators/filters/index.ts +2 -2
- package/src/core/navigators/filters/interferenceMitigator.ts +5 -1
- package/src/core/navigators/filters/relativePriority.ts +5 -1
- package/src/core/navigators/filters/types.ts +24 -1
- package/src/core/navigators/filters/userTagPreference.ts +5 -1
- package/src/core/navigators/generators/elo.ts +23 -53
- package/src/core/navigators/generators/srs.ts +27 -124
- package/src/core/navigators/index.ts +32 -5
- package/src/core/navigators/pipelinePlan.ts +245 -0
- package/src/core/navigators/regulators.ts +230 -0
- package/src/core/types/studySession.ts +40 -0
- package/src/diagnostics/dataset.ts +242 -0
- package/src/diagnostics/derive.ts +555 -0
- package/src/diagnostics/index.ts +27 -0
- package/src/diagnostics/loader.ts +194 -0
- package/src/diagnostics/pipeline.ts +236 -0
- package/src/diagnostics/text.ts +265 -0
- package/src/impl/couch/PouchDataLayerProvider.ts +0 -23
- package/src/impl/couch/courseDB.ts +13 -0
- package/src/impl/static/StaticDataLayerProvider.ts +0 -11
- package/src/impl/static/courseDB.ts +9 -0
- package/src/index.ts +4 -0
- package/src/study/SessionController.ts +76 -2
- package/src/study/SessionOverlay.ts +7 -4
- package/tests/core/navigators/PipelineAssembler.test.ts +20 -5
- package/tests/core/navigators/eloDistanceFilter.test.ts +9 -9
- package/tsup.config.ts +1 -0
package/dist/core/index.js
CHANGED
|
@@ -723,7 +723,7 @@ function parseCardElo(provenance) {
|
|
|
723
723
|
const match = eloEntry.reason.match(/card:\s*(\d+)/);
|
|
724
724
|
return match ? parseInt(match[1], 10) : void 0;
|
|
725
725
|
}
|
|
726
|
-
function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints) {
|
|
726
|
+
function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints, scoredCards, regulators) {
|
|
727
727
|
const selectedIds = new Set(selectedCards.map((c) => c.cardId));
|
|
728
728
|
const toReport = (card) => ({
|
|
729
729
|
cardId: card.cardId,
|
|
@@ -731,7 +731,7 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
|
|
|
731
731
|
origin: getOrigin(card),
|
|
732
732
|
generator: card.provenance[0]?.strategyName || card.provenance[0]?.strategy,
|
|
733
733
|
finalScore: card.score,
|
|
734
|
-
cardElo: parseCardElo(card.provenance),
|
|
734
|
+
cardElo: card.cardElo ?? parseCardElo(card.provenance),
|
|
735
735
|
provenance: card.provenance,
|
|
736
736
|
tags: card.tags,
|
|
737
737
|
selected: selectedIds.has(card.cardId)
|
|
@@ -776,6 +776,23 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
|
|
|
776
776
|
note: `${discardedTailCards.length} additional candidate(s) scored below the top ${DISCARDED_KEEP_TOP} near-misses and were not retained (score ${scoreMin.toExponential(2)}\u2013${scoreMax.toExponential(2)}${eloFragment}). Likely ELO-window pull remnants filtered out by hierarchy/lesson/priority gates.`
|
|
777
777
|
};
|
|
778
778
|
}
|
|
779
|
+
const isUnselectedNew = (c) => !c.reviewID && !selectedIds.has(c.cardId);
|
|
780
|
+
const generatorScore = (c) => c.provenance[0]?.score ?? 0;
|
|
781
|
+
const keptIds = new Set(allCards.map((c) => c.cardId));
|
|
782
|
+
const hintExcluded = (c) => c.score > 0 && !keptIds.has(c.cardId);
|
|
783
|
+
let nextInLine;
|
|
784
|
+
for (const c of allCards) {
|
|
785
|
+
if (isUnselectedNew(c) && (!nextInLine || c.score > nextInLine.score)) nextInLine = c;
|
|
786
|
+
}
|
|
787
|
+
let topGenerated;
|
|
788
|
+
for (const c of scoredCards ?? allCards) {
|
|
789
|
+
if (!isUnselectedNew(c) || hintExcluded(c)) continue;
|
|
790
|
+
if (!topGenerated || generatorScore(c) > generatorScore(topGenerated)) topGenerated = c;
|
|
791
|
+
}
|
|
792
|
+
const unselectedNew = nextInLine || topGenerated ? {
|
|
793
|
+
...nextInLine ? { nextInLine: toReport(nextInLine) } : {},
|
|
794
|
+
...topGenerated && topGenerated.cardId !== nextInLine?.cardId ? { topGenerated: toReport(topGenerated) } : {}
|
|
795
|
+
} : void 0;
|
|
779
796
|
const reviewsSelected = selectedCards.filter((c) => getOrigin(c) === "review").length;
|
|
780
797
|
const newSelected = selectedCards.filter((c) => getOrigin(c) === "new").length;
|
|
781
798
|
return {
|
|
@@ -791,7 +808,9 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
|
|
|
791
808
|
reviewsSelected,
|
|
792
809
|
newSelected,
|
|
793
810
|
cards,
|
|
794
|
-
|
|
811
|
+
unselectedNew,
|
|
812
|
+
discardedTail,
|
|
813
|
+
...regulators ? { regulators } : {}
|
|
795
814
|
};
|
|
796
815
|
}
|
|
797
816
|
function formatProvenance(provenance) {
|
|
@@ -1515,11 +1534,23 @@ var SrsDebugger_exports = {};
|
|
|
1515
1534
|
__export(SrsDebugger_exports, {
|
|
1516
1535
|
captureSrsBacklog: () => captureSrsBacklog,
|
|
1517
1536
|
clearSrsBacklogDebug: () => clearSrsBacklogDebug,
|
|
1518
|
-
getSrsBacklogDebug: () => getSrsBacklogDebug
|
|
1537
|
+
getSrsBacklogDebug: () => getSrsBacklogDebug,
|
|
1538
|
+
noteReviewPressure: () => noteReviewPressure
|
|
1519
1539
|
});
|
|
1520
1540
|
function captureSrsBacklog(snapshot) {
|
|
1521
1541
|
snapshots.set(snapshot.courseId, snapshot);
|
|
1522
1542
|
}
|
|
1543
|
+
function noteReviewPressure(courseId, pressure) {
|
|
1544
|
+
const snapshot = snapshots.get(courseId);
|
|
1545
|
+
if (!snapshot) return;
|
|
1546
|
+
snapshots.set(courseId, {
|
|
1547
|
+
...snapshot,
|
|
1548
|
+
reviewMass: pressure.mass,
|
|
1549
|
+
healthyBacklog: pressure.healthyMass,
|
|
1550
|
+
backlogGrowthRate: pressure.rate,
|
|
1551
|
+
backlogMultiplier: pressure.multiplier
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1523
1554
|
function getSrsBacklogDebug() {
|
|
1524
1555
|
return [...snapshots.values()].sort((a, b) => b.timestamp - a.timestamp);
|
|
1525
1556
|
}
|
|
@@ -1797,14 +1828,13 @@ var elo_exports = {};
|
|
|
1797
1828
|
__export(elo_exports, {
|
|
1798
1829
|
default: () => ELONavigator
|
|
1799
1830
|
});
|
|
1800
|
-
var import_common5,
|
|
1831
|
+
var import_common5, ELONavigator;
|
|
1801
1832
|
var init_elo = __esm({
|
|
1802
1833
|
"src/core/navigators/generators/elo.ts"() {
|
|
1803
1834
|
"use strict";
|
|
1804
1835
|
init_navigators();
|
|
1805
1836
|
import_common5 = require("@vue-skuilder/common");
|
|
1806
1837
|
init_logger();
|
|
1807
|
-
ELO_RELEVANCE_SIGMA = 300;
|
|
1808
1838
|
ELONavigator = class extends ContentNavigator {
|
|
1809
1839
|
/** Human-readable name for CardGenerator interface */
|
|
1810
1840
|
name;
|
|
@@ -1813,10 +1843,8 @@ var init_elo = __esm({
|
|
|
1813
1843
|
this.name = strategyData?.name || "ELO";
|
|
1814
1844
|
}
|
|
1815
1845
|
/**
|
|
1816
|
-
* Get new cards
|
|
1817
|
-
*
|
|
1818
|
-
* Cards closer to user's ELO get higher scores.
|
|
1819
|
-
* Score formula: max(0, 1 - distance / 500)
|
|
1846
|
+
* Get the new cards nearest the learner's ELO, each scored with a flat
|
|
1847
|
+
* jitter in [0.5, 1]. Carries each card's ELO for the ELO distance filter.
|
|
1820
1848
|
*
|
|
1821
1849
|
* NOTE: This generator only handles NEW cards. Reviews are handled by
|
|
1822
1850
|
* SRSNavigator. Use CompositeGenerator to combine both.
|
|
@@ -1844,20 +1872,20 @@ var init_elo = __esm({
|
|
|
1844
1872
|
const scored = newCards.map((c) => {
|
|
1845
1873
|
const cardElo = c.elo ?? 1e3;
|
|
1846
1874
|
const distance = Math.abs(cardElo - userGlobalElo);
|
|
1847
|
-
const
|
|
1848
|
-
const samplingKey = relevance * (0.5 + 0.5 * Math.random());
|
|
1875
|
+
const jitter = 0.5 + 0.5 * Math.random();
|
|
1849
1876
|
return {
|
|
1850
1877
|
cardId: c.cardID,
|
|
1851
1878
|
courseId: c.courseID,
|
|
1852
|
-
score:
|
|
1879
|
+
score: jitter,
|
|
1880
|
+
cardElo,
|
|
1853
1881
|
provenance: [
|
|
1854
1882
|
{
|
|
1855
1883
|
strategy: "elo",
|
|
1856
1884
|
strategyName: this.strategyName || this.name,
|
|
1857
1885
|
strategyId: this.strategyId || "NAVIGATION_STRATEGY-ELO-default",
|
|
1858
1886
|
action: "generated",
|
|
1859
|
-
score:
|
|
1860
|
-
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}),
|
|
1887
|
+
score: jitter,
|
|
1888
|
+
reason: `new card near learner ELO: distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}), jitter ${jitter.toFixed(3)}`
|
|
1861
1889
|
}
|
|
1862
1890
|
]
|
|
1863
1891
|
};
|
|
@@ -2733,43 +2761,132 @@ var init_prescribed = __esm({
|
|
|
2733
2761
|
}
|
|
2734
2762
|
});
|
|
2735
2763
|
|
|
2764
|
+
// src/core/navigators/regulators.ts
|
|
2765
|
+
var regulators_exports = {};
|
|
2766
|
+
__export(regulators_exports, {
|
|
2767
|
+
DEFAULT_REGULATOR_CONFIG: () => DEFAULT_REGULATOR_CONFIG,
|
|
2768
|
+
INTAKE_CLOCK_KEY: () => INTAKE_CLOCK_KEY,
|
|
2769
|
+
applyReading: () => applyReading,
|
|
2770
|
+
frozenMsAt: () => frozenMsAt,
|
|
2771
|
+
intakeHours: () => intakeHours,
|
|
2772
|
+
intakeReading: () => intakeReading,
|
|
2773
|
+
resetIntakeClock: () => resetIntakeClock,
|
|
2774
|
+
reviewMassReading: () => reviewMassReading,
|
|
2775
|
+
reviewWeight: () => reviewWeight,
|
|
2776
|
+
stepIntakeClock: () => stepIntakeClock
|
|
2777
|
+
});
|
|
2778
|
+
function clamp01(x) {
|
|
2779
|
+
return Math.min(1, Math.max(0, x));
|
|
2780
|
+
}
|
|
2781
|
+
function reviewWeight(card, generatedScore, referenceScore) {
|
|
2782
|
+
if (card.reviewUrgency !== void 0 && generatedScore !== void 0 && generatedScore > 0) {
|
|
2783
|
+
return clamp01(card.reviewUrgency * (card.score / generatedScore));
|
|
2784
|
+
}
|
|
2785
|
+
return clamp01(card.score / referenceScore);
|
|
2786
|
+
}
|
|
2787
|
+
function reviewMassReading(reviews, generatedScores, config = DEFAULT_REGULATOR_CONFIG.reviewMass) {
|
|
2788
|
+
const mass = reviews.reduce(
|
|
2789
|
+
(m, c) => m + reviewWeight(c, generatedScores.get(c.cardId), config.referenceScore),
|
|
2790
|
+
0
|
|
2791
|
+
);
|
|
2792
|
+
const multiplier = mass > config.healthyMass ? Math.pow(config.rate, (mass - config.healthyMass) / config.healthyMass) : 1;
|
|
2793
|
+
return {
|
|
2794
|
+
name: "review-mass",
|
|
2795
|
+
class: "review",
|
|
2796
|
+
urgency: mass,
|
|
2797
|
+
multiplier,
|
|
2798
|
+
applied: reviews.length,
|
|
2799
|
+
inputs: { due: reviews.length, mass, healthyMass: config.healthyMass }
|
|
2800
|
+
};
|
|
2801
|
+
}
|
|
2802
|
+
function resetIntakeClock(nowMs) {
|
|
2803
|
+
return { lastNewAt: new Date(nowMs).toISOString(), frozenMs: 0, unservableSince: null };
|
|
2804
|
+
}
|
|
2805
|
+
function frozenMsAt(state, nowMs) {
|
|
2806
|
+
const open = state.unservableSince ? Math.max(0, nowMs - Date.parse(state.unservableSince)) : 0;
|
|
2807
|
+
return state.frozenMs + open;
|
|
2808
|
+
}
|
|
2809
|
+
function intakeHours(state, nowMs) {
|
|
2810
|
+
const elapsed = nowMs - Date.parse(state.lastNewAt);
|
|
2811
|
+
return Math.max(0, elapsed - frozenMsAt(state, nowMs)) / 36e5;
|
|
2812
|
+
}
|
|
2813
|
+
function stepIntakeClock(state, nowMs, eligibleNew) {
|
|
2814
|
+
if (eligibleNew === 0 && !state.unservableSince) {
|
|
2815
|
+
return { ...state, unservableSince: new Date(nowMs).toISOString() };
|
|
2816
|
+
}
|
|
2817
|
+
if (eligibleNew > 0 && state.unservableSince) {
|
|
2818
|
+
return { ...state, frozenMs: frozenMsAt(state, nowMs), unservableSince: null };
|
|
2819
|
+
}
|
|
2820
|
+
return state;
|
|
2821
|
+
}
|
|
2822
|
+
function intakeReading(state, nowMs, counts, config = DEFAULT_REGULATOR_CONFIG.intake) {
|
|
2823
|
+
const hours = intakeHours(state, nowMs);
|
|
2824
|
+
const multiplier = counts.eligibleNew > 0 ? Math.pow(config.rate, hours / config.scaleHours) : 1;
|
|
2825
|
+
return {
|
|
2826
|
+
name: "intake",
|
|
2827
|
+
class: "new",
|
|
2828
|
+
urgency: hours,
|
|
2829
|
+
multiplier,
|
|
2830
|
+
applied: counts.eligibleNew,
|
|
2831
|
+
inputs: {
|
|
2832
|
+
hoursSinceNew: hours,
|
|
2833
|
+
frozenHours: frozenMsAt(state, nowMs) / 36e5,
|
|
2834
|
+
eligibleNew: counts.eligibleNew,
|
|
2835
|
+
newCandidates: counts.newCandidates
|
|
2836
|
+
}
|
|
2837
|
+
};
|
|
2838
|
+
}
|
|
2839
|
+
function applyReading(cards, reading) {
|
|
2840
|
+
if (reading.multiplier === 1) return;
|
|
2841
|
+
const reason = reading.name === "review-mass" ? `review mass ${reading.urgency.toFixed(1)} (healthy ${reading.inputs.healthyMass}) \u2192 \xD7${reading.multiplier.toFixed(2)}` : `${reading.urgency.toFixed(1)}h since a new card \u2192 \xD7${reading.multiplier.toFixed(2)}`;
|
|
2842
|
+
for (const card of cards) {
|
|
2843
|
+
card.score *= reading.multiplier;
|
|
2844
|
+
card.provenance.push({
|
|
2845
|
+
strategy: "regulator",
|
|
2846
|
+
strategyName: `Regulator: ${REGULATOR_LABEL[reading.name]}`,
|
|
2847
|
+
strategyId: `regulator-${reading.name}`,
|
|
2848
|
+
action: reading.multiplier > 1 ? "boosted" : "penalized",
|
|
2849
|
+
score: card.score,
|
|
2850
|
+
reason
|
|
2851
|
+
});
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
var DEFAULT_REGULATOR_CONFIG, INTAKE_CLOCK_KEY, REGULATOR_LABEL;
|
|
2855
|
+
var init_regulators = __esm({
|
|
2856
|
+
"src/core/navigators/regulators.ts"() {
|
|
2857
|
+
"use strict";
|
|
2858
|
+
DEFAULT_REGULATOR_CONFIG = {
|
|
2859
|
+
reviewMass: { referenceScore: 0.95, healthyMass: 20, rate: 2 },
|
|
2860
|
+
intake: { rate: 2, scaleHours: 24 }
|
|
2861
|
+
};
|
|
2862
|
+
INTAKE_CLOCK_KEY = "IntakeClock";
|
|
2863
|
+
REGULATOR_LABEL = {
|
|
2864
|
+
"review-mass": "Review mass",
|
|
2865
|
+
intake: "Intake"
|
|
2866
|
+
};
|
|
2867
|
+
}
|
|
2868
|
+
});
|
|
2869
|
+
|
|
2736
2870
|
// src/core/navigators/generators/srs.ts
|
|
2737
2871
|
var srs_exports = {};
|
|
2738
2872
|
__export(srs_exports, {
|
|
2739
2873
|
default: () => SRSNavigator
|
|
2740
2874
|
});
|
|
2741
|
-
var import_moment,
|
|
2875
|
+
var import_moment, SRSNavigator;
|
|
2742
2876
|
var init_srs = __esm({
|
|
2743
2877
|
"src/core/navigators/generators/srs.ts"() {
|
|
2744
2878
|
"use strict";
|
|
2745
2879
|
import_moment = __toESM(require("moment"), 1);
|
|
2746
2880
|
init_navigators();
|
|
2747
2881
|
init_SrsDebugger();
|
|
2882
|
+
init_regulators();
|
|
2748
2883
|
init_logger();
|
|
2749
|
-
DEFAULT_HEALTHY_BACKLOG = 20;
|
|
2750
|
-
BACKLOG_GROWTH_RATE = 2;
|
|
2751
2884
|
SRSNavigator = class extends ContentNavigator {
|
|
2752
2885
|
/** Human-readable name for CardGenerator interface */
|
|
2753
2886
|
name;
|
|
2754
|
-
/** Healthy backlog threshold - when exceeded, backlog pressure kicks in */
|
|
2755
|
-
healthyBacklog;
|
|
2756
2887
|
constructor(user, course, strategyData) {
|
|
2757
2888
|
super(user, course, strategyData);
|
|
2758
2889
|
this.name = strategyData?.name || "SRS";
|
|
2759
|
-
const config = this.parseConfig(strategyData?.serializedData);
|
|
2760
|
-
this.healthyBacklog = config.healthyBacklog ?? DEFAULT_HEALTHY_BACKLOG;
|
|
2761
|
-
}
|
|
2762
|
-
/**
|
|
2763
|
-
* Parse configuration from serialized JSON.
|
|
2764
|
-
*/
|
|
2765
|
-
parseConfig(serializedData) {
|
|
2766
|
-
if (!serializedData) return {};
|
|
2767
|
-
try {
|
|
2768
|
-
return JSON.parse(serializedData);
|
|
2769
|
-
} catch {
|
|
2770
|
-
logger.warn("[SRS] Failed to parse strategy config, using defaults");
|
|
2771
|
-
return {};
|
|
2772
|
-
}
|
|
2773
2890
|
}
|
|
2774
2891
|
/**
|
|
2775
2892
|
* Get review cards scored by urgency.
|
|
@@ -2777,7 +2894,6 @@ var init_srs = __esm({
|
|
|
2777
2894
|
* Score formula combines:
|
|
2778
2895
|
* - Relative overdueness: hoursOverdue / intervalHours
|
|
2779
2896
|
* - Interval recency: exponential decay favoring shorter intervals
|
|
2780
|
-
* - Backlog pressure: boost when due reviews exceed healthy threshold
|
|
2781
2897
|
*
|
|
2782
2898
|
* Cards not yet due are excluded (not scored as 0).
|
|
2783
2899
|
*
|
|
@@ -2814,7 +2930,6 @@ var init_srs = __esm({
|
|
|
2814
2930
|
}
|
|
2815
2931
|
}
|
|
2816
2932
|
}
|
|
2817
|
-
const backlogMultiplier = this.computeBacklogMultiplier(dueReviews.length);
|
|
2818
2933
|
const notDue = reviews.filter((r) => !now.isAfter(import_moment.default.utc(r.reviewTime)));
|
|
2819
2934
|
let nextDueIn = null;
|
|
2820
2935
|
if (notDue.length > 0) {
|
|
@@ -2825,9 +2940,8 @@ var init_srs = __esm({
|
|
|
2825
2940
|
nextDueIn = until.asHours() < 1 ? `${Math.round(until.asMinutes())}m` : until.asHours() < 24 ? `${Math.round(until.asHours())}h` : `${Math.round(until.asDays())}d`;
|
|
2826
2941
|
}
|
|
2827
2942
|
if (dueReviews.length > 0) {
|
|
2828
|
-
const pressureNote = backlogMultiplier > 1 ? ` [backlog pressure: \xD7${backlogMultiplier.toFixed(2)}]` : ` [healthy backlog]`;
|
|
2829
2943
|
logger.info(
|
|
2830
|
-
`[SRS] Course ${courseId}: ${dueReviews.length} reviews due now (of ${reviews.length} scheduled)
|
|
2944
|
+
`[SRS] Course ${courseId}: ${dueReviews.length} reviews due now (of ${reviews.length} scheduled)`
|
|
2831
2945
|
);
|
|
2832
2946
|
} else if (reviews.length > 0) {
|
|
2833
2947
|
const sortedByDue = [...reviews].sort(
|
|
@@ -2844,11 +2958,12 @@ var init_srs = __esm({
|
|
|
2844
2958
|
logger.info(`[SRS] Course ${courseId}: No reviews scheduled`);
|
|
2845
2959
|
}
|
|
2846
2960
|
const scored = dueReviews.map((review) => {
|
|
2847
|
-
const { score, reason } = this.computeUrgencyScore(review, now
|
|
2961
|
+
const { score, urgency, reason } = this.computeUrgencyScore(review, now);
|
|
2848
2962
|
return {
|
|
2849
2963
|
cardId: review.cardId,
|
|
2850
2964
|
courseId: review.courseId,
|
|
2851
2965
|
score,
|
|
2966
|
+
reviewUrgency: urgency,
|
|
2852
2967
|
reviewID: review._id,
|
|
2853
2968
|
provenance: [
|
|
2854
2969
|
{
|
|
@@ -2867,47 +2982,20 @@ var init_srs = __esm({
|
|
|
2867
2982
|
courseId,
|
|
2868
2983
|
scheduledTotal: reviews.length,
|
|
2869
2984
|
dueNow: dueReviews.length,
|
|
2870
|
-
healthyBacklog:
|
|
2871
|
-
|
|
2872
|
-
|
|
2985
|
+
healthyBacklog: DEFAULT_REGULATOR_CONFIG.reviewMass.healthyMass,
|
|
2986
|
+
reviewMass: null,
|
|
2987
|
+
backlogMultiplier: 1,
|
|
2988
|
+
backlogGrowthRate: DEFAULT_REGULATOR_CONFIG.reviewMass.rate,
|
|
2873
2989
|
topReviewScore: sorted.length > 0 ? sorted[0].score : null,
|
|
2874
2990
|
nextDueIn,
|
|
2875
2991
|
timestamp: Date.now()
|
|
2876
2992
|
});
|
|
2877
2993
|
return { cards: sorted.slice(0, limit) };
|
|
2878
2994
|
}
|
|
2879
|
-
/**
|
|
2880
|
-
* Compute the multiplicative backlog pressure based on number of due reviews.
|
|
2881
|
-
*
|
|
2882
|
-
* ×1.0 at or below the healthy threshold (no boost); above it, grows as
|
|
2883
|
-
* BACKLOG_GROWTH_RATE raised to the excess expressed in multiples of the
|
|
2884
|
-
* healthy threshold. Uncapped — self-regulating instead: reviews winning
|
|
2885
|
-
* slots depletes dueCount, which drops the ratio and relaxes the multiplier
|
|
2886
|
-
* next run.
|
|
2887
|
-
*
|
|
2888
|
-
* Examples (with default healthyBacklog=20, BACKLOG_GROWTH_RATE=1.5):
|
|
2889
|
-
* - 10 due reviews → ×1.00 (healthy)
|
|
2890
|
-
* - 20 due reviews → ×1.00 (at threshold, ratio 0)
|
|
2891
|
-
* - 40 due reviews → ×1.50 (ratio 1, 2x threshold)
|
|
2892
|
-
* - 60 due reviews → ×2.25 (ratio 2, 3x threshold — old hard cap was ×2.00 here)
|
|
2893
|
-
* - 100 due reviews → ×5.06 (ratio 4, 5x threshold)
|
|
2894
|
-
* - 160 due reviews → ×17.09 (ratio 7, 8x threshold)
|
|
2895
|
-
*
|
|
2896
|
-
* @param dueCount - Number of reviews currently due
|
|
2897
|
-
* @returns Multiplier applied to review urgency (>= 1.0, unbounded)
|
|
2898
|
-
*/
|
|
2899
|
-
computeBacklogMultiplier(dueCount) {
|
|
2900
|
-
if (dueCount <= this.healthyBacklog) {
|
|
2901
|
-
return 1;
|
|
2902
|
-
}
|
|
2903
|
-
const excess = dueCount - this.healthyBacklog;
|
|
2904
|
-
const ratio = excess / this.healthyBacklog;
|
|
2905
|
-
return Math.pow(BACKLOG_GROWTH_RATE, ratio);
|
|
2906
|
-
}
|
|
2907
2995
|
/**
|
|
2908
2996
|
* Compute urgency score for a review card.
|
|
2909
2997
|
*
|
|
2910
|
-
*
|
|
2998
|
+
* Two factors:
|
|
2911
2999
|
* 1. Relative overdueness = hoursOverdue / intervalHours
|
|
2912
3000
|
* - 2 days overdue on 3-day interval = 0.67 (urgent)
|
|
2913
3001
|
* - 2 days overdue on 180-day interval = 0.01 (not urgent)
|
|
@@ -2917,20 +3005,14 @@ var init_srs = __esm({
|
|
|
2917
3005
|
* - 30 days (720h) → ~0.56
|
|
2918
3006
|
* - 180 days → ~0.30
|
|
2919
3007
|
*
|
|
2920
|
-
*
|
|
2921
|
-
*
|
|
2922
|
-
*
|
|
2923
|
-
* Combined: (base 0.5 + urgency factors * 0.45) × backlog multiplier.
|
|
2924
|
-
* Per-card range before pressure: ~0.57–0.95. NOT clamped to 1.0 — under a
|
|
2925
|
-
* heavy backlog reviews scale onto the open scale to compete with (and exceed)
|
|
2926
|
-
* new cards; there's no ceiling at all now, so a bad enough backlog always
|
|
2927
|
-
* wins eventually — self-regulating because winning slots depletes dueCount.
|
|
3008
|
+
* Combined: base 0.5 + urgency factors * 0.45, so ~0.57–0.95 per card.
|
|
3009
|
+
* Backlog pressure is applied later, by the regulator stage, which can lift
|
|
3010
|
+
* reviews onto the open scale above new cards (see regulators.ts).
|
|
2928
3011
|
*
|
|
2929
3012
|
* @param review - The scheduled card to score
|
|
2930
3013
|
* @param now - Current time
|
|
2931
|
-
* @param backlogMultiplier - Pre-computed backlog multiplier (>= 1.0, unbounded)
|
|
2932
3014
|
*/
|
|
2933
|
-
computeUrgencyScore(review, now
|
|
3015
|
+
computeUrgencyScore(review, now) {
|
|
2934
3016
|
const scheduledAt = import_moment.default.utc(review.scheduledAt);
|
|
2935
3017
|
const due = import_moment.default.utc(review.reviewTime);
|
|
2936
3018
|
const intervalHours = Math.max(1, due.diff(scheduledAt, "hours"));
|
|
@@ -2939,20 +3021,16 @@ var init_srs = __esm({
|
|
|
2939
3021
|
const recencyFactor = 0.3 + 0.7 * Math.exp(-intervalHours / 720);
|
|
2940
3022
|
const overdueContribution = Math.min(1, Math.max(0, relativeOverdue));
|
|
2941
3023
|
const urgency = overdueContribution * 0.5 + recencyFactor * 0.5;
|
|
2942
|
-
const
|
|
2943
|
-
const score = baseScore * backlogMultiplier;
|
|
3024
|
+
const score = 0.5 + urgency * 0.45;
|
|
2944
3025
|
const reasonParts = [
|
|
2945
3026
|
`${Math.round(hoursOverdue)}h overdue`,
|
|
2946
3027
|
`interval: ${Math.round(intervalHours)}h`,
|
|
2947
3028
|
`relative: ${relativeOverdue.toFixed(2)}`,
|
|
2948
3029
|
`recency: ${recencyFactor.toFixed(2)}`
|
|
2949
3030
|
];
|
|
2950
|
-
if (backlogMultiplier > 1) {
|
|
2951
|
-
reasonParts.push(`backlog: \xD7${backlogMultiplier.toFixed(2)}`);
|
|
2952
|
-
}
|
|
2953
3031
|
reasonParts.push("review");
|
|
2954
3032
|
const reason = reasonParts.join(", ");
|
|
2955
|
-
return { score, reason };
|
|
3033
|
+
return { score, urgency, reason };
|
|
2956
3034
|
}
|
|
2957
3035
|
};
|
|
2958
3036
|
}
|
|
@@ -3007,6 +3085,8 @@ var init_WeightedFilter = __esm({
|
|
|
3007
3085
|
init_contentNavigationStrategy();
|
|
3008
3086
|
WeightedFilter = class {
|
|
3009
3087
|
name;
|
|
3088
|
+
kind;
|
|
3089
|
+
liveOnly;
|
|
3010
3090
|
inner;
|
|
3011
3091
|
learnable;
|
|
3012
3092
|
staticWeight;
|
|
@@ -3014,6 +3094,8 @@ var init_WeightedFilter = __esm({
|
|
|
3014
3094
|
constructor(inner, learnable = DEFAULT_LEARNABLE_WEIGHT, staticWeight = false, strategyId) {
|
|
3015
3095
|
this.inner = inner;
|
|
3016
3096
|
this.name = inner.name;
|
|
3097
|
+
this.kind = inner.kind;
|
|
3098
|
+
this.liveOnly = inner.liveOnly;
|
|
3017
3099
|
this.learnable = learnable;
|
|
3018
3100
|
this.staticWeight = staticWeight;
|
|
3019
3101
|
this.strategyId = strategyId;
|
|
@@ -3078,58 +3160,141 @@ var init_WeightedFilter = __esm({
|
|
|
3078
3160
|
// src/core/navigators/filters/eloDistance.ts
|
|
3079
3161
|
var eloDistance_exports = {};
|
|
3080
3162
|
__export(eloDistance_exports, {
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3163
|
+
DEFAULT_ELO_DISTANCE_CONFIG: () => DEFAULT_ELO_DISTANCE_CONFIG,
|
|
3164
|
+
createEloDistanceFilter: () => createEloDistanceFilter,
|
|
3165
|
+
default: () => EloDistanceFilter,
|
|
3166
|
+
tagAwareGap: () => tagAwareGap
|
|
3085
3167
|
});
|
|
3086
3168
|
function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
|
|
3087
3169
|
const normalizedDistance = distance / halfLife;
|
|
3088
3170
|
const decay = Math.exp(-(normalizedDistance * normalizedDistance));
|
|
3089
3171
|
return minMultiplier + (maxMultiplier - minMultiplier) * decay;
|
|
3090
3172
|
}
|
|
3173
|
+
function resolveConfig(config) {
|
|
3174
|
+
return { ...DEFAULT_ELO_DISTANCE_CONFIG, ...config };
|
|
3175
|
+
}
|
|
3176
|
+
function tagAwareGap(cardTags, cardElo, userElo, minTagCount) {
|
|
3177
|
+
const globalGap = cardElo.global.score - userElo.global.score;
|
|
3178
|
+
const tags = [];
|
|
3179
|
+
for (const tag of cardTags) {
|
|
3180
|
+
const user = userElo.tags[tag];
|
|
3181
|
+
if (!user || user.score === COUNT_ONLY_SENTINEL || user.count < minTagCount) continue;
|
|
3182
|
+
const card = cardElo.tags[tag]?.score ?? cardElo.global.score;
|
|
3183
|
+
tags.push({
|
|
3184
|
+
tag,
|
|
3185
|
+
gap: card - user.score,
|
|
3186
|
+
weight: user.count / (user.count + TAG_CONFIDENCE_HALF)
|
|
3187
|
+
});
|
|
3188
|
+
}
|
|
3189
|
+
if (tags.length === 0) return { gap: globalGap, globalGap, tags };
|
|
3190
|
+
const total = tags.reduce((w, t) => w + t.weight, 0);
|
|
3191
|
+
const tagGap = tags.reduce((g, t) => g + t.weight * t.gap, 0) / total;
|
|
3192
|
+
const lambda = total / (total + 1);
|
|
3193
|
+
return { gap: lambda * tagGap + (1 - lambda) * globalGap, globalGap, tags };
|
|
3194
|
+
}
|
|
3195
|
+
function tagReason(tags, globalGap) {
|
|
3196
|
+
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(", ");
|
|
3197
|
+
const more = tags.length > 3 ? `, +${tags.length - 3} more` : "";
|
|
3198
|
+
return ` on ${tags.length} shared tag(s) [${shown}${more}] (global ${globalGap >= 0 ? "+" : ""}${Math.round(globalGap)})`;
|
|
3199
|
+
}
|
|
3200
|
+
async function applyEloDistance(cards, context, config, source) {
|
|
3201
|
+
const { course, userElo, userCourseElo } = context;
|
|
3202
|
+
const { halfLife, minMultiplier, maxMultiplier } = config;
|
|
3203
|
+
const tagAware = config.tagAware && userCourseElo !== void 0;
|
|
3204
|
+
const missing = cards.filter((c) => tagAware || c.cardElo === void 0).map((c) => c.cardId);
|
|
3205
|
+
const fetched = /* @__PURE__ */ new Map();
|
|
3206
|
+
if (missing.length > 0) {
|
|
3207
|
+
const elos = await course.getCardEloData(missing);
|
|
3208
|
+
missing.forEach((id, i) => {
|
|
3209
|
+
if (elos[i]) fetched.set(id, elos[i]);
|
|
3210
|
+
});
|
|
3211
|
+
}
|
|
3212
|
+
return cards.map((card) => {
|
|
3213
|
+
const full = fetched.get(card.cardId);
|
|
3214
|
+
const cardElo = full?.global?.score ?? card.cardElo ?? DEFAULT_CARD_ELO;
|
|
3215
|
+
let distance = Math.abs(cardElo - userElo);
|
|
3216
|
+
let how = "";
|
|
3217
|
+
if (tagAware && full) {
|
|
3218
|
+
const t = tagAwareGap(card.tags ?? [], full, userCourseElo, config.minTagCount);
|
|
3219
|
+
distance = Math.abs(t.gap);
|
|
3220
|
+
if (t.tags.length > 0) how = tagReason(t.tags, t.globalGap);
|
|
3221
|
+
}
|
|
3222
|
+
const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
|
|
3223
|
+
const newScore = card.score * multiplier;
|
|
3224
|
+
const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
|
|
3225
|
+
return {
|
|
3226
|
+
...card,
|
|
3227
|
+
cardElo,
|
|
3228
|
+
score: newScore,
|
|
3229
|
+
provenance: [
|
|
3230
|
+
...card.provenance,
|
|
3231
|
+
{
|
|
3232
|
+
strategy: "eloDistance",
|
|
3233
|
+
strategyName: source.name,
|
|
3234
|
+
strategyId: source.strategyId,
|
|
3235
|
+
action,
|
|
3236
|
+
score: newScore,
|
|
3237
|
+
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)})${how} \u2192 ${multiplier.toFixed(2)}x`
|
|
3238
|
+
}
|
|
3239
|
+
]
|
|
3240
|
+
};
|
|
3241
|
+
});
|
|
3242
|
+
}
|
|
3091
3243
|
function createEloDistanceFilter(config) {
|
|
3092
|
-
const
|
|
3093
|
-
const
|
|
3094
|
-
const maxMultiplier = config?.maxMultiplier ?? DEFAULT_MAX_MULTIPLIER;
|
|
3244
|
+
const resolved = resolveConfig(config);
|
|
3245
|
+
const source = { name: "ELO Distance Filter", strategyId: "ELO_DISTANCE_FILTER" };
|
|
3095
3246
|
return {
|
|
3096
|
-
name:
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
const cardElos = await course.getCardEloData(cardIds);
|
|
3101
|
-
return cards.map((card, i) => {
|
|
3102
|
-
const cardElo = cardElos[i]?.global?.score ?? 1e3;
|
|
3103
|
-
const distance = Math.abs(cardElo - userElo);
|
|
3104
|
-
const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
|
|
3105
|
-
const newScore = card.score * multiplier;
|
|
3106
|
-
const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
|
|
3107
|
-
return {
|
|
3108
|
-
...card,
|
|
3109
|
-
score: newScore,
|
|
3110
|
-
provenance: [
|
|
3111
|
-
...card.provenance,
|
|
3112
|
-
{
|
|
3113
|
-
strategy: "eloDistance",
|
|
3114
|
-
strategyName: "ELO Distance Filter",
|
|
3115
|
-
strategyId: "ELO_DISTANCE_FILTER",
|
|
3116
|
-
action,
|
|
3117
|
-
score: newScore,
|
|
3118
|
-
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)}) \u2192 ${multiplier.toFixed(2)}x`
|
|
3119
|
-
}
|
|
3120
|
-
]
|
|
3121
|
-
};
|
|
3122
|
-
});
|
|
3123
|
-
}
|
|
3247
|
+
name: source.name,
|
|
3248
|
+
kind: "signal",
|
|
3249
|
+
liveOnly: true,
|
|
3250
|
+
transform: (cards, context) => applyEloDistance(cards, context, resolved, source)
|
|
3124
3251
|
};
|
|
3125
3252
|
}
|
|
3126
|
-
var
|
|
3253
|
+
var DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, COUNT_ONLY_SENTINEL, DEFAULT_CARD_ELO, EloDistanceFilter;
|
|
3127
3254
|
var init_eloDistance = __esm({
|
|
3128
3255
|
"src/core/navigators/filters/eloDistance.ts"() {
|
|
3129
3256
|
"use strict";
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3257
|
+
init_navigators();
|
|
3258
|
+
DEFAULT_ELO_DISTANCE_CONFIG = {
|
|
3259
|
+
halfLife: 300,
|
|
3260
|
+
minMultiplier: 0.05,
|
|
3261
|
+
maxMultiplier: 1,
|
|
3262
|
+
tagAware: true,
|
|
3263
|
+
minTagCount: 3
|
|
3264
|
+
};
|
|
3265
|
+
TAG_CONFIDENCE_HALF = 10;
|
|
3266
|
+
COUNT_ONLY_SENTINEL = -1;
|
|
3267
|
+
DEFAULT_CARD_ELO = 1e3;
|
|
3268
|
+
EloDistanceFilter = class _EloDistanceFilter extends ContentNavigator {
|
|
3269
|
+
name;
|
|
3270
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3271
|
+
static kind = "signal";
|
|
3272
|
+
kind = _EloDistanceFilter.kind;
|
|
3273
|
+
liveOnly = true;
|
|
3274
|
+
config;
|
|
3275
|
+
constructor(user, course, strategyData) {
|
|
3276
|
+
super(user, course, strategyData);
|
|
3277
|
+
this.name = strategyData.name || "ELO Distance";
|
|
3278
|
+
let parsed;
|
|
3279
|
+
try {
|
|
3280
|
+
parsed = strategyData.serializedData ? JSON.parse(strategyData.serializedData) : void 0;
|
|
3281
|
+
} catch {
|
|
3282
|
+
parsed = void 0;
|
|
3283
|
+
}
|
|
3284
|
+
this.config = resolveConfig(parsed);
|
|
3285
|
+
}
|
|
3286
|
+
transform(cards, context) {
|
|
3287
|
+
return applyEloDistance(cards, context, this.config, {
|
|
3288
|
+
name: this.name,
|
|
3289
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-eloDistance-default"
|
|
3290
|
+
});
|
|
3291
|
+
}
|
|
3292
|
+
async getWeightedCards(_limit) {
|
|
3293
|
+
throw new Error(
|
|
3294
|
+
"EloDistanceFilter is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
|
|
3295
|
+
);
|
|
3296
|
+
}
|
|
3297
|
+
};
|
|
3133
3298
|
}
|
|
3134
3299
|
});
|
|
3135
3300
|
|
|
@@ -3146,10 +3311,13 @@ var init_hierarchyDefinition = __esm({
|
|
|
3146
3311
|
import_common6 = require("@vue-skuilder/common");
|
|
3147
3312
|
init_logger();
|
|
3148
3313
|
DEFAULT_MIN_COUNT2 = 3;
|
|
3149
|
-
HierarchyDefinitionNavigator = class extends ContentNavigator {
|
|
3314
|
+
HierarchyDefinitionNavigator = class _HierarchyDefinitionNavigator extends ContentNavigator {
|
|
3150
3315
|
config;
|
|
3151
3316
|
/** Human-readable name for CardFilter interface */
|
|
3152
3317
|
name;
|
|
3318
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3319
|
+
static kind = "gate";
|
|
3320
|
+
kind = _HierarchyDefinitionNavigator.kind;
|
|
3153
3321
|
constructor(user, course, strategyData) {
|
|
3154
3322
|
super(user, course, strategyData);
|
|
3155
3323
|
this.config = this.parseConfig(strategyData.serializedData);
|
|
@@ -3416,10 +3584,13 @@ var init_userTagPreference = __esm({
|
|
|
3416
3584
|
"src/core/navigators/filters/userTagPreference.ts"() {
|
|
3417
3585
|
"use strict";
|
|
3418
3586
|
init_navigators();
|
|
3419
|
-
UserTagPreferenceFilter = class extends ContentNavigator {
|
|
3587
|
+
UserTagPreferenceFilter = class _UserTagPreferenceFilter extends ContentNavigator {
|
|
3420
3588
|
_strategyData;
|
|
3421
3589
|
/** Human-readable name for CardFilter interface */
|
|
3422
3590
|
name;
|
|
3591
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3592
|
+
static kind = "signal";
|
|
3593
|
+
kind = _UserTagPreferenceFilter.kind;
|
|
3423
3594
|
constructor(user, course, strategyData) {
|
|
3424
3595
|
super(user, course, strategyData);
|
|
3425
3596
|
this._strategyData = strategyData;
|
|
@@ -3529,6 +3700,7 @@ var init_userTagPreference = __esm({
|
|
|
3529
3700
|
// src/core/navigators/filters/index.ts
|
|
3530
3701
|
var filters_exports = {};
|
|
3531
3702
|
__export(filters_exports, {
|
|
3703
|
+
EloDistanceFilter: () => EloDistanceFilter,
|
|
3532
3704
|
UserTagPreferenceFilter: () => UserTagPreferenceFilter,
|
|
3533
3705
|
createEloDistanceFilter: () => createEloDistanceFilter
|
|
3534
3706
|
});
|
|
@@ -3567,10 +3739,13 @@ var init_interferenceMitigator = __esm({
|
|
|
3567
3739
|
DEFAULT_MIN_COUNT3 = 10;
|
|
3568
3740
|
DEFAULT_MIN_ELAPSED_DAYS = 3;
|
|
3569
3741
|
DEFAULT_INTERFERENCE_DECAY = 0.8;
|
|
3570
|
-
InterferenceMitigatorNavigator = class extends ContentNavigator {
|
|
3742
|
+
InterferenceMitigatorNavigator = class _InterferenceMitigatorNavigator extends ContentNavigator {
|
|
3571
3743
|
config;
|
|
3572
3744
|
/** Human-readable name for CardFilter interface */
|
|
3573
3745
|
name;
|
|
3746
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3747
|
+
static kind = "signal";
|
|
3748
|
+
kind = _InterferenceMitigatorNavigator.kind;
|
|
3574
3749
|
/** Precomputed map: tag -> set of { partner, decay } it interferes with */
|
|
3575
3750
|
interferenceMap;
|
|
3576
3751
|
constructor(user, course, strategyData) {
|
|
@@ -3786,10 +3961,13 @@ var init_relativePriority = __esm({
|
|
|
3786
3961
|
DEFAULT_PRIORITY = 0.5;
|
|
3787
3962
|
DEFAULT_PRIORITY_INFLUENCE = 0.5;
|
|
3788
3963
|
DEFAULT_COMBINE_MODE = "max";
|
|
3789
|
-
RelativePriorityNavigator = class extends ContentNavigator {
|
|
3964
|
+
RelativePriorityNavigator = class _RelativePriorityNavigator extends ContentNavigator {
|
|
3790
3965
|
config;
|
|
3791
3966
|
/** Human-readable name for CardFilter interface */
|
|
3792
3967
|
name;
|
|
3968
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3969
|
+
static kind = "signal";
|
|
3970
|
+
kind = _RelativePriorityNavigator.kind;
|
|
3793
3971
|
constructor(user, course, strategyData) {
|
|
3794
3972
|
super(user, course, strategyData);
|
|
3795
3973
|
this.config = this.parseConfig(strategyData.serializedData);
|
|
@@ -4443,6 +4621,8 @@ var init_Pipeline = __esm({
|
|
|
4443
4621
|
init_orchestration();
|
|
4444
4622
|
init_PipelineDebugger();
|
|
4445
4623
|
init_diversityRerank();
|
|
4624
|
+
init_regulators();
|
|
4625
|
+
init_SrsDebugger();
|
|
4446
4626
|
VERBOSE_RESULTS = true;
|
|
4447
4627
|
Pipeline = class extends ContentNavigator {
|
|
4448
4628
|
generator;
|
|
@@ -4468,6 +4648,13 @@ var init_Pipeline = __esm({
|
|
|
4468
4648
|
* getWeightedCards() call, then cleared.
|
|
4469
4649
|
*/
|
|
4470
4650
|
_ephemeralHints = null;
|
|
4651
|
+
/**
|
|
4652
|
+
* The intake valve's clock (see regulators.ts), loaded from strategy state on
|
|
4653
|
+
* first use and kept in memory. Writes are chained so a presentation and a
|
|
4654
|
+
* run can't race each other's revision.
|
|
4655
|
+
*/
|
|
4656
|
+
_intakeClock = null;
|
|
4657
|
+
_intakeClockWrite = Promise.resolve();
|
|
4471
4658
|
/**
|
|
4472
4659
|
* Create a new pipeline.
|
|
4473
4660
|
*
|
|
@@ -4542,13 +4729,12 @@ var init_Pipeline = __esm({
|
|
|
4542
4729
|
}
|
|
4543
4730
|
}
|
|
4544
4731
|
generatorSummaries = Array.from(genMap.entries()).map(([name, data]) => {
|
|
4545
|
-
const
|
|
4546
|
-
const reviewCards = data.cards.filter((c) => c.provenance[0]?.reason?.includes("review"));
|
|
4732
|
+
const reviewCount = data.cards.filter((c) => c.reviewID).length;
|
|
4547
4733
|
return {
|
|
4548
4734
|
name,
|
|
4549
4735
|
cardCount: data.cards.length,
|
|
4550
|
-
newCount:
|
|
4551
|
-
reviewCount
|
|
4736
|
+
newCount: data.cards.length - reviewCount,
|
|
4737
|
+
reviewCount,
|
|
4552
4738
|
topScore: Math.max(...data.cards.map((c) => c.score), 0)
|
|
4553
4739
|
};
|
|
4554
4740
|
});
|
|
@@ -4584,19 +4770,24 @@ var init_Pipeline = __esm({
|
|
|
4584
4770
|
cards.filter((c) => c.provenance.some((p) => p.strategy === "prescribed")).map((c) => c.cardId)
|
|
4585
4771
|
);
|
|
4586
4772
|
const filterImpacts = [];
|
|
4773
|
+
const generatedScores = new Map(cards.map((c) => [c.cardId, c.score]));
|
|
4774
|
+
const gated = /* @__PURE__ */ new Set();
|
|
4587
4775
|
for (const filter of this.filters) {
|
|
4588
4776
|
const beforeCount = cards.length;
|
|
4589
4777
|
const beforeScores = new Map(cards.map((c) => [c.cardId, c.score]));
|
|
4590
4778
|
cards = await filter.transform(cards, context);
|
|
4591
4779
|
let boosted = 0, penalized = 0, passed = 0;
|
|
4592
4780
|
const removed = beforeCount - cards.length;
|
|
4781
|
+
const kind = filter.kind ?? "gate";
|
|
4593
4782
|
for (const card of cards) {
|
|
4594
4783
|
const before = beforeScores.get(card.cardId) ?? 0;
|
|
4595
4784
|
if (card.score > before) boosted++;
|
|
4596
|
-
else if (card.score < before)
|
|
4597
|
-
|
|
4785
|
+
else if (card.score < before) {
|
|
4786
|
+
penalized++;
|
|
4787
|
+
if (kind === "gate") gated.add(card.cardId);
|
|
4788
|
+
} else passed++;
|
|
4598
4789
|
}
|
|
4599
|
-
filterImpacts.push({ name: filter.name, boosted, penalized, passed, removed });
|
|
4790
|
+
filterImpacts.push({ name: filter.name, kind, boosted, penalized, passed, removed });
|
|
4600
4791
|
if (prescribedIds.size > 0) {
|
|
4601
4792
|
const survivingIds = new Set(cards.map((c) => c.cardId));
|
|
4602
4793
|
const killedPrescribed = [...prescribedIds].filter((id) => !survivingIds.has(id));
|
|
@@ -4610,7 +4801,9 @@ var init_Pipeline = __esm({
|
|
|
4610
4801
|
}
|
|
4611
4802
|
logger.debug(`[Pipeline] Filter '${filter.name}': ${beforeScores.size} \u2192 ${cards.length} cards (\u2191${boosted} \u2193${penalized} =${passed})`);
|
|
4612
4803
|
}
|
|
4804
|
+
const scoredCards = cards;
|
|
4613
4805
|
cards = cards.filter((c) => c.score > 0);
|
|
4806
|
+
const regulators = await this.regulate(cards, generatedScores, gated);
|
|
4614
4807
|
const hints = this._ephemeralHints;
|
|
4615
4808
|
if (hints) {
|
|
4616
4809
|
this._ephemeralHints = null;
|
|
@@ -4646,7 +4839,9 @@ var init_Pipeline = __esm({
|
|
|
4646
4839
|
cards,
|
|
4647
4840
|
result,
|
|
4648
4841
|
context.userElo,
|
|
4649
|
-
hints ?? void 0
|
|
4842
|
+
hints ?? void 0,
|
|
4843
|
+
scoredCards,
|
|
4844
|
+
regulators
|
|
4650
4845
|
);
|
|
4651
4846
|
captureRun(report);
|
|
4652
4847
|
} catch (e) {
|
|
@@ -4825,6 +5020,77 @@ var init_Pipeline = __esm({
|
|
|
4825
5020
|
logger.info(`[Pipeline] Hints applied: ${beforeCount} \u2192 ${cards.length} cards`);
|
|
4826
5021
|
return cards;
|
|
4827
5022
|
}
|
|
5023
|
+
/**
|
|
5024
|
+
* The regulator stage: measure each class's pressure and scale it.
|
|
5025
|
+
*
|
|
5026
|
+
* - Review mass: every due review's SRS urgency times the filters' net
|
|
5027
|
+
* effect on it.
|
|
5028
|
+
* - Intake: servable hours since a new card was presented, applied only to
|
|
5029
|
+
* eligible new cards (no gate penalized them). With none eligible, the
|
|
5030
|
+
* clock freezes.
|
|
5031
|
+
*
|
|
5032
|
+
* Mutates `cards` in place; returns the readings for the run report.
|
|
5033
|
+
*/
|
|
5034
|
+
async regulate(cards, generatedScores, gated) {
|
|
5035
|
+
const config = DEFAULT_REGULATOR_CONFIG;
|
|
5036
|
+
const reviews = cards.filter((c) => c.reviewID);
|
|
5037
|
+
const newCards = cards.filter((c) => !c.reviewID);
|
|
5038
|
+
const eligibleNew = newCards.filter((c) => !gated.has(c.cardId));
|
|
5039
|
+
const mass = reviewMassReading(reviews, generatedScores, config.reviewMass);
|
|
5040
|
+
applyReading(reviews, mass);
|
|
5041
|
+
noteReviewPressure(this.course.getCourseID(), {
|
|
5042
|
+
mass: mass.urgency,
|
|
5043
|
+
healthyMass: config.reviewMass.healthyMass,
|
|
5044
|
+
rate: config.reviewMass.rate,
|
|
5045
|
+
multiplier: mass.multiplier
|
|
5046
|
+
});
|
|
5047
|
+
const now = Date.now();
|
|
5048
|
+
const clock = await this.loadIntakeClock(now);
|
|
5049
|
+
const stepped = stepIntakeClock(clock, now, eligibleNew.length);
|
|
5050
|
+
if (stepped !== clock) this.saveIntakeClock(stepped);
|
|
5051
|
+
const intake = intakeReading(
|
|
5052
|
+
stepped,
|
|
5053
|
+
now,
|
|
5054
|
+
{ eligibleNew: eligibleNew.length, newCandidates: newCards.length },
|
|
5055
|
+
config.intake
|
|
5056
|
+
);
|
|
5057
|
+
applyReading(eligibleNew, intake);
|
|
5058
|
+
logger.info(
|
|
5059
|
+
`[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)}`
|
|
5060
|
+
);
|
|
5061
|
+
return [mass, intake];
|
|
5062
|
+
}
|
|
5063
|
+
/**
|
|
5064
|
+
* A card was presented. A new card's first presentation discharges the
|
|
5065
|
+
* intake valve: its clock restarts. Called by the SessionController.
|
|
5066
|
+
*/
|
|
5067
|
+
notePresented(card) {
|
|
5068
|
+
if (card.status !== "new" || card.courseId !== this.course?.getCourseID()) return;
|
|
5069
|
+
this.saveIntakeClock(resetIntakeClock(Date.now()));
|
|
5070
|
+
}
|
|
5071
|
+
async loadIntakeClock(nowMs) {
|
|
5072
|
+
if (this._intakeClock) return this._intakeClock;
|
|
5073
|
+
let stored = null;
|
|
5074
|
+
try {
|
|
5075
|
+
stored = await this.user.getStrategyState(
|
|
5076
|
+
this.course.getCourseID(),
|
|
5077
|
+
INTAKE_CLOCK_KEY
|
|
5078
|
+
);
|
|
5079
|
+
} catch (e) {
|
|
5080
|
+
logger.warn(`[Pipeline:regulators] Could not read the intake clock: ${e}`);
|
|
5081
|
+
}
|
|
5082
|
+
if (stored) {
|
|
5083
|
+
this._intakeClock = stored;
|
|
5084
|
+
} else {
|
|
5085
|
+
this.saveIntakeClock(resetIntakeClock(nowMs));
|
|
5086
|
+
}
|
|
5087
|
+
return this._intakeClock;
|
|
5088
|
+
}
|
|
5089
|
+
saveIntakeClock(state) {
|
|
5090
|
+
this._intakeClock = state;
|
|
5091
|
+
const courseId = this.course.getCourseID();
|
|
5092
|
+
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}`));
|
|
5093
|
+
}
|
|
4828
5094
|
/**
|
|
4829
5095
|
* Build shared context for generator and filters.
|
|
4830
5096
|
*
|
|
@@ -4835,10 +5101,11 @@ var init_Pipeline = __esm({
|
|
|
4835
5101
|
*/
|
|
4836
5102
|
async buildContext() {
|
|
4837
5103
|
let userElo = 1e3;
|
|
5104
|
+
let userCourseElo;
|
|
4838
5105
|
try {
|
|
4839
5106
|
const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
|
|
4840
|
-
|
|
4841
|
-
userElo =
|
|
5107
|
+
userCourseElo = (0, import_common8.toCourseElo)(courseReg.elo);
|
|
5108
|
+
userElo = userCourseElo.global.score;
|
|
4842
5109
|
} catch (e) {
|
|
4843
5110
|
logger.debug(`[Pipeline] Could not get user ELO, using default: ${e}`);
|
|
4844
5111
|
}
|
|
@@ -4850,6 +5117,7 @@ var init_Pipeline = __esm({
|
|
|
4850
5117
|
user: this.user,
|
|
4851
5118
|
course: this.course,
|
|
4852
5119
|
userElo,
|
|
5120
|
+
...userCourseElo ? { userCourseElo } : {},
|
|
4853
5121
|
orchestration
|
|
4854
5122
|
};
|
|
4855
5123
|
}
|
|
@@ -4963,7 +5231,7 @@ var init_Pipeline = __esm({
|
|
|
4963
5231
|
cards = await this.hydrateTags(cards);
|
|
4964
5232
|
const fullPool = cards.slice();
|
|
4965
5233
|
const context = await this.buildContext();
|
|
4966
|
-
for (const filter of this.
|
|
5234
|
+
for (const filter of this.forecastFilters()) {
|
|
4967
5235
|
cards = await filter.transform(cards, context);
|
|
4968
5236
|
}
|
|
4969
5237
|
if (opts?.hints) {
|
|
@@ -4982,6 +5250,14 @@ var init_Pipeline = __esm({
|
|
|
4982
5250
|
cards.sort((a, b) => b.score - a.score);
|
|
4983
5251
|
return opts?.limit ? cards.slice(0, opts.limit) : cards;
|
|
4984
5252
|
}
|
|
5253
|
+
/**
|
|
5254
|
+
* The filters a forecast or card-space scan applies. Those start every card at
|
|
5255
|
+
* 1.0 without a generator, so they skip `liveOnly` filters (ELO distance),
|
|
5256
|
+
* which only make sense against generator scores.
|
|
5257
|
+
*/
|
|
5258
|
+
forecastFilters() {
|
|
5259
|
+
return this.filters.filter((f) => !f.liveOnly);
|
|
5260
|
+
}
|
|
4985
5261
|
/**
|
|
4986
5262
|
* Scan every card in the course through the filter chain and report
|
|
4987
5263
|
* how many are "well indicated" (score >= threshold) for the current user.
|
|
@@ -5003,7 +5279,7 @@ var init_Pipeline = __esm({
|
|
|
5003
5279
|
cards = await this.hydrateTags(cards);
|
|
5004
5280
|
const context = await this.buildContext();
|
|
5005
5281
|
const filterBreakdown = [];
|
|
5006
|
-
for (const filter of this.
|
|
5282
|
+
for (const filter of this.forecastFilters()) {
|
|
5007
5283
|
cards = await filter.transform(cards, context);
|
|
5008
5284
|
const wi = cards.filter((c) => c.score >= THRESHOLD).length;
|
|
5009
5285
|
filterBreakdown.push({ name: filter.name, wellIndicated: wi });
|
|
@@ -5067,6 +5343,7 @@ var init_Pipeline = __esm({
|
|
|
5067
5343
|
// src/core/navigators/defaults.ts
|
|
5068
5344
|
var defaults_exports = {};
|
|
5069
5345
|
__export(defaults_exports, {
|
|
5346
|
+
createDefaultEloDistanceStrategy: () => createDefaultEloDistanceStrategy,
|
|
5070
5347
|
createDefaultEloStrategy: () => createDefaultEloStrategy,
|
|
5071
5348
|
createDefaultPipeline: () => createDefaultPipeline,
|
|
5072
5349
|
createDefaultSrsStrategy: () => createDefaultSrsStrategy
|
|
@@ -5093,12 +5370,28 @@ function createDefaultSrsStrategy(courseId) {
|
|
|
5093
5370
|
serializedData: ""
|
|
5094
5371
|
};
|
|
5095
5372
|
}
|
|
5373
|
+
function createDefaultEloDistanceStrategy(courseId) {
|
|
5374
|
+
return {
|
|
5375
|
+
_id: "NAVIGATION_STRATEGY-eloDistance-default",
|
|
5376
|
+
docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
|
|
5377
|
+
name: "ELO Distance (default)",
|
|
5378
|
+
description: "Scales every candidate, new or review, by its distance from the learner's ELO",
|
|
5379
|
+
implementingClass: "eloDistance" /* ELO_DISTANCE */,
|
|
5380
|
+
course: courseId,
|
|
5381
|
+
// Explicit, though the filter would default to it anyway: views show what runs.
|
|
5382
|
+
serializedData: JSON.stringify(DEFAULT_ELO_DISTANCE_CONFIG)
|
|
5383
|
+
};
|
|
5384
|
+
}
|
|
5096
5385
|
function createDefaultPipeline(user, course) {
|
|
5097
5386
|
const courseId = course.getCourseID();
|
|
5098
5387
|
const eloNavigator = new ELONavigator(user, course, createDefaultEloStrategy(courseId));
|
|
5099
5388
|
const srsNavigator = new SRSNavigator(user, course, createDefaultSrsStrategy(courseId));
|
|
5100
5389
|
const compositeGenerator = new CompositeGenerator([eloNavigator, srsNavigator]);
|
|
5101
|
-
const eloDistanceFilter =
|
|
5390
|
+
const eloDistanceFilter = new EloDistanceFilter(
|
|
5391
|
+
user,
|
|
5392
|
+
course,
|
|
5393
|
+
createDefaultEloDistanceStrategy(courseId)
|
|
5394
|
+
);
|
|
5102
5395
|
return new Pipeline(compositeGenerator, [eloDistanceFilter], user, course);
|
|
5103
5396
|
}
|
|
5104
5397
|
var init_defaults = __esm({
|
|
@@ -5114,6 +5407,131 @@ var init_defaults = __esm({
|
|
|
5114
5407
|
}
|
|
5115
5408
|
});
|
|
5116
5409
|
|
|
5410
|
+
// src/core/navigators/pipelinePlan.ts
|
|
5411
|
+
var pipelinePlan_exports = {};
|
|
5412
|
+
__export(pipelinePlan_exports, {
|
|
5413
|
+
PIPELINE_STAGES: () => PIPELINE_STAGES,
|
|
5414
|
+
planPipeline: () => planPipeline
|
|
5415
|
+
});
|
|
5416
|
+
function planned(strategy, role, origin) {
|
|
5417
|
+
const kind = role === "filter" /* FILTER */ ? getRegisteredFilterKind(strategy.implementingClass) : void 0;
|
|
5418
|
+
return {
|
|
5419
|
+
role,
|
|
5420
|
+
origin,
|
|
5421
|
+
name: strategy.name,
|
|
5422
|
+
implementingClass: strategy.implementingClass,
|
|
5423
|
+
strategy,
|
|
5424
|
+
...kind ? { kind } : {}
|
|
5425
|
+
};
|
|
5426
|
+
}
|
|
5427
|
+
function planPipeline(strategies, courseId) {
|
|
5428
|
+
if (strategies.length === 0) {
|
|
5429
|
+
return {
|
|
5430
|
+
kind: "default",
|
|
5431
|
+
generators: [
|
|
5432
|
+
planned(createDefaultEloStrategy(courseId), "generator" /* GENERATOR */, "default-pipeline"),
|
|
5433
|
+
planned(createDefaultSrsStrategy(courseId), "generator" /* GENERATOR */, "default-pipeline")
|
|
5434
|
+
],
|
|
5435
|
+
filters: [
|
|
5436
|
+
planned(
|
|
5437
|
+
createDefaultEloDistanceStrategy(courseId),
|
|
5438
|
+
"filter" /* FILTER */,
|
|
5439
|
+
"default-pipeline"
|
|
5440
|
+
)
|
|
5441
|
+
],
|
|
5442
|
+
skipped: [],
|
|
5443
|
+
warnings: [],
|
|
5444
|
+
notes: [],
|
|
5445
|
+
regulators: DEFAULT_REGULATOR_CONFIG
|
|
5446
|
+
};
|
|
5447
|
+
}
|
|
5448
|
+
const generators = [];
|
|
5449
|
+
const filters = [];
|
|
5450
|
+
const skipped = [];
|
|
5451
|
+
const warnings = [];
|
|
5452
|
+
for (const s of strategies) {
|
|
5453
|
+
if (isGenerator(s.implementingClass)) {
|
|
5454
|
+
generators.push(planned(s, "generator" /* GENERATOR */, "strategy-doc"));
|
|
5455
|
+
} else if (isFilter(s.implementingClass)) {
|
|
5456
|
+
filters.push(planned(s, "filter" /* FILTER */, "strategy-doc"));
|
|
5457
|
+
} else {
|
|
5458
|
+
skipped.push({ strategy: s, reason: "not a registered generator or filter" });
|
|
5459
|
+
warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
|
|
5460
|
+
}
|
|
5461
|
+
}
|
|
5462
|
+
const declared = new Set(generators.map((g) => g.implementingClass));
|
|
5463
|
+
if (!declared.has(createDefaultEloStrategy(courseId).implementingClass)) {
|
|
5464
|
+
generators.push(
|
|
5465
|
+
planned(createDefaultEloStrategy(courseId), "generator" /* GENERATOR */, "assembler-default")
|
|
5466
|
+
);
|
|
5467
|
+
}
|
|
5468
|
+
if (!declared.has(createDefaultSrsStrategy(courseId).implementingClass)) {
|
|
5469
|
+
generators.push(
|
|
5470
|
+
planned(createDefaultSrsStrategy(courseId), "generator" /* GENERATOR */, "assembler-default")
|
|
5471
|
+
);
|
|
5472
|
+
}
|
|
5473
|
+
const eloDistance = createDefaultEloDistanceStrategy(courseId);
|
|
5474
|
+
if (!filters.some((f) => f.implementingClass === eloDistance.implementingClass)) {
|
|
5475
|
+
filters.push(planned(eloDistance, "filter" /* FILTER */, "assembler-default"));
|
|
5476
|
+
}
|
|
5477
|
+
filters.sort((a, b) => a.name.localeCompare(b.name));
|
|
5478
|
+
return {
|
|
5479
|
+
kind: "assembled",
|
|
5480
|
+
generators,
|
|
5481
|
+
filters,
|
|
5482
|
+
skipped,
|
|
5483
|
+
warnings,
|
|
5484
|
+
notes: [],
|
|
5485
|
+
regulators: DEFAULT_REGULATOR_CONFIG
|
|
5486
|
+
};
|
|
5487
|
+
}
|
|
5488
|
+
var PIPELINE_STAGES;
|
|
5489
|
+
var init_pipelinePlan = __esm({
|
|
5490
|
+
"src/core/navigators/pipelinePlan.ts"() {
|
|
5491
|
+
"use strict";
|
|
5492
|
+
init_navigators();
|
|
5493
|
+
init_regulators();
|
|
5494
|
+
init_defaults();
|
|
5495
|
+
PIPELINE_STAGES = [
|
|
5496
|
+
{
|
|
5497
|
+
key: "generate",
|
|
5498
|
+
title: "Generate",
|
|
5499
|
+
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."
|
|
5500
|
+
},
|
|
5501
|
+
{
|
|
5502
|
+
key: "filter",
|
|
5503
|
+
title: "Filter",
|
|
5504
|
+
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."
|
|
5505
|
+
},
|
|
5506
|
+
{
|
|
5507
|
+
key: "drop-zero",
|
|
5508
|
+
title: "Drop zero scores",
|
|
5509
|
+
summary: "Candidates whose score reached 0 leave the pool."
|
|
5510
|
+
},
|
|
5511
|
+
{
|
|
5512
|
+
key: "regulate",
|
|
5513
|
+
title: "Regulate",
|
|
5514
|
+
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."
|
|
5515
|
+
},
|
|
5516
|
+
{
|
|
5517
|
+
key: "hints",
|
|
5518
|
+
title: "Apply hints",
|
|
5519
|
+
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."
|
|
5520
|
+
},
|
|
5521
|
+
{
|
|
5522
|
+
key: "diversity",
|
|
5523
|
+
title: "Diversity re-rank",
|
|
5524
|
+
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."
|
|
5525
|
+
},
|
|
5526
|
+
{
|
|
5527
|
+
key: "select",
|
|
5528
|
+
title: "Select",
|
|
5529
|
+
summary: "Highest scores first, up to the run's limit. The session mixes them into its supply queue."
|
|
5530
|
+
}
|
|
5531
|
+
];
|
|
5532
|
+
}
|
|
5533
|
+
});
|
|
5534
|
+
|
|
5117
5535
|
// src/core/navigators/PipelineAssembler.ts
|
|
5118
5536
|
var PipelineAssembler_exports = {};
|
|
5119
5537
|
__export(PipelineAssembler_exports, {
|
|
@@ -5128,16 +5546,16 @@ var init_PipelineAssembler = __esm({
|
|
|
5128
5546
|
init_Pipeline();
|
|
5129
5547
|
init_logger();
|
|
5130
5548
|
init_CompositeGenerator();
|
|
5131
|
-
|
|
5549
|
+
init_pipelinePlan();
|
|
5132
5550
|
PipelineAssembler = class {
|
|
5133
5551
|
/**
|
|
5134
5552
|
* Assembles a navigation pipeline from strategy documents.
|
|
5135
5553
|
*
|
|
5136
|
-
* 1.
|
|
5137
|
-
*
|
|
5138
|
-
*
|
|
5139
|
-
*
|
|
5140
|
-
*
|
|
5554
|
+
* 1. Plans: classifies by role, adds default ELO/SRS and ELO distance, orders filters
|
|
5555
|
+
* (`planPipeline`)
|
|
5556
|
+
* 2. Instantiates generators - wraps multiple in CompositeGenerator
|
|
5557
|
+
* 3. Instantiates filters
|
|
5558
|
+
* 4. Returns Pipeline(generator, filters)
|
|
5141
5559
|
*
|
|
5142
5560
|
* @param input - Strategy documents plus user/course interfaces
|
|
5143
5561
|
* @returns Assembled pipeline and any warnings
|
|
@@ -5153,28 +5571,17 @@ var init_PipelineAssembler = __esm({
|
|
|
5153
5571
|
warnings
|
|
5154
5572
|
};
|
|
5155
5573
|
}
|
|
5156
|
-
const
|
|
5157
|
-
|
|
5158
|
-
for (const
|
|
5159
|
-
if (
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
} else {
|
|
5164
|
-
warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
|
|
5574
|
+
const plan = planPipeline(strategies, course.getCourseID());
|
|
5575
|
+
warnings.push(...plan.warnings);
|
|
5576
|
+
for (const n of [...plan.generators, ...plan.filters]) {
|
|
5577
|
+
if (n.origin === "assembler-default") {
|
|
5578
|
+
logger.debug(
|
|
5579
|
+
`[PipelineAssembler] No ${n.implementingClass} ${n.role} configured, adding default`
|
|
5580
|
+
);
|
|
5165
5581
|
}
|
|
5166
5582
|
}
|
|
5167
|
-
const
|
|
5168
|
-
const
|
|
5169
|
-
const hasSrs = generatorStrategies.some((s) => s.implementingClass === "srs" /* SRS */);
|
|
5170
|
-
if (!hasElo) {
|
|
5171
|
-
logger.debug("[PipelineAssembler] No ELO generator configured, adding default");
|
|
5172
|
-
generatorStrategies.push(createDefaultEloStrategy(courseId));
|
|
5173
|
-
}
|
|
5174
|
-
if (!hasSrs) {
|
|
5175
|
-
logger.debug("[PipelineAssembler] No SRS generator configured, adding default");
|
|
5176
|
-
generatorStrategies.push(createDefaultSrsStrategy(courseId));
|
|
5177
|
-
}
|
|
5583
|
+
const generatorStrategies = plan.generators.map((g) => g.strategy);
|
|
5584
|
+
const sortedFilterStrategies = plan.filters.map((f) => f.strategy);
|
|
5178
5585
|
if (generatorStrategies.length === 0) {
|
|
5179
5586
|
warnings.push("No generator strategy found");
|
|
5180
5587
|
return {
|
|
@@ -5196,9 +5603,6 @@ var init_PipelineAssembler = __esm({
|
|
|
5196
5603
|
generator = await CompositeGenerator.fromStrategies(user, course, generatorStrategies);
|
|
5197
5604
|
}
|
|
5198
5605
|
const filters = [];
|
|
5199
|
-
const sortedFilterStrategies = [...filterStrategies].sort(
|
|
5200
|
-
(a, b) => a.name.localeCompare(b.name)
|
|
5201
|
-
);
|
|
5202
5606
|
for (const filterStrategy of sortedFilterStrategies) {
|
|
5203
5607
|
try {
|
|
5204
5608
|
const nav = await ContentNavigator.create(user, course, filterStrategy);
|
|
@@ -5266,7 +5670,9 @@ var init_3 = __esm({
|
|
|
5266
5670
|
"./generators/prescribed.ts": () => Promise.resolve().then(() => (init_prescribed(), prescribed_exports)),
|
|
5267
5671
|
"./generators/srs.ts": () => Promise.resolve().then(() => (init_srs(), srs_exports)),
|
|
5268
5672
|
"./generators/types.ts": () => Promise.resolve().then(() => (init_types(), types_exports)),
|
|
5269
|
-
"./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports))
|
|
5673
|
+
"./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports)),
|
|
5674
|
+
"./pipelinePlan.ts": () => Promise.resolve().then(() => (init_pipelinePlan(), pipelinePlan_exports)),
|
|
5675
|
+
"./regulators.ts": () => Promise.resolve().then(() => (init_regulators(), regulators_exports))
|
|
5270
5676
|
});
|
|
5271
5677
|
}
|
|
5272
5678
|
});
|
|
@@ -5287,6 +5693,7 @@ __export(navigators_exports, {
|
|
|
5287
5693
|
drainCapturedRuns: () => drainCapturedRuns,
|
|
5288
5694
|
getActivePipeline: () => getActivePipeline,
|
|
5289
5695
|
getCardOrigin: () => getCardOrigin,
|
|
5696
|
+
getRegisteredFilterKind: () => getRegisteredFilterKind,
|
|
5290
5697
|
getRegisteredNavigator: () => getRegisteredNavigator,
|
|
5291
5698
|
getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
|
|
5292
5699
|
getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
|
|
@@ -5315,6 +5722,10 @@ function hasRegisteredNavigator(implementingClass) {
|
|
|
5315
5722
|
function getRegisteredNavigatorRole(implementingClass) {
|
|
5316
5723
|
return navigatorRegistry.get(implementingClass)?.role;
|
|
5317
5724
|
}
|
|
5725
|
+
function getRegisteredFilterKind(implementingClass) {
|
|
5726
|
+
const ctor = navigatorRegistry.get(implementingClass)?.constructor;
|
|
5727
|
+
return ctor?.kind;
|
|
5728
|
+
}
|
|
5318
5729
|
function getRegisteredNavigatorNames() {
|
|
5319
5730
|
return Array.from(navigatorRegistry.keys());
|
|
5320
5731
|
}
|
|
@@ -5332,17 +5743,20 @@ async function initializeNavigatorRegistry() {
|
|
|
5332
5743
|
hierarchyModule,
|
|
5333
5744
|
interferenceModule,
|
|
5334
5745
|
relativePriorityModule,
|
|
5335
|
-
userTagPreferenceModule
|
|
5746
|
+
userTagPreferenceModule,
|
|
5747
|
+
eloDistanceModule
|
|
5336
5748
|
] = await Promise.all([
|
|
5337
5749
|
Promise.resolve().then(() => (init_hierarchyDefinition(), hierarchyDefinition_exports)),
|
|
5338
5750
|
Promise.resolve().then(() => (init_interferenceMitigator(), interferenceMitigator_exports)),
|
|
5339
5751
|
Promise.resolve().then(() => (init_relativePriority(), relativePriority_exports)),
|
|
5340
|
-
Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports))
|
|
5752
|
+
Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports)),
|
|
5753
|
+
Promise.resolve().then(() => (init_eloDistance(), eloDistance_exports))
|
|
5341
5754
|
]);
|
|
5342
5755
|
registerNavigator("hierarchyDefinition", hierarchyModule.default);
|
|
5343
5756
|
registerNavigator("interferenceMitigator", interferenceModule.default);
|
|
5344
5757
|
registerNavigator("relativePriority", relativePriorityModule.default);
|
|
5345
5758
|
registerNavigator("userTagPreference", userTagPreferenceModule.default);
|
|
5759
|
+
registerNavigator("eloDistance", eloDistanceModule.default);
|
|
5346
5760
|
logger.debug(
|
|
5347
5761
|
`[NavigatorRegistry] Initialized ${navigatorRegistry.size} navigators: ${getRegisteredNavigatorNames().join(", ")}`
|
|
5348
5762
|
);
|
|
@@ -5390,6 +5804,7 @@ var init_navigators = __esm({
|
|
|
5390
5804
|
Navigators2["INTERFERENCE"] = "interferenceMitigator";
|
|
5391
5805
|
Navigators2["RELATIVE_PRIORITY"] = "relativePriority";
|
|
5392
5806
|
Navigators2["USER_TAG_PREFERENCE"] = "userTagPreference";
|
|
5807
|
+
Navigators2["ELO_DISTANCE"] = "eloDistance";
|
|
5393
5808
|
return Navigators2;
|
|
5394
5809
|
})(Navigators || {});
|
|
5395
5810
|
NavigatorRole = /* @__PURE__ */ ((NavigatorRole2) => {
|
|
@@ -5404,7 +5819,8 @@ var init_navigators = __esm({
|
|
|
5404
5819
|
["hierarchyDefinition" /* HIERARCHY */]: "filter" /* FILTER */,
|
|
5405
5820
|
["interferenceMitigator" /* INTERFERENCE */]: "filter" /* FILTER */,
|
|
5406
5821
|
["relativePriority" /* RELATIVE_PRIORITY */]: "filter" /* FILTER */,
|
|
5407
|
-
["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER
|
|
5822
|
+
["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER */,
|
|
5823
|
+
["eloDistance" /* ELO_DISTANCE */]: "filter" /* FILTER */
|
|
5408
5824
|
};
|
|
5409
5825
|
ContentNavigator = class {
|
|
5410
5826
|
/** User interface for this navigation session */
|
|
@@ -6138,6 +6554,14 @@ ${e.stack}` : JSON.stringify(e);
|
|
|
6138
6554
|
setEphemeralHints(hints) {
|
|
6139
6555
|
this._pendingHints = hints;
|
|
6140
6556
|
}
|
|
6557
|
+
/**
|
|
6558
|
+
* Forward a presentation to the navigator (a new card restarts its intake
|
|
6559
|
+
* clock). Builds the navigator if the cached one has expired.
|
|
6560
|
+
*/
|
|
6561
|
+
notePresented(card) {
|
|
6562
|
+
if (card.status !== "new") return;
|
|
6563
|
+
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}`));
|
|
6564
|
+
}
|
|
6141
6565
|
async getWeightedCards(limit) {
|
|
6142
6566
|
const u = await this._getCurrentUser();
|
|
6143
6567
|
try {
|
|
@@ -8187,10 +8611,11 @@ function backlogHtml(backlog) {
|
|
|
8187
8611
|
const rows = backlog.map((b) => {
|
|
8188
8612
|
const hot = b.backlogMultiplier >= 3;
|
|
8189
8613
|
const multColor = b.backlogMultiplier <= 1 ? "#86efac" : hot ? "#fca5a5" : "#fcd34d";
|
|
8190
|
-
const headroom = b.backlogMultiplier > 1 ? `climbing (\xD7${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog}
|
|
8614
|
+
const headroom = b.backlogMultiplier > 1 ? `climbing (\xD7${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog} of mass in excess, unbounded)` : "healthy \u2014 no pressure";
|
|
8615
|
+
const mass = b.reviewMass !== null ? ` \xB7 mass ${b.reviewMass.toFixed(1)}` : "";
|
|
8191
8616
|
const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
|
|
8192
8617
|
const next = b.nextDueIn ? ` <span style="opacity:.6">\xB7 next due ${esc(b.nextDueIn)}</span>` : "";
|
|
8193
|
-
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>`;
|
|
8618
|
+
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>`;
|
|
8194
8619
|
}).join("");
|
|
8195
8620
|
return `<div style="margin-bottom:6px"><div style="color:#93c5fd">review backpressure</div>${rows}</div>`;
|
|
8196
8621
|
}
|
|
@@ -8329,8 +8754,9 @@ function snapshotToText(s) {
|
|
|
8329
8754
|
const headroom = b.backlogMultiplier > 1 ? "climbing" : "healthy";
|
|
8330
8755
|
const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
|
|
8331
8756
|
const next = b.nextDueIn ? `, next due ${b.nextDueIn}` : "";
|
|
8757
|
+
const mass = b.reviewMass !== null ? `, mass ${b.reviewMass.toFixed(1)}` : "";
|
|
8332
8758
|
lines.push(
|
|
8333
|
-
` ${b.courseId.slice(0, 8)}: due ${b.dueNow}/${b.scheduledTotal} (healthy ${b.healthyBacklog})${next}; pressure \xD7${b.backlogMultiplier.toFixed(2)} ${headroom}; top review ${top}`
|
|
8759
|
+
` ${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}`
|
|
8334
8760
|
);
|
|
8335
8761
|
}
|
|
8336
8762
|
}
|
|
@@ -10812,6 +11238,7 @@ __export(core_exports, {
|
|
|
10812
11238
|
getCardHistoryID: () => getCardHistoryID,
|
|
10813
11239
|
getCardOrigin: () => getCardOrigin,
|
|
10814
11240
|
getDefaultLearnableWeight: () => getDefaultLearnableWeight,
|
|
11241
|
+
getRegisteredFilterKind: () => getRegisteredFilterKind,
|
|
10815
11242
|
getRegisteredNavigator: () => getRegisteredNavigator,
|
|
10816
11243
|
getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
|
|
10817
11244
|
getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
|
|
@@ -10894,6 +11321,7 @@ init_core();
|
|
|
10894
11321
|
getCardHistoryID,
|
|
10895
11322
|
getCardOrigin,
|
|
10896
11323
|
getDefaultLearnableWeight,
|
|
11324
|
+
getRegisteredFilterKind,
|
|
10897
11325
|
getRegisteredNavigator,
|
|
10898
11326
|
getRegisteredNavigatorNames,
|
|
10899
11327
|
getRegisteredNavigatorRole,
|