@vue-skuilder/db 0.2.28 → 0.2.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{contentSource-DpQqTG3m.d.cts → contentSource-B6FrSihy.d.cts} +218 -2
- package/dist/{contentSource-BoFBwvYa.d.ts → contentSource-CqJmbOZN.d.ts} +218 -2
- package/dist/core/index.d.cts +13 -90
- package/dist/core/index.d.ts +13 -90
- package/dist/core/index.js +621 -179
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +620 -179
- package/dist/core/index.mjs.map +1 -1
- package/dist/{dataLayerProvider-D_LJT3F4.d.ts → dataLayerProvider-B9_UCvkR.d.ts} +1 -1
- package/dist/{dataLayerProvider-Dl3cAAvQ.d.cts → dataLayerProvider-DUxDqMtZ.d.cts} +1 -1
- package/dist/diagnostics/index.d.cts +79 -6
- package/dist/diagnostics/index.d.ts +79 -6
- package/dist/diagnostics/index.js +158 -4
- package/dist/diagnostics/index.js.map +1 -1
- package/dist/diagnostics/index.mjs +156 -4
- package/dist/diagnostics/index.mjs.map +1 -1
- package/dist/impl/couch/index.d.cts +11 -2
- package/dist/impl/couch/index.d.ts +11 -2
- package/dist/impl/couch/index.js +619 -179
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +619 -179
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.d.cts +8 -2
- package/dist/impl/static/index.d.ts +8 -2
- package/dist/impl/static/index.js +616 -179
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +616 -179
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/index.d.cts +66 -5
- package/dist/index.d.ts +66 -5
- package/dist/index.js +669 -180
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +656 -180
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/interfaces/contentSource.ts +7 -0
- package/src/core/navigators/Pipeline.ts +145 -13
- package/src/core/navigators/PipelineAssembler.ts +19 -40
- package/src/core/navigators/PipelineDebugger.ts +11 -2
- package/src/core/navigators/SrsDebugger.ts +37 -12
- package/src/core/navigators/defaults.ts +29 -5
- package/src/core/navigators/filters/WeightedFilter.ts +5 -1
- package/src/core/navigators/filters/eloDistance.ts +320 -76
- package/src/core/navigators/filters/hierarchyDefinition.ts +5 -1
- package/src/core/navigators/filters/index.ts +2 -2
- package/src/core/navigators/filters/interferenceMitigator.ts +5 -1
- package/src/core/navigators/filters/relativePriority.ts +5 -1
- package/src/core/navigators/filters/types.ts +24 -1
- package/src/core/navigators/filters/userTagPreference.ts +5 -1
- package/src/core/navigators/generators/elo.ts +23 -53
- package/src/core/navigators/generators/srs.ts +27 -124
- package/src/core/navigators/index.ts +31 -5
- package/src/core/navigators/pipelinePlan.ts +245 -0
- package/src/core/navigators/regulators.ts +230 -0
- package/src/core/types/studySession.ts +3 -0
- package/src/diagnostics/dataset.ts +13 -2
- package/src/diagnostics/index.ts +3 -0
- package/src/diagnostics/loader.ts +5 -2
- package/src/diagnostics/pipeline.ts +236 -0
- package/src/diagnostics/text.ts +26 -3
- package/src/impl/couch/courseDB.ts +13 -0
- package/src/impl/static/courseDB.ts +9 -0
- package/src/index.ts +4 -0
- package/src/study/SessionController.ts +20 -0
- package/src/study/SessionOverlay.ts +7 -4
- package/tests/core/navigators/PipelineAssembler.test.ts +20 -5
- package/tests/core/navigators/eloDistanceFilter.test.ts +9 -9
package/dist/impl/couch/index.js
CHANGED
|
@@ -798,7 +798,7 @@ function parseCardElo(provenance) {
|
|
|
798
798
|
const match = eloEntry.reason.match(/card:\s*(\d+)/);
|
|
799
799
|
return match ? parseInt(match[1], 10) : void 0;
|
|
800
800
|
}
|
|
801
|
-
function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints, scoredCards) {
|
|
801
|
+
function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints, scoredCards, regulators) {
|
|
802
802
|
const selectedIds = new Set(selectedCards.map((c) => c.cardId));
|
|
803
803
|
const toReport = (card) => ({
|
|
804
804
|
cardId: card.cardId,
|
|
@@ -806,7 +806,7 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
|
|
|
806
806
|
origin: getOrigin(card),
|
|
807
807
|
generator: card.provenance[0]?.strategyName || card.provenance[0]?.strategy,
|
|
808
808
|
finalScore: card.score,
|
|
809
|
-
cardElo: parseCardElo(card.provenance),
|
|
809
|
+
cardElo: card.cardElo ?? parseCardElo(card.provenance),
|
|
810
810
|
provenance: card.provenance,
|
|
811
811
|
tags: card.tags,
|
|
812
812
|
selected: selectedIds.has(card.cardId)
|
|
@@ -884,7 +884,8 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
|
|
|
884
884
|
newSelected,
|
|
885
885
|
cards,
|
|
886
886
|
unselectedNew,
|
|
887
|
-
discardedTail
|
|
887
|
+
discardedTail,
|
|
888
|
+
...regulators ? { regulators } : {}
|
|
888
889
|
};
|
|
889
890
|
}
|
|
890
891
|
function formatProvenance(provenance) {
|
|
@@ -1608,11 +1609,23 @@ var SrsDebugger_exports = {};
|
|
|
1608
1609
|
__export(SrsDebugger_exports, {
|
|
1609
1610
|
captureSrsBacklog: () => captureSrsBacklog,
|
|
1610
1611
|
clearSrsBacklogDebug: () => clearSrsBacklogDebug,
|
|
1611
|
-
getSrsBacklogDebug: () => getSrsBacklogDebug
|
|
1612
|
+
getSrsBacklogDebug: () => getSrsBacklogDebug,
|
|
1613
|
+
noteReviewPressure: () => noteReviewPressure
|
|
1612
1614
|
});
|
|
1613
1615
|
function captureSrsBacklog(snapshot) {
|
|
1614
1616
|
snapshots.set(snapshot.courseId, snapshot);
|
|
1615
1617
|
}
|
|
1618
|
+
function noteReviewPressure(courseId, pressure) {
|
|
1619
|
+
const snapshot = snapshots.get(courseId);
|
|
1620
|
+
if (!snapshot) return;
|
|
1621
|
+
snapshots.set(courseId, {
|
|
1622
|
+
...snapshot,
|
|
1623
|
+
reviewMass: pressure.mass,
|
|
1624
|
+
healthyBacklog: pressure.healthyMass,
|
|
1625
|
+
backlogGrowthRate: pressure.rate,
|
|
1626
|
+
backlogMultiplier: pressure.multiplier
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1616
1629
|
function getSrsBacklogDebug() {
|
|
1617
1630
|
return [...snapshots.values()].sort((a, b) => b.timestamp - a.timestamp);
|
|
1618
1631
|
}
|
|
@@ -1890,14 +1903,13 @@ var elo_exports = {};
|
|
|
1890
1903
|
__export(elo_exports, {
|
|
1891
1904
|
default: () => ELONavigator
|
|
1892
1905
|
});
|
|
1893
|
-
var import_common5,
|
|
1906
|
+
var import_common5, ELONavigator;
|
|
1894
1907
|
var init_elo = __esm({
|
|
1895
1908
|
"src/core/navigators/generators/elo.ts"() {
|
|
1896
1909
|
"use strict";
|
|
1897
1910
|
init_navigators();
|
|
1898
1911
|
import_common5 = require("@vue-skuilder/common");
|
|
1899
1912
|
init_logger();
|
|
1900
|
-
ELO_RELEVANCE_SIGMA = 300;
|
|
1901
1913
|
ELONavigator = class extends ContentNavigator {
|
|
1902
1914
|
/** Human-readable name for CardGenerator interface */
|
|
1903
1915
|
name;
|
|
@@ -1906,10 +1918,8 @@ var init_elo = __esm({
|
|
|
1906
1918
|
this.name = strategyData?.name || "ELO";
|
|
1907
1919
|
}
|
|
1908
1920
|
/**
|
|
1909
|
-
* Get new cards
|
|
1910
|
-
*
|
|
1911
|
-
* Cards closer to user's ELO get higher scores.
|
|
1912
|
-
* Score formula: max(0, 1 - distance / 500)
|
|
1921
|
+
* Get the new cards nearest the learner's ELO, each scored with a flat
|
|
1922
|
+
* jitter in [0.5, 1]. Carries each card's ELO for the ELO distance filter.
|
|
1913
1923
|
*
|
|
1914
1924
|
* NOTE: This generator only handles NEW cards. Reviews are handled by
|
|
1915
1925
|
* SRSNavigator. Use CompositeGenerator to combine both.
|
|
@@ -1937,20 +1947,20 @@ var init_elo = __esm({
|
|
|
1937
1947
|
const scored = newCards.map((c) => {
|
|
1938
1948
|
const cardElo = c.elo ?? 1e3;
|
|
1939
1949
|
const distance = Math.abs(cardElo - userGlobalElo);
|
|
1940
|
-
const
|
|
1941
|
-
const samplingKey = relevance * (0.5 + 0.5 * Math.random());
|
|
1950
|
+
const jitter = 0.5 + 0.5 * Math.random();
|
|
1942
1951
|
return {
|
|
1943
1952
|
cardId: c.cardID,
|
|
1944
1953
|
courseId: c.courseID,
|
|
1945
|
-
score:
|
|
1954
|
+
score: jitter,
|
|
1955
|
+
cardElo,
|
|
1946
1956
|
provenance: [
|
|
1947
1957
|
{
|
|
1948
1958
|
strategy: "elo",
|
|
1949
1959
|
strategyName: this.strategyName || this.name,
|
|
1950
1960
|
strategyId: this.strategyId || "NAVIGATION_STRATEGY-ELO-default",
|
|
1951
1961
|
action: "generated",
|
|
1952
|
-
score:
|
|
1953
|
-
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}),
|
|
1962
|
+
score: jitter,
|
|
1963
|
+
reason: `new card near learner ELO: distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}), jitter ${jitter.toFixed(3)}`
|
|
1954
1964
|
}
|
|
1955
1965
|
]
|
|
1956
1966
|
};
|
|
@@ -2826,43 +2836,132 @@ var init_prescribed = __esm({
|
|
|
2826
2836
|
}
|
|
2827
2837
|
});
|
|
2828
2838
|
|
|
2839
|
+
// src/core/navigators/regulators.ts
|
|
2840
|
+
var regulators_exports = {};
|
|
2841
|
+
__export(regulators_exports, {
|
|
2842
|
+
DEFAULT_REGULATOR_CONFIG: () => DEFAULT_REGULATOR_CONFIG,
|
|
2843
|
+
INTAKE_CLOCK_KEY: () => INTAKE_CLOCK_KEY,
|
|
2844
|
+
applyReading: () => applyReading,
|
|
2845
|
+
frozenMsAt: () => frozenMsAt,
|
|
2846
|
+
intakeHours: () => intakeHours,
|
|
2847
|
+
intakeReading: () => intakeReading,
|
|
2848
|
+
resetIntakeClock: () => resetIntakeClock,
|
|
2849
|
+
reviewMassReading: () => reviewMassReading,
|
|
2850
|
+
reviewWeight: () => reviewWeight,
|
|
2851
|
+
stepIntakeClock: () => stepIntakeClock
|
|
2852
|
+
});
|
|
2853
|
+
function clamp01(x) {
|
|
2854
|
+
return Math.min(1, Math.max(0, x));
|
|
2855
|
+
}
|
|
2856
|
+
function reviewWeight(card, generatedScore, referenceScore) {
|
|
2857
|
+
if (card.reviewUrgency !== void 0 && generatedScore !== void 0 && generatedScore > 0) {
|
|
2858
|
+
return clamp01(card.reviewUrgency * (card.score / generatedScore));
|
|
2859
|
+
}
|
|
2860
|
+
return clamp01(card.score / referenceScore);
|
|
2861
|
+
}
|
|
2862
|
+
function reviewMassReading(reviews, generatedScores, config = DEFAULT_REGULATOR_CONFIG.reviewMass) {
|
|
2863
|
+
const mass = reviews.reduce(
|
|
2864
|
+
(m, c) => m + reviewWeight(c, generatedScores.get(c.cardId), config.referenceScore),
|
|
2865
|
+
0
|
|
2866
|
+
);
|
|
2867
|
+
const multiplier = mass > config.healthyMass ? Math.pow(config.rate, (mass - config.healthyMass) / config.healthyMass) : 1;
|
|
2868
|
+
return {
|
|
2869
|
+
name: "review-mass",
|
|
2870
|
+
class: "review",
|
|
2871
|
+
urgency: mass,
|
|
2872
|
+
multiplier,
|
|
2873
|
+
applied: reviews.length,
|
|
2874
|
+
inputs: { due: reviews.length, mass, healthyMass: config.healthyMass }
|
|
2875
|
+
};
|
|
2876
|
+
}
|
|
2877
|
+
function resetIntakeClock(nowMs) {
|
|
2878
|
+
return { lastNewAt: new Date(nowMs).toISOString(), frozenMs: 0, unservableSince: null };
|
|
2879
|
+
}
|
|
2880
|
+
function frozenMsAt(state, nowMs) {
|
|
2881
|
+
const open = state.unservableSince ? Math.max(0, nowMs - Date.parse(state.unservableSince)) : 0;
|
|
2882
|
+
return state.frozenMs + open;
|
|
2883
|
+
}
|
|
2884
|
+
function intakeHours(state, nowMs) {
|
|
2885
|
+
const elapsed = nowMs - Date.parse(state.lastNewAt);
|
|
2886
|
+
return Math.max(0, elapsed - frozenMsAt(state, nowMs)) / 36e5;
|
|
2887
|
+
}
|
|
2888
|
+
function stepIntakeClock(state, nowMs, eligibleNew) {
|
|
2889
|
+
if (eligibleNew === 0 && !state.unservableSince) {
|
|
2890
|
+
return { ...state, unservableSince: new Date(nowMs).toISOString() };
|
|
2891
|
+
}
|
|
2892
|
+
if (eligibleNew > 0 && state.unservableSince) {
|
|
2893
|
+
return { ...state, frozenMs: frozenMsAt(state, nowMs), unservableSince: null };
|
|
2894
|
+
}
|
|
2895
|
+
return state;
|
|
2896
|
+
}
|
|
2897
|
+
function intakeReading(state, nowMs, counts, config = DEFAULT_REGULATOR_CONFIG.intake) {
|
|
2898
|
+
const hours = intakeHours(state, nowMs);
|
|
2899
|
+
const multiplier = counts.eligibleNew > 0 ? Math.pow(config.rate, hours / config.scaleHours) : 1;
|
|
2900
|
+
return {
|
|
2901
|
+
name: "intake",
|
|
2902
|
+
class: "new",
|
|
2903
|
+
urgency: hours,
|
|
2904
|
+
multiplier,
|
|
2905
|
+
applied: counts.eligibleNew,
|
|
2906
|
+
inputs: {
|
|
2907
|
+
hoursSinceNew: hours,
|
|
2908
|
+
frozenHours: frozenMsAt(state, nowMs) / 36e5,
|
|
2909
|
+
eligibleNew: counts.eligibleNew,
|
|
2910
|
+
newCandidates: counts.newCandidates
|
|
2911
|
+
}
|
|
2912
|
+
};
|
|
2913
|
+
}
|
|
2914
|
+
function applyReading(cards, reading) {
|
|
2915
|
+
if (reading.multiplier === 1) return;
|
|
2916
|
+
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)}`;
|
|
2917
|
+
for (const card of cards) {
|
|
2918
|
+
card.score *= reading.multiplier;
|
|
2919
|
+
card.provenance.push({
|
|
2920
|
+
strategy: "regulator",
|
|
2921
|
+
strategyName: `Regulator: ${REGULATOR_LABEL[reading.name]}`,
|
|
2922
|
+
strategyId: `regulator-${reading.name}`,
|
|
2923
|
+
action: reading.multiplier > 1 ? "boosted" : "penalized",
|
|
2924
|
+
score: card.score,
|
|
2925
|
+
reason
|
|
2926
|
+
});
|
|
2927
|
+
}
|
|
2928
|
+
}
|
|
2929
|
+
var DEFAULT_REGULATOR_CONFIG, INTAKE_CLOCK_KEY, REGULATOR_LABEL;
|
|
2930
|
+
var init_regulators = __esm({
|
|
2931
|
+
"src/core/navigators/regulators.ts"() {
|
|
2932
|
+
"use strict";
|
|
2933
|
+
DEFAULT_REGULATOR_CONFIG = {
|
|
2934
|
+
reviewMass: { referenceScore: 0.95, healthyMass: 20, rate: 2 },
|
|
2935
|
+
intake: { rate: 2, scaleHours: 24 }
|
|
2936
|
+
};
|
|
2937
|
+
INTAKE_CLOCK_KEY = "IntakeClock";
|
|
2938
|
+
REGULATOR_LABEL = {
|
|
2939
|
+
"review-mass": "Review mass",
|
|
2940
|
+
intake: "Intake"
|
|
2941
|
+
};
|
|
2942
|
+
}
|
|
2943
|
+
});
|
|
2944
|
+
|
|
2829
2945
|
// src/core/navigators/generators/srs.ts
|
|
2830
2946
|
var srs_exports = {};
|
|
2831
2947
|
__export(srs_exports, {
|
|
2832
2948
|
default: () => SRSNavigator
|
|
2833
2949
|
});
|
|
2834
|
-
var import_moment,
|
|
2950
|
+
var import_moment, SRSNavigator;
|
|
2835
2951
|
var init_srs = __esm({
|
|
2836
2952
|
"src/core/navigators/generators/srs.ts"() {
|
|
2837
2953
|
"use strict";
|
|
2838
2954
|
import_moment = __toESM(require("moment"), 1);
|
|
2839
2955
|
init_navigators();
|
|
2840
2956
|
init_SrsDebugger();
|
|
2957
|
+
init_regulators();
|
|
2841
2958
|
init_logger();
|
|
2842
|
-
DEFAULT_HEALTHY_BACKLOG = 20;
|
|
2843
|
-
BACKLOG_GROWTH_RATE = 2;
|
|
2844
2959
|
SRSNavigator = class extends ContentNavigator {
|
|
2845
2960
|
/** Human-readable name for CardGenerator interface */
|
|
2846
2961
|
name;
|
|
2847
|
-
/** Healthy backlog threshold - when exceeded, backlog pressure kicks in */
|
|
2848
|
-
healthyBacklog;
|
|
2849
2962
|
constructor(user, course, strategyData) {
|
|
2850
2963
|
super(user, course, strategyData);
|
|
2851
2964
|
this.name = strategyData?.name || "SRS";
|
|
2852
|
-
const config = this.parseConfig(strategyData?.serializedData);
|
|
2853
|
-
this.healthyBacklog = config.healthyBacklog ?? DEFAULT_HEALTHY_BACKLOG;
|
|
2854
|
-
}
|
|
2855
|
-
/**
|
|
2856
|
-
* Parse configuration from serialized JSON.
|
|
2857
|
-
*/
|
|
2858
|
-
parseConfig(serializedData) {
|
|
2859
|
-
if (!serializedData) return {};
|
|
2860
|
-
try {
|
|
2861
|
-
return JSON.parse(serializedData);
|
|
2862
|
-
} catch {
|
|
2863
|
-
logger.warn("[SRS] Failed to parse strategy config, using defaults");
|
|
2864
|
-
return {};
|
|
2865
|
-
}
|
|
2866
2965
|
}
|
|
2867
2966
|
/**
|
|
2868
2967
|
* Get review cards scored by urgency.
|
|
@@ -2870,7 +2969,6 @@ var init_srs = __esm({
|
|
|
2870
2969
|
* Score formula combines:
|
|
2871
2970
|
* - Relative overdueness: hoursOverdue / intervalHours
|
|
2872
2971
|
* - Interval recency: exponential decay favoring shorter intervals
|
|
2873
|
-
* - Backlog pressure: boost when due reviews exceed healthy threshold
|
|
2874
2972
|
*
|
|
2875
2973
|
* Cards not yet due are excluded (not scored as 0).
|
|
2876
2974
|
*
|
|
@@ -2907,7 +3005,6 @@ var init_srs = __esm({
|
|
|
2907
3005
|
}
|
|
2908
3006
|
}
|
|
2909
3007
|
}
|
|
2910
|
-
const backlogMultiplier = this.computeBacklogMultiplier(dueReviews.length);
|
|
2911
3008
|
const notDue = reviews.filter((r) => !now.isAfter(import_moment.default.utc(r.reviewTime)));
|
|
2912
3009
|
let nextDueIn = null;
|
|
2913
3010
|
if (notDue.length > 0) {
|
|
@@ -2918,9 +3015,8 @@ var init_srs = __esm({
|
|
|
2918
3015
|
nextDueIn = until.asHours() < 1 ? `${Math.round(until.asMinutes())}m` : until.asHours() < 24 ? `${Math.round(until.asHours())}h` : `${Math.round(until.asDays())}d`;
|
|
2919
3016
|
}
|
|
2920
3017
|
if (dueReviews.length > 0) {
|
|
2921
|
-
const pressureNote = backlogMultiplier > 1 ? ` [backlog pressure: \xD7${backlogMultiplier.toFixed(2)}]` : ` [healthy backlog]`;
|
|
2922
3018
|
logger.info(
|
|
2923
|
-
`[SRS] Course ${courseId}: ${dueReviews.length} reviews due now (of ${reviews.length} scheduled)
|
|
3019
|
+
`[SRS] Course ${courseId}: ${dueReviews.length} reviews due now (of ${reviews.length} scheduled)`
|
|
2924
3020
|
);
|
|
2925
3021
|
} else if (reviews.length > 0) {
|
|
2926
3022
|
const sortedByDue = [...reviews].sort(
|
|
@@ -2937,11 +3033,12 @@ var init_srs = __esm({
|
|
|
2937
3033
|
logger.info(`[SRS] Course ${courseId}: No reviews scheduled`);
|
|
2938
3034
|
}
|
|
2939
3035
|
const scored = dueReviews.map((review) => {
|
|
2940
|
-
const { score, reason } = this.computeUrgencyScore(review, now
|
|
3036
|
+
const { score, urgency, reason } = this.computeUrgencyScore(review, now);
|
|
2941
3037
|
return {
|
|
2942
3038
|
cardId: review.cardId,
|
|
2943
3039
|
courseId: review.courseId,
|
|
2944
3040
|
score,
|
|
3041
|
+
reviewUrgency: urgency,
|
|
2945
3042
|
reviewID: review._id,
|
|
2946
3043
|
provenance: [
|
|
2947
3044
|
{
|
|
@@ -2960,47 +3057,20 @@ var init_srs = __esm({
|
|
|
2960
3057
|
courseId,
|
|
2961
3058
|
scheduledTotal: reviews.length,
|
|
2962
3059
|
dueNow: dueReviews.length,
|
|
2963
|
-
healthyBacklog:
|
|
2964
|
-
|
|
2965
|
-
|
|
3060
|
+
healthyBacklog: DEFAULT_REGULATOR_CONFIG.reviewMass.healthyMass,
|
|
3061
|
+
reviewMass: null,
|
|
3062
|
+
backlogMultiplier: 1,
|
|
3063
|
+
backlogGrowthRate: DEFAULT_REGULATOR_CONFIG.reviewMass.rate,
|
|
2966
3064
|
topReviewScore: sorted.length > 0 ? sorted[0].score : null,
|
|
2967
3065
|
nextDueIn,
|
|
2968
3066
|
timestamp: Date.now()
|
|
2969
3067
|
});
|
|
2970
3068
|
return { cards: sorted.slice(0, limit) };
|
|
2971
3069
|
}
|
|
2972
|
-
/**
|
|
2973
|
-
* Compute the multiplicative backlog pressure based on number of due reviews.
|
|
2974
|
-
*
|
|
2975
|
-
* ×1.0 at or below the healthy threshold (no boost); above it, grows as
|
|
2976
|
-
* BACKLOG_GROWTH_RATE raised to the excess expressed in multiples of the
|
|
2977
|
-
* healthy threshold. Uncapped — self-regulating instead: reviews winning
|
|
2978
|
-
* slots depletes dueCount, which drops the ratio and relaxes the multiplier
|
|
2979
|
-
* next run.
|
|
2980
|
-
*
|
|
2981
|
-
* Examples (with default healthyBacklog=20, BACKLOG_GROWTH_RATE=1.5):
|
|
2982
|
-
* - 10 due reviews → ×1.00 (healthy)
|
|
2983
|
-
* - 20 due reviews → ×1.00 (at threshold, ratio 0)
|
|
2984
|
-
* - 40 due reviews → ×1.50 (ratio 1, 2x threshold)
|
|
2985
|
-
* - 60 due reviews → ×2.25 (ratio 2, 3x threshold — old hard cap was ×2.00 here)
|
|
2986
|
-
* - 100 due reviews → ×5.06 (ratio 4, 5x threshold)
|
|
2987
|
-
* - 160 due reviews → ×17.09 (ratio 7, 8x threshold)
|
|
2988
|
-
*
|
|
2989
|
-
* @param dueCount - Number of reviews currently due
|
|
2990
|
-
* @returns Multiplier applied to review urgency (>= 1.0, unbounded)
|
|
2991
|
-
*/
|
|
2992
|
-
computeBacklogMultiplier(dueCount) {
|
|
2993
|
-
if (dueCount <= this.healthyBacklog) {
|
|
2994
|
-
return 1;
|
|
2995
|
-
}
|
|
2996
|
-
const excess = dueCount - this.healthyBacklog;
|
|
2997
|
-
const ratio = excess / this.healthyBacklog;
|
|
2998
|
-
return Math.pow(BACKLOG_GROWTH_RATE, ratio);
|
|
2999
|
-
}
|
|
3000
3070
|
/**
|
|
3001
3071
|
* Compute urgency score for a review card.
|
|
3002
3072
|
*
|
|
3003
|
-
*
|
|
3073
|
+
* Two factors:
|
|
3004
3074
|
* 1. Relative overdueness = hoursOverdue / intervalHours
|
|
3005
3075
|
* - 2 days overdue on 3-day interval = 0.67 (urgent)
|
|
3006
3076
|
* - 2 days overdue on 180-day interval = 0.01 (not urgent)
|
|
@@ -3010,20 +3080,14 @@ var init_srs = __esm({
|
|
|
3010
3080
|
* - 30 days (720h) → ~0.56
|
|
3011
3081
|
* - 180 days → ~0.30
|
|
3012
3082
|
*
|
|
3013
|
-
*
|
|
3014
|
-
*
|
|
3015
|
-
*
|
|
3016
|
-
* Combined: (base 0.5 + urgency factors * 0.45) × backlog multiplier.
|
|
3017
|
-
* Per-card range before pressure: ~0.57–0.95. NOT clamped to 1.0 — under a
|
|
3018
|
-
* heavy backlog reviews scale onto the open scale to compete with (and exceed)
|
|
3019
|
-
* new cards; there's no ceiling at all now, so a bad enough backlog always
|
|
3020
|
-
* wins eventually — self-regulating because winning slots depletes dueCount.
|
|
3083
|
+
* Combined: base 0.5 + urgency factors * 0.45, so ~0.57–0.95 per card.
|
|
3084
|
+
* Backlog pressure is applied later, by the regulator stage, which can lift
|
|
3085
|
+
* reviews onto the open scale above new cards (see regulators.ts).
|
|
3021
3086
|
*
|
|
3022
3087
|
* @param review - The scheduled card to score
|
|
3023
3088
|
* @param now - Current time
|
|
3024
|
-
* @param backlogMultiplier - Pre-computed backlog multiplier (>= 1.0, unbounded)
|
|
3025
3089
|
*/
|
|
3026
|
-
computeUrgencyScore(review, now
|
|
3090
|
+
computeUrgencyScore(review, now) {
|
|
3027
3091
|
const scheduledAt = import_moment.default.utc(review.scheduledAt);
|
|
3028
3092
|
const due = import_moment.default.utc(review.reviewTime);
|
|
3029
3093
|
const intervalHours = Math.max(1, due.diff(scheduledAt, "hours"));
|
|
@@ -3032,20 +3096,16 @@ var init_srs = __esm({
|
|
|
3032
3096
|
const recencyFactor = 0.3 + 0.7 * Math.exp(-intervalHours / 720);
|
|
3033
3097
|
const overdueContribution = Math.min(1, Math.max(0, relativeOverdue));
|
|
3034
3098
|
const urgency = overdueContribution * 0.5 + recencyFactor * 0.5;
|
|
3035
|
-
const
|
|
3036
|
-
const score = baseScore * backlogMultiplier;
|
|
3099
|
+
const score = 0.5 + urgency * 0.45;
|
|
3037
3100
|
const reasonParts = [
|
|
3038
3101
|
`${Math.round(hoursOverdue)}h overdue`,
|
|
3039
3102
|
`interval: ${Math.round(intervalHours)}h`,
|
|
3040
3103
|
`relative: ${relativeOverdue.toFixed(2)}`,
|
|
3041
3104
|
`recency: ${recencyFactor.toFixed(2)}`
|
|
3042
3105
|
];
|
|
3043
|
-
if (backlogMultiplier > 1) {
|
|
3044
|
-
reasonParts.push(`backlog: \xD7${backlogMultiplier.toFixed(2)}`);
|
|
3045
|
-
}
|
|
3046
3106
|
reasonParts.push("review");
|
|
3047
3107
|
const reason = reasonParts.join(", ");
|
|
3048
|
-
return { score, reason };
|
|
3108
|
+
return { score, urgency, reason };
|
|
3049
3109
|
}
|
|
3050
3110
|
};
|
|
3051
3111
|
}
|
|
@@ -3100,6 +3160,8 @@ var init_WeightedFilter = __esm({
|
|
|
3100
3160
|
init_contentNavigationStrategy();
|
|
3101
3161
|
WeightedFilter = class {
|
|
3102
3162
|
name;
|
|
3163
|
+
kind;
|
|
3164
|
+
liveOnly;
|
|
3103
3165
|
inner;
|
|
3104
3166
|
learnable;
|
|
3105
3167
|
staticWeight;
|
|
@@ -3107,6 +3169,8 @@ var init_WeightedFilter = __esm({
|
|
|
3107
3169
|
constructor(inner, learnable = DEFAULT_LEARNABLE_WEIGHT, staticWeight = false, strategyId) {
|
|
3108
3170
|
this.inner = inner;
|
|
3109
3171
|
this.name = inner.name;
|
|
3172
|
+
this.kind = inner.kind;
|
|
3173
|
+
this.liveOnly = inner.liveOnly;
|
|
3110
3174
|
this.learnable = learnable;
|
|
3111
3175
|
this.staticWeight = staticWeight;
|
|
3112
3176
|
this.strategyId = strategyId;
|
|
@@ -3171,58 +3235,175 @@ var init_WeightedFilter = __esm({
|
|
|
3171
3235
|
// src/core/navigators/filters/eloDistance.ts
|
|
3172
3236
|
var eloDistance_exports = {};
|
|
3173
3237
|
__export(eloDistance_exports, {
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3238
|
+
DEFAULT_ELO_DISTANCE_CONFIG: () => DEFAULT_ELO_DISTANCE_CONFIG,
|
|
3239
|
+
createEloDistanceFilter: () => createEloDistanceFilter,
|
|
3240
|
+
default: () => EloDistanceFilter,
|
|
3241
|
+
mountMultiDimEloToggle: () => mountMultiDimEloToggle,
|
|
3242
|
+
tagAwareGap: () => tagAwareGap
|
|
3178
3243
|
});
|
|
3179
3244
|
function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
|
|
3180
3245
|
const normalizedDistance = distance / halfLife;
|
|
3181
3246
|
const decay = Math.exp(-(normalizedDistance * normalizedDistance));
|
|
3182
3247
|
return minMultiplier + (maxMultiplier - minMultiplier) * decay;
|
|
3183
3248
|
}
|
|
3249
|
+
function resolveConfig(config) {
|
|
3250
|
+
return { ...DEFAULT_ELO_DISTANCE_CONFIG, ...config };
|
|
3251
|
+
}
|
|
3252
|
+
function readMultiDimElo() {
|
|
3253
|
+
try {
|
|
3254
|
+
return typeof localStorage !== "undefined" && localStorage.getItem(MULTI_DIM_ELO_KEY) === "true";
|
|
3255
|
+
} catch {
|
|
3256
|
+
return false;
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
function mountMultiDimEloToggle() {
|
|
3260
|
+
if (typeof window === "undefined") return;
|
|
3261
|
+
const win = window;
|
|
3262
|
+
win.skuilder = win.skuilder || {};
|
|
3263
|
+
Object.defineProperty(win.skuilder, "multiDimElo", {
|
|
3264
|
+
configurable: true,
|
|
3265
|
+
enumerable: true,
|
|
3266
|
+
get: () => multiDimElo,
|
|
3267
|
+
set: (on) => {
|
|
3268
|
+
multiDimElo = on === true;
|
|
3269
|
+
try {
|
|
3270
|
+
if (multiDimElo) localStorage.setItem(MULTI_DIM_ELO_KEY, "true");
|
|
3271
|
+
else localStorage.removeItem(MULTI_DIM_ELO_KEY);
|
|
3272
|
+
} catch (e) {
|
|
3273
|
+
logger.warn(`[EloDistance] multiDimElo not persisted (localStorage unavailable): ${e}`);
|
|
3274
|
+
}
|
|
3275
|
+
logger.info(
|
|
3276
|
+
`[EloDistance] multiDimElo ${multiDimElo ? "on: tag-aware" : "off: per strategy config"} ELO distance from the next replan`
|
|
3277
|
+
);
|
|
3278
|
+
}
|
|
3279
|
+
});
|
|
3280
|
+
}
|
|
3281
|
+
function tagAwareGap(cardTags, cardElo, userElo, minTagCount) {
|
|
3282
|
+
const globalGap = cardElo.global.score - userElo.global.score;
|
|
3283
|
+
const tags = [];
|
|
3284
|
+
for (const tag of cardTags) {
|
|
3285
|
+
const user = userElo.tags[tag];
|
|
3286
|
+
if (!user || user.score === COUNT_ONLY_SENTINEL || user.count < minTagCount) continue;
|
|
3287
|
+
const card = cardElo.tags[tag]?.score ?? cardElo.global.score;
|
|
3288
|
+
tags.push({
|
|
3289
|
+
tag,
|
|
3290
|
+
gap: card - user.score,
|
|
3291
|
+
weight: user.count / (user.count + TAG_CONFIDENCE_HALF)
|
|
3292
|
+
});
|
|
3293
|
+
}
|
|
3294
|
+
if (tags.length === 0) return { gap: globalGap, globalGap, tags };
|
|
3295
|
+
const total = tags.reduce((w, t) => w + t.weight, 0);
|
|
3296
|
+
const tagGap = tags.reduce((g, t) => g + t.weight * t.gap, 0) / total;
|
|
3297
|
+
const lambda = total / (total + 1);
|
|
3298
|
+
return { gap: lambda * tagGap + (1 - lambda) * globalGap, globalGap, tags };
|
|
3299
|
+
}
|
|
3300
|
+
function tagReason(tags, globalGap) {
|
|
3301
|
+
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(", ");
|
|
3302
|
+
const more = tags.length > 3 ? `, +${tags.length - 3} more` : "";
|
|
3303
|
+
return ` on ${tags.length} shared tag(s) [${shown}${more}] (global ${globalGap >= 0 ? "+" : ""}${Math.round(globalGap)})`;
|
|
3304
|
+
}
|
|
3305
|
+
async function applyEloDistance(cards, context, config, source) {
|
|
3306
|
+
const { course, userElo, userCourseElo } = context;
|
|
3307
|
+
const { halfLife, minMultiplier, maxMultiplier } = config;
|
|
3308
|
+
const tagAware = (config.tagAware || multiDimElo) && userCourseElo !== void 0;
|
|
3309
|
+
const missing = cards.filter((c) => tagAware || c.cardElo === void 0).map((c) => c.cardId);
|
|
3310
|
+
const fetched = /* @__PURE__ */ new Map();
|
|
3311
|
+
if (missing.length > 0) {
|
|
3312
|
+
const elos = await course.getCardEloData(missing);
|
|
3313
|
+
missing.forEach((id, i) => {
|
|
3314
|
+
if (elos[i]) fetched.set(id, elos[i]);
|
|
3315
|
+
});
|
|
3316
|
+
}
|
|
3317
|
+
return cards.map((card) => {
|
|
3318
|
+
const full = fetched.get(card.cardId);
|
|
3319
|
+
const cardElo = full?.global?.score ?? card.cardElo ?? DEFAULT_CARD_ELO;
|
|
3320
|
+
let distance = Math.abs(cardElo - userElo);
|
|
3321
|
+
let how = "";
|
|
3322
|
+
if (tagAware) {
|
|
3323
|
+
const t = full ? tagAwareGap(card.tags ?? [], full, userCourseElo, config.minTagCount) : void 0;
|
|
3324
|
+
if (t) distance = Math.abs(t.gap);
|
|
3325
|
+
how = t?.tags.length ? `, tag-aware${tagReason(t.tags, t.globalGap)}` : ", tag-aware: global (no shared tags)";
|
|
3326
|
+
}
|
|
3327
|
+
const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
|
|
3328
|
+
const newScore = card.score * multiplier;
|
|
3329
|
+
const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
|
|
3330
|
+
return {
|
|
3331
|
+
...card,
|
|
3332
|
+
cardElo,
|
|
3333
|
+
score: newScore,
|
|
3334
|
+
provenance: [
|
|
3335
|
+
...card.provenance,
|
|
3336
|
+
{
|
|
3337
|
+
strategy: "eloDistance",
|
|
3338
|
+
strategyName: source.name,
|
|
3339
|
+
strategyId: source.strategyId,
|
|
3340
|
+
action,
|
|
3341
|
+
score: newScore,
|
|
3342
|
+
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)})${how} \u2192 ${multiplier.toFixed(2)}x`
|
|
3343
|
+
}
|
|
3344
|
+
]
|
|
3345
|
+
};
|
|
3346
|
+
});
|
|
3347
|
+
}
|
|
3184
3348
|
function createEloDistanceFilter(config) {
|
|
3185
|
-
const
|
|
3186
|
-
const
|
|
3187
|
-
const maxMultiplier = config?.maxMultiplier ?? DEFAULT_MAX_MULTIPLIER;
|
|
3349
|
+
const resolved = resolveConfig(config);
|
|
3350
|
+
const source = { name: "ELO Distance Filter", strategyId: "ELO_DISTANCE_FILTER" };
|
|
3188
3351
|
return {
|
|
3189
|
-
name:
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
const cardElos = await course.getCardEloData(cardIds);
|
|
3194
|
-
return cards.map((card, i) => {
|
|
3195
|
-
const cardElo = cardElos[i]?.global?.score ?? 1e3;
|
|
3196
|
-
const distance = Math.abs(cardElo - userElo);
|
|
3197
|
-
const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
|
|
3198
|
-
const newScore = card.score * multiplier;
|
|
3199
|
-
const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
|
|
3200
|
-
return {
|
|
3201
|
-
...card,
|
|
3202
|
-
score: newScore,
|
|
3203
|
-
provenance: [
|
|
3204
|
-
...card.provenance,
|
|
3205
|
-
{
|
|
3206
|
-
strategy: "eloDistance",
|
|
3207
|
-
strategyName: "ELO Distance Filter",
|
|
3208
|
-
strategyId: "ELO_DISTANCE_FILTER",
|
|
3209
|
-
action,
|
|
3210
|
-
score: newScore,
|
|
3211
|
-
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)}) \u2192 ${multiplier.toFixed(2)}x`
|
|
3212
|
-
}
|
|
3213
|
-
]
|
|
3214
|
-
};
|
|
3215
|
-
});
|
|
3216
|
-
}
|
|
3352
|
+
name: source.name,
|
|
3353
|
+
kind: "signal",
|
|
3354
|
+
liveOnly: true,
|
|
3355
|
+
transform: (cards, context) => applyEloDistance(cards, context, resolved, source)
|
|
3217
3356
|
};
|
|
3218
3357
|
}
|
|
3219
|
-
var
|
|
3358
|
+
var DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, COUNT_ONLY_SENTINEL, DEFAULT_CARD_ELO, MULTI_DIM_ELO_KEY, multiDimElo, EloDistanceFilter;
|
|
3220
3359
|
var init_eloDistance = __esm({
|
|
3221
3360
|
"src/core/navigators/filters/eloDistance.ts"() {
|
|
3222
3361
|
"use strict";
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3362
|
+
init_navigators();
|
|
3363
|
+
init_logger();
|
|
3364
|
+
DEFAULT_ELO_DISTANCE_CONFIG = {
|
|
3365
|
+
halfLife: 300,
|
|
3366
|
+
minMultiplier: 0.05,
|
|
3367
|
+
maxMultiplier: 1,
|
|
3368
|
+
tagAware: false,
|
|
3369
|
+
minTagCount: 3
|
|
3370
|
+
};
|
|
3371
|
+
TAG_CONFIDENCE_HALF = 10;
|
|
3372
|
+
COUNT_ONLY_SENTINEL = -1;
|
|
3373
|
+
DEFAULT_CARD_ELO = 1e3;
|
|
3374
|
+
MULTI_DIM_ELO_KEY = "skuilder:multiDimElo";
|
|
3375
|
+
multiDimElo = readMultiDimElo();
|
|
3376
|
+
mountMultiDimEloToggle();
|
|
3377
|
+
EloDistanceFilter = class _EloDistanceFilter extends ContentNavigator {
|
|
3378
|
+
name;
|
|
3379
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3380
|
+
static kind = "signal";
|
|
3381
|
+
kind = _EloDistanceFilter.kind;
|
|
3382
|
+
liveOnly = true;
|
|
3383
|
+
config;
|
|
3384
|
+
constructor(user, course, strategyData) {
|
|
3385
|
+
super(user, course, strategyData);
|
|
3386
|
+
this.name = strategyData.name || "ELO Distance";
|
|
3387
|
+
let parsed;
|
|
3388
|
+
try {
|
|
3389
|
+
parsed = strategyData.serializedData ? JSON.parse(strategyData.serializedData) : void 0;
|
|
3390
|
+
} catch {
|
|
3391
|
+
parsed = void 0;
|
|
3392
|
+
}
|
|
3393
|
+
this.config = resolveConfig(parsed);
|
|
3394
|
+
}
|
|
3395
|
+
transform(cards, context) {
|
|
3396
|
+
return applyEloDistance(cards, context, this.config, {
|
|
3397
|
+
name: this.name,
|
|
3398
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-eloDistance-default"
|
|
3399
|
+
});
|
|
3400
|
+
}
|
|
3401
|
+
async getWeightedCards(_limit) {
|
|
3402
|
+
throw new Error(
|
|
3403
|
+
"EloDistanceFilter is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
|
|
3404
|
+
);
|
|
3405
|
+
}
|
|
3406
|
+
};
|
|
3226
3407
|
}
|
|
3227
3408
|
});
|
|
3228
3409
|
|
|
@@ -3239,10 +3420,13 @@ var init_hierarchyDefinition = __esm({
|
|
|
3239
3420
|
import_common6 = require("@vue-skuilder/common");
|
|
3240
3421
|
init_logger();
|
|
3241
3422
|
DEFAULT_MIN_COUNT2 = 3;
|
|
3242
|
-
HierarchyDefinitionNavigator = class extends ContentNavigator {
|
|
3423
|
+
HierarchyDefinitionNavigator = class _HierarchyDefinitionNavigator extends ContentNavigator {
|
|
3243
3424
|
config;
|
|
3244
3425
|
/** Human-readable name for CardFilter interface */
|
|
3245
3426
|
name;
|
|
3427
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3428
|
+
static kind = "gate";
|
|
3429
|
+
kind = _HierarchyDefinitionNavigator.kind;
|
|
3246
3430
|
constructor(user, course, strategyData) {
|
|
3247
3431
|
super(user, course, strategyData);
|
|
3248
3432
|
this.config = this.parseConfig(strategyData.serializedData);
|
|
@@ -3509,10 +3693,13 @@ var init_userTagPreference = __esm({
|
|
|
3509
3693
|
"src/core/navigators/filters/userTagPreference.ts"() {
|
|
3510
3694
|
"use strict";
|
|
3511
3695
|
init_navigators();
|
|
3512
|
-
UserTagPreferenceFilter = class extends ContentNavigator {
|
|
3696
|
+
UserTagPreferenceFilter = class _UserTagPreferenceFilter extends ContentNavigator {
|
|
3513
3697
|
_strategyData;
|
|
3514
3698
|
/** Human-readable name for CardFilter interface */
|
|
3515
3699
|
name;
|
|
3700
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3701
|
+
static kind = "signal";
|
|
3702
|
+
kind = _UserTagPreferenceFilter.kind;
|
|
3516
3703
|
constructor(user, course, strategyData) {
|
|
3517
3704
|
super(user, course, strategyData);
|
|
3518
3705
|
this._strategyData = strategyData;
|
|
@@ -3622,6 +3809,7 @@ var init_userTagPreference = __esm({
|
|
|
3622
3809
|
// src/core/navigators/filters/index.ts
|
|
3623
3810
|
var filters_exports = {};
|
|
3624
3811
|
__export(filters_exports, {
|
|
3812
|
+
EloDistanceFilter: () => EloDistanceFilter,
|
|
3625
3813
|
UserTagPreferenceFilter: () => UserTagPreferenceFilter,
|
|
3626
3814
|
createEloDistanceFilter: () => createEloDistanceFilter
|
|
3627
3815
|
});
|
|
@@ -3660,10 +3848,13 @@ var init_interferenceMitigator = __esm({
|
|
|
3660
3848
|
DEFAULT_MIN_COUNT3 = 10;
|
|
3661
3849
|
DEFAULT_MIN_ELAPSED_DAYS = 3;
|
|
3662
3850
|
DEFAULT_INTERFERENCE_DECAY = 0.8;
|
|
3663
|
-
InterferenceMitigatorNavigator = class extends ContentNavigator {
|
|
3851
|
+
InterferenceMitigatorNavigator = class _InterferenceMitigatorNavigator extends ContentNavigator {
|
|
3664
3852
|
config;
|
|
3665
3853
|
/** Human-readable name for CardFilter interface */
|
|
3666
3854
|
name;
|
|
3855
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3856
|
+
static kind = "signal";
|
|
3857
|
+
kind = _InterferenceMitigatorNavigator.kind;
|
|
3667
3858
|
/** Precomputed map: tag -> set of { partner, decay } it interferes with */
|
|
3668
3859
|
interferenceMap;
|
|
3669
3860
|
constructor(user, course, strategyData) {
|
|
@@ -3879,10 +4070,13 @@ var init_relativePriority = __esm({
|
|
|
3879
4070
|
DEFAULT_PRIORITY = 0.5;
|
|
3880
4071
|
DEFAULT_PRIORITY_INFLUENCE = 0.5;
|
|
3881
4072
|
DEFAULT_COMBINE_MODE = "max";
|
|
3882
|
-
RelativePriorityNavigator = class extends ContentNavigator {
|
|
4073
|
+
RelativePriorityNavigator = class _RelativePriorityNavigator extends ContentNavigator {
|
|
3883
4074
|
config;
|
|
3884
4075
|
/** Human-readable name for CardFilter interface */
|
|
3885
4076
|
name;
|
|
4077
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
4078
|
+
static kind = "signal";
|
|
4079
|
+
kind = _RelativePriorityNavigator.kind;
|
|
3886
4080
|
constructor(user, course, strategyData) {
|
|
3887
4081
|
super(user, course, strategyData);
|
|
3888
4082
|
this.config = this.parseConfig(strategyData.serializedData);
|
|
@@ -4290,6 +4484,8 @@ var init_Pipeline = __esm({
|
|
|
4290
4484
|
init_orchestration();
|
|
4291
4485
|
init_PipelineDebugger();
|
|
4292
4486
|
init_diversityRerank();
|
|
4487
|
+
init_regulators();
|
|
4488
|
+
init_SrsDebugger();
|
|
4293
4489
|
VERBOSE_RESULTS = true;
|
|
4294
4490
|
Pipeline = class extends ContentNavigator {
|
|
4295
4491
|
generator;
|
|
@@ -4315,6 +4511,13 @@ var init_Pipeline = __esm({
|
|
|
4315
4511
|
* getWeightedCards() call, then cleared.
|
|
4316
4512
|
*/
|
|
4317
4513
|
_ephemeralHints = null;
|
|
4514
|
+
/**
|
|
4515
|
+
* The intake valve's clock (see regulators.ts), loaded from strategy state on
|
|
4516
|
+
* first use and kept in memory. Writes are chained so a presentation and a
|
|
4517
|
+
* run can't race each other's revision.
|
|
4518
|
+
*/
|
|
4519
|
+
_intakeClock = null;
|
|
4520
|
+
_intakeClockWrite = Promise.resolve();
|
|
4318
4521
|
/**
|
|
4319
4522
|
* Create a new pipeline.
|
|
4320
4523
|
*
|
|
@@ -4389,13 +4592,12 @@ var init_Pipeline = __esm({
|
|
|
4389
4592
|
}
|
|
4390
4593
|
}
|
|
4391
4594
|
generatorSummaries = Array.from(genMap.entries()).map(([name, data]) => {
|
|
4392
|
-
const
|
|
4393
|
-
const reviewCards = data.cards.filter((c) => c.provenance[0]?.reason?.includes("review"));
|
|
4595
|
+
const reviewCount = data.cards.filter((c) => c.reviewID).length;
|
|
4394
4596
|
return {
|
|
4395
4597
|
name,
|
|
4396
4598
|
cardCount: data.cards.length,
|
|
4397
|
-
newCount:
|
|
4398
|
-
reviewCount
|
|
4599
|
+
newCount: data.cards.length - reviewCount,
|
|
4600
|
+
reviewCount,
|
|
4399
4601
|
topScore: Math.max(...data.cards.map((c) => c.score), 0)
|
|
4400
4602
|
};
|
|
4401
4603
|
});
|
|
@@ -4431,19 +4633,24 @@ var init_Pipeline = __esm({
|
|
|
4431
4633
|
cards.filter((c) => c.provenance.some((p) => p.strategy === "prescribed")).map((c) => c.cardId)
|
|
4432
4634
|
);
|
|
4433
4635
|
const filterImpacts = [];
|
|
4636
|
+
const generatedScores = new Map(cards.map((c) => [c.cardId, c.score]));
|
|
4637
|
+
const gated = /* @__PURE__ */ new Set();
|
|
4434
4638
|
for (const filter of this.filters) {
|
|
4435
4639
|
const beforeCount = cards.length;
|
|
4436
4640
|
const beforeScores = new Map(cards.map((c) => [c.cardId, c.score]));
|
|
4437
4641
|
cards = await filter.transform(cards, context);
|
|
4438
4642
|
let boosted = 0, penalized = 0, passed = 0;
|
|
4439
4643
|
const removed = beforeCount - cards.length;
|
|
4644
|
+
const kind = filter.kind ?? "gate";
|
|
4440
4645
|
for (const card of cards) {
|
|
4441
4646
|
const before = beforeScores.get(card.cardId) ?? 0;
|
|
4442
4647
|
if (card.score > before) boosted++;
|
|
4443
|
-
else if (card.score < before)
|
|
4444
|
-
|
|
4648
|
+
else if (card.score < before) {
|
|
4649
|
+
penalized++;
|
|
4650
|
+
if (kind === "gate") gated.add(card.cardId);
|
|
4651
|
+
} else passed++;
|
|
4445
4652
|
}
|
|
4446
|
-
filterImpacts.push({ name: filter.name, boosted, penalized, passed, removed });
|
|
4653
|
+
filterImpacts.push({ name: filter.name, kind, boosted, penalized, passed, removed });
|
|
4447
4654
|
if (prescribedIds.size > 0) {
|
|
4448
4655
|
const survivingIds = new Set(cards.map((c) => c.cardId));
|
|
4449
4656
|
const killedPrescribed = [...prescribedIds].filter((id) => !survivingIds.has(id));
|
|
@@ -4459,6 +4666,7 @@ var init_Pipeline = __esm({
|
|
|
4459
4666
|
}
|
|
4460
4667
|
const scoredCards = cards;
|
|
4461
4668
|
cards = cards.filter((c) => c.score > 0);
|
|
4669
|
+
const regulators = await this.regulate(cards, generatedScores, gated);
|
|
4462
4670
|
const hints = this._ephemeralHints;
|
|
4463
4671
|
if (hints) {
|
|
4464
4672
|
this._ephemeralHints = null;
|
|
@@ -4495,7 +4703,8 @@ var init_Pipeline = __esm({
|
|
|
4495
4703
|
result,
|
|
4496
4704
|
context.userElo,
|
|
4497
4705
|
hints ?? void 0,
|
|
4498
|
-
scoredCards
|
|
4706
|
+
scoredCards,
|
|
4707
|
+
regulators
|
|
4499
4708
|
);
|
|
4500
4709
|
captureRun(report);
|
|
4501
4710
|
} catch (e) {
|
|
@@ -4674,6 +4883,77 @@ var init_Pipeline = __esm({
|
|
|
4674
4883
|
logger.info(`[Pipeline] Hints applied: ${beforeCount} \u2192 ${cards.length} cards`);
|
|
4675
4884
|
return cards;
|
|
4676
4885
|
}
|
|
4886
|
+
/**
|
|
4887
|
+
* The regulator stage: measure each class's pressure and scale it.
|
|
4888
|
+
*
|
|
4889
|
+
* - Review mass: every due review's SRS urgency times the filters' net
|
|
4890
|
+
* effect on it.
|
|
4891
|
+
* - Intake: servable hours since a new card was presented, applied only to
|
|
4892
|
+
* eligible new cards (no gate penalized them). With none eligible, the
|
|
4893
|
+
* clock freezes.
|
|
4894
|
+
*
|
|
4895
|
+
* Mutates `cards` in place; returns the readings for the run report.
|
|
4896
|
+
*/
|
|
4897
|
+
async regulate(cards, generatedScores, gated) {
|
|
4898
|
+
const config = DEFAULT_REGULATOR_CONFIG;
|
|
4899
|
+
const reviews = cards.filter((c) => c.reviewID);
|
|
4900
|
+
const newCards = cards.filter((c) => !c.reviewID);
|
|
4901
|
+
const eligibleNew = newCards.filter((c) => !gated.has(c.cardId));
|
|
4902
|
+
const mass = reviewMassReading(reviews, generatedScores, config.reviewMass);
|
|
4903
|
+
applyReading(reviews, mass);
|
|
4904
|
+
noteReviewPressure(this.course.getCourseID(), {
|
|
4905
|
+
mass: mass.urgency,
|
|
4906
|
+
healthyMass: config.reviewMass.healthyMass,
|
|
4907
|
+
rate: config.reviewMass.rate,
|
|
4908
|
+
multiplier: mass.multiplier
|
|
4909
|
+
});
|
|
4910
|
+
const now = Date.now();
|
|
4911
|
+
const clock = await this.loadIntakeClock(now);
|
|
4912
|
+
const stepped = stepIntakeClock(clock, now, eligibleNew.length);
|
|
4913
|
+
if (stepped !== clock) this.saveIntakeClock(stepped);
|
|
4914
|
+
const intake = intakeReading(
|
|
4915
|
+
stepped,
|
|
4916
|
+
now,
|
|
4917
|
+
{ eligibleNew: eligibleNew.length, newCandidates: newCards.length },
|
|
4918
|
+
config.intake
|
|
4919
|
+
);
|
|
4920
|
+
applyReading(eligibleNew, intake);
|
|
4921
|
+
logger.info(
|
|
4922
|
+
`[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)}`
|
|
4923
|
+
);
|
|
4924
|
+
return [mass, intake];
|
|
4925
|
+
}
|
|
4926
|
+
/**
|
|
4927
|
+
* A card was presented. A new card's first presentation discharges the
|
|
4928
|
+
* intake valve: its clock restarts. Called by the SessionController.
|
|
4929
|
+
*/
|
|
4930
|
+
notePresented(card) {
|
|
4931
|
+
if (card.status !== "new" || card.courseId !== this.course?.getCourseID()) return;
|
|
4932
|
+
this.saveIntakeClock(resetIntakeClock(Date.now()));
|
|
4933
|
+
}
|
|
4934
|
+
async loadIntakeClock(nowMs) {
|
|
4935
|
+
if (this._intakeClock) return this._intakeClock;
|
|
4936
|
+
let stored = null;
|
|
4937
|
+
try {
|
|
4938
|
+
stored = await this.user.getStrategyState(
|
|
4939
|
+
this.course.getCourseID(),
|
|
4940
|
+
INTAKE_CLOCK_KEY
|
|
4941
|
+
);
|
|
4942
|
+
} catch (e) {
|
|
4943
|
+
logger.warn(`[Pipeline:regulators] Could not read the intake clock: ${e}`);
|
|
4944
|
+
}
|
|
4945
|
+
if (stored) {
|
|
4946
|
+
this._intakeClock = stored;
|
|
4947
|
+
} else {
|
|
4948
|
+
this.saveIntakeClock(resetIntakeClock(nowMs));
|
|
4949
|
+
}
|
|
4950
|
+
return this._intakeClock;
|
|
4951
|
+
}
|
|
4952
|
+
saveIntakeClock(state) {
|
|
4953
|
+
this._intakeClock = state;
|
|
4954
|
+
const courseId = this.course.getCourseID();
|
|
4955
|
+
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}`));
|
|
4956
|
+
}
|
|
4677
4957
|
/**
|
|
4678
4958
|
* Build shared context for generator and filters.
|
|
4679
4959
|
*
|
|
@@ -4684,10 +4964,11 @@ var init_Pipeline = __esm({
|
|
|
4684
4964
|
*/
|
|
4685
4965
|
async buildContext() {
|
|
4686
4966
|
let userElo = 1e3;
|
|
4967
|
+
let userCourseElo;
|
|
4687
4968
|
try {
|
|
4688
4969
|
const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
|
|
4689
|
-
|
|
4690
|
-
userElo =
|
|
4970
|
+
userCourseElo = (0, import_common8.toCourseElo)(courseReg.elo);
|
|
4971
|
+
userElo = userCourseElo.global.score;
|
|
4691
4972
|
} catch (e) {
|
|
4692
4973
|
logger.debug(`[Pipeline] Could not get user ELO, using default: ${e}`);
|
|
4693
4974
|
}
|
|
@@ -4699,6 +4980,7 @@ var init_Pipeline = __esm({
|
|
|
4699
4980
|
user: this.user,
|
|
4700
4981
|
course: this.course,
|
|
4701
4982
|
userElo,
|
|
4983
|
+
...userCourseElo ? { userCourseElo } : {},
|
|
4702
4984
|
orchestration
|
|
4703
4985
|
};
|
|
4704
4986
|
}
|
|
@@ -4812,7 +5094,7 @@ var init_Pipeline = __esm({
|
|
|
4812
5094
|
cards = await this.hydrateTags(cards);
|
|
4813
5095
|
const fullPool = cards.slice();
|
|
4814
5096
|
const context = await this.buildContext();
|
|
4815
|
-
for (const filter of this.
|
|
5097
|
+
for (const filter of this.forecastFilters()) {
|
|
4816
5098
|
cards = await filter.transform(cards, context);
|
|
4817
5099
|
}
|
|
4818
5100
|
if (opts?.hints) {
|
|
@@ -4831,6 +5113,14 @@ var init_Pipeline = __esm({
|
|
|
4831
5113
|
cards.sort((a, b) => b.score - a.score);
|
|
4832
5114
|
return opts?.limit ? cards.slice(0, opts.limit) : cards;
|
|
4833
5115
|
}
|
|
5116
|
+
/**
|
|
5117
|
+
* The filters a forecast or card-space scan applies. Those start every card at
|
|
5118
|
+
* 1.0 without a generator, so they skip `liveOnly` filters (ELO distance),
|
|
5119
|
+
* which only make sense against generator scores.
|
|
5120
|
+
*/
|
|
5121
|
+
forecastFilters() {
|
|
5122
|
+
return this.filters.filter((f) => !f.liveOnly);
|
|
5123
|
+
}
|
|
4834
5124
|
/**
|
|
4835
5125
|
* Scan every card in the course through the filter chain and report
|
|
4836
5126
|
* how many are "well indicated" (score >= threshold) for the current user.
|
|
@@ -4852,7 +5142,7 @@ var init_Pipeline = __esm({
|
|
|
4852
5142
|
cards = await this.hydrateTags(cards);
|
|
4853
5143
|
const context = await this.buildContext();
|
|
4854
5144
|
const filterBreakdown = [];
|
|
4855
|
-
for (const filter of this.
|
|
5145
|
+
for (const filter of this.forecastFilters()) {
|
|
4856
5146
|
cards = await filter.transform(cards, context);
|
|
4857
5147
|
const wi = cards.filter((c) => c.score >= THRESHOLD).length;
|
|
4858
5148
|
filterBreakdown.push({ name: filter.name, wellIndicated: wi });
|
|
@@ -4916,6 +5206,7 @@ var init_Pipeline = __esm({
|
|
|
4916
5206
|
// src/core/navigators/defaults.ts
|
|
4917
5207
|
var defaults_exports = {};
|
|
4918
5208
|
__export(defaults_exports, {
|
|
5209
|
+
createDefaultEloDistanceStrategy: () => createDefaultEloDistanceStrategy,
|
|
4919
5210
|
createDefaultEloStrategy: () => createDefaultEloStrategy,
|
|
4920
5211
|
createDefaultPipeline: () => createDefaultPipeline,
|
|
4921
5212
|
createDefaultSrsStrategy: () => createDefaultSrsStrategy
|
|
@@ -4942,12 +5233,28 @@ function createDefaultSrsStrategy(courseId) {
|
|
|
4942
5233
|
serializedData: ""
|
|
4943
5234
|
};
|
|
4944
5235
|
}
|
|
5236
|
+
function createDefaultEloDistanceStrategy(courseId) {
|
|
5237
|
+
return {
|
|
5238
|
+
_id: "NAVIGATION_STRATEGY-eloDistance-default",
|
|
5239
|
+
docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
|
|
5240
|
+
name: "ELO Distance (default)",
|
|
5241
|
+
description: "Scales every candidate, new or review, by its distance from the learner's ELO",
|
|
5242
|
+
implementingClass: "eloDistance" /* ELO_DISTANCE */,
|
|
5243
|
+
course: courseId,
|
|
5244
|
+
// Explicit, though the filter would default to it anyway: views show what runs.
|
|
5245
|
+
serializedData: JSON.stringify(DEFAULT_ELO_DISTANCE_CONFIG)
|
|
5246
|
+
};
|
|
5247
|
+
}
|
|
4945
5248
|
function createDefaultPipeline(user, course) {
|
|
4946
5249
|
const courseId = course.getCourseID();
|
|
4947
5250
|
const eloNavigator = new ELONavigator(user, course, createDefaultEloStrategy(courseId));
|
|
4948
5251
|
const srsNavigator = new SRSNavigator(user, course, createDefaultSrsStrategy(courseId));
|
|
4949
5252
|
const compositeGenerator = new CompositeGenerator([eloNavigator, srsNavigator]);
|
|
4950
|
-
const eloDistanceFilter =
|
|
5253
|
+
const eloDistanceFilter = new EloDistanceFilter(
|
|
5254
|
+
user,
|
|
5255
|
+
course,
|
|
5256
|
+
createDefaultEloDistanceStrategy(courseId)
|
|
5257
|
+
);
|
|
4951
5258
|
return new Pipeline(compositeGenerator, [eloDistanceFilter], user, course);
|
|
4952
5259
|
}
|
|
4953
5260
|
var init_defaults = __esm({
|
|
@@ -4963,6 +5270,131 @@ var init_defaults = __esm({
|
|
|
4963
5270
|
}
|
|
4964
5271
|
});
|
|
4965
5272
|
|
|
5273
|
+
// src/core/navigators/pipelinePlan.ts
|
|
5274
|
+
var pipelinePlan_exports = {};
|
|
5275
|
+
__export(pipelinePlan_exports, {
|
|
5276
|
+
PIPELINE_STAGES: () => PIPELINE_STAGES,
|
|
5277
|
+
planPipeline: () => planPipeline
|
|
5278
|
+
});
|
|
5279
|
+
function planned(strategy, role, origin) {
|
|
5280
|
+
const kind = role === "filter" /* FILTER */ ? getRegisteredFilterKind(strategy.implementingClass) : void 0;
|
|
5281
|
+
return {
|
|
5282
|
+
role,
|
|
5283
|
+
origin,
|
|
5284
|
+
name: strategy.name,
|
|
5285
|
+
implementingClass: strategy.implementingClass,
|
|
5286
|
+
strategy,
|
|
5287
|
+
...kind ? { kind } : {}
|
|
5288
|
+
};
|
|
5289
|
+
}
|
|
5290
|
+
function planPipeline(strategies, courseId) {
|
|
5291
|
+
if (strategies.length === 0) {
|
|
5292
|
+
return {
|
|
5293
|
+
kind: "default",
|
|
5294
|
+
generators: [
|
|
5295
|
+
planned(createDefaultEloStrategy(courseId), "generator" /* GENERATOR */, "default-pipeline"),
|
|
5296
|
+
planned(createDefaultSrsStrategy(courseId), "generator" /* GENERATOR */, "default-pipeline")
|
|
5297
|
+
],
|
|
5298
|
+
filters: [
|
|
5299
|
+
planned(
|
|
5300
|
+
createDefaultEloDistanceStrategy(courseId),
|
|
5301
|
+
"filter" /* FILTER */,
|
|
5302
|
+
"default-pipeline"
|
|
5303
|
+
)
|
|
5304
|
+
],
|
|
5305
|
+
skipped: [],
|
|
5306
|
+
warnings: [],
|
|
5307
|
+
notes: [],
|
|
5308
|
+
regulators: DEFAULT_REGULATOR_CONFIG
|
|
5309
|
+
};
|
|
5310
|
+
}
|
|
5311
|
+
const generators = [];
|
|
5312
|
+
const filters = [];
|
|
5313
|
+
const skipped = [];
|
|
5314
|
+
const warnings = [];
|
|
5315
|
+
for (const s of strategies) {
|
|
5316
|
+
if (isGenerator(s.implementingClass)) {
|
|
5317
|
+
generators.push(planned(s, "generator" /* GENERATOR */, "strategy-doc"));
|
|
5318
|
+
} else if (isFilter(s.implementingClass)) {
|
|
5319
|
+
filters.push(planned(s, "filter" /* FILTER */, "strategy-doc"));
|
|
5320
|
+
} else {
|
|
5321
|
+
skipped.push({ strategy: s, reason: "not a registered generator or filter" });
|
|
5322
|
+
warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
|
|
5323
|
+
}
|
|
5324
|
+
}
|
|
5325
|
+
const declared = new Set(generators.map((g) => g.implementingClass));
|
|
5326
|
+
if (!declared.has(createDefaultEloStrategy(courseId).implementingClass)) {
|
|
5327
|
+
generators.push(
|
|
5328
|
+
planned(createDefaultEloStrategy(courseId), "generator" /* GENERATOR */, "assembler-default")
|
|
5329
|
+
);
|
|
5330
|
+
}
|
|
5331
|
+
if (!declared.has(createDefaultSrsStrategy(courseId).implementingClass)) {
|
|
5332
|
+
generators.push(
|
|
5333
|
+
planned(createDefaultSrsStrategy(courseId), "generator" /* GENERATOR */, "assembler-default")
|
|
5334
|
+
);
|
|
5335
|
+
}
|
|
5336
|
+
const eloDistance = createDefaultEloDistanceStrategy(courseId);
|
|
5337
|
+
if (!filters.some((f) => f.implementingClass === eloDistance.implementingClass)) {
|
|
5338
|
+
filters.push(planned(eloDistance, "filter" /* FILTER */, "assembler-default"));
|
|
5339
|
+
}
|
|
5340
|
+
filters.sort((a, b) => a.name.localeCompare(b.name));
|
|
5341
|
+
return {
|
|
5342
|
+
kind: "assembled",
|
|
5343
|
+
generators,
|
|
5344
|
+
filters,
|
|
5345
|
+
skipped,
|
|
5346
|
+
warnings,
|
|
5347
|
+
notes: [],
|
|
5348
|
+
regulators: DEFAULT_REGULATOR_CONFIG
|
|
5349
|
+
};
|
|
5350
|
+
}
|
|
5351
|
+
var PIPELINE_STAGES;
|
|
5352
|
+
var init_pipelinePlan = __esm({
|
|
5353
|
+
"src/core/navigators/pipelinePlan.ts"() {
|
|
5354
|
+
"use strict";
|
|
5355
|
+
init_navigators();
|
|
5356
|
+
init_regulators();
|
|
5357
|
+
init_defaults();
|
|
5358
|
+
PIPELINE_STAGES = [
|
|
5359
|
+
{
|
|
5360
|
+
key: "generate",
|
|
5361
|
+
title: "Generate",
|
|
5362
|
+
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."
|
|
5363
|
+
},
|
|
5364
|
+
{
|
|
5365
|
+
key: "filter",
|
|
5366
|
+
title: "Filter",
|
|
5367
|
+
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."
|
|
5368
|
+
},
|
|
5369
|
+
{
|
|
5370
|
+
key: "drop-zero",
|
|
5371
|
+
title: "Drop zero scores",
|
|
5372
|
+
summary: "Candidates whose score reached 0 leave the pool."
|
|
5373
|
+
},
|
|
5374
|
+
{
|
|
5375
|
+
key: "regulate",
|
|
5376
|
+
title: "Regulate",
|
|
5377
|
+
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."
|
|
5378
|
+
},
|
|
5379
|
+
{
|
|
5380
|
+
key: "hints",
|
|
5381
|
+
title: "Apply hints",
|
|
5382
|
+
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."
|
|
5383
|
+
},
|
|
5384
|
+
{
|
|
5385
|
+
key: "diversity",
|
|
5386
|
+
title: "Diversity re-rank",
|
|
5387
|
+
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."
|
|
5388
|
+
},
|
|
5389
|
+
{
|
|
5390
|
+
key: "select",
|
|
5391
|
+
title: "Select",
|
|
5392
|
+
summary: "Highest scores first, up to the run's limit. The session mixes them into its supply queue."
|
|
5393
|
+
}
|
|
5394
|
+
];
|
|
5395
|
+
}
|
|
5396
|
+
});
|
|
5397
|
+
|
|
4966
5398
|
// src/core/navigators/PipelineAssembler.ts
|
|
4967
5399
|
var PipelineAssembler_exports = {};
|
|
4968
5400
|
__export(PipelineAssembler_exports, {
|
|
@@ -4977,16 +5409,16 @@ var init_PipelineAssembler = __esm({
|
|
|
4977
5409
|
init_Pipeline();
|
|
4978
5410
|
init_logger();
|
|
4979
5411
|
init_CompositeGenerator();
|
|
4980
|
-
|
|
5412
|
+
init_pipelinePlan();
|
|
4981
5413
|
PipelineAssembler = class {
|
|
4982
5414
|
/**
|
|
4983
5415
|
* Assembles a navigation pipeline from strategy documents.
|
|
4984
5416
|
*
|
|
4985
|
-
* 1.
|
|
4986
|
-
*
|
|
4987
|
-
*
|
|
4988
|
-
*
|
|
4989
|
-
*
|
|
5417
|
+
* 1. Plans: classifies by role, adds default ELO/SRS and ELO distance, orders filters
|
|
5418
|
+
* (`planPipeline`)
|
|
5419
|
+
* 2. Instantiates generators - wraps multiple in CompositeGenerator
|
|
5420
|
+
* 3. Instantiates filters
|
|
5421
|
+
* 4. Returns Pipeline(generator, filters)
|
|
4990
5422
|
*
|
|
4991
5423
|
* @param input - Strategy documents plus user/course interfaces
|
|
4992
5424
|
* @returns Assembled pipeline and any warnings
|
|
@@ -5002,28 +5434,17 @@ var init_PipelineAssembler = __esm({
|
|
|
5002
5434
|
warnings
|
|
5003
5435
|
};
|
|
5004
5436
|
}
|
|
5005
|
-
const
|
|
5006
|
-
|
|
5007
|
-
for (const
|
|
5008
|
-
if (
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
} else {
|
|
5013
|
-
warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
|
|
5437
|
+
const plan = planPipeline(strategies, course.getCourseID());
|
|
5438
|
+
warnings.push(...plan.warnings);
|
|
5439
|
+
for (const n of [...plan.generators, ...plan.filters]) {
|
|
5440
|
+
if (n.origin === "assembler-default") {
|
|
5441
|
+
logger.debug(
|
|
5442
|
+
`[PipelineAssembler] No ${n.implementingClass} ${n.role} configured, adding default`
|
|
5443
|
+
);
|
|
5014
5444
|
}
|
|
5015
5445
|
}
|
|
5016
|
-
const
|
|
5017
|
-
const
|
|
5018
|
-
const hasSrs = generatorStrategies.some((s) => s.implementingClass === "srs" /* SRS */);
|
|
5019
|
-
if (!hasElo) {
|
|
5020
|
-
logger.debug("[PipelineAssembler] No ELO generator configured, adding default");
|
|
5021
|
-
generatorStrategies.push(createDefaultEloStrategy(courseId));
|
|
5022
|
-
}
|
|
5023
|
-
if (!hasSrs) {
|
|
5024
|
-
logger.debug("[PipelineAssembler] No SRS generator configured, adding default");
|
|
5025
|
-
generatorStrategies.push(createDefaultSrsStrategy(courseId));
|
|
5026
|
-
}
|
|
5446
|
+
const generatorStrategies = plan.generators.map((g) => g.strategy);
|
|
5447
|
+
const sortedFilterStrategies = plan.filters.map((f) => f.strategy);
|
|
5027
5448
|
if (generatorStrategies.length === 0) {
|
|
5028
5449
|
warnings.push("No generator strategy found");
|
|
5029
5450
|
return {
|
|
@@ -5045,9 +5466,6 @@ var init_PipelineAssembler = __esm({
|
|
|
5045
5466
|
generator = await CompositeGenerator.fromStrategies(user, course, generatorStrategies);
|
|
5046
5467
|
}
|
|
5047
5468
|
const filters = [];
|
|
5048
|
-
const sortedFilterStrategies = [...filterStrategies].sort(
|
|
5049
|
-
(a, b) => a.name.localeCompare(b.name)
|
|
5050
|
-
);
|
|
5051
5469
|
for (const filterStrategy of sortedFilterStrategies) {
|
|
5052
5470
|
try {
|
|
5053
5471
|
const nav = await ContentNavigator.create(user, course, filterStrategy);
|
|
@@ -5115,7 +5533,9 @@ var init_3 = __esm({
|
|
|
5115
5533
|
"./generators/prescribed.ts": () => Promise.resolve().then(() => (init_prescribed(), prescribed_exports)),
|
|
5116
5534
|
"./generators/srs.ts": () => Promise.resolve().then(() => (init_srs(), srs_exports)),
|
|
5117
5535
|
"./generators/types.ts": () => Promise.resolve().then(() => (init_types(), types_exports)),
|
|
5118
|
-
"./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports))
|
|
5536
|
+
"./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports)),
|
|
5537
|
+
"./pipelinePlan.ts": () => Promise.resolve().then(() => (init_pipelinePlan(), pipelinePlan_exports)),
|
|
5538
|
+
"./regulators.ts": () => Promise.resolve().then(() => (init_regulators(), regulators_exports))
|
|
5119
5539
|
});
|
|
5120
5540
|
}
|
|
5121
5541
|
});
|
|
@@ -5136,6 +5556,7 @@ __export(navigators_exports, {
|
|
|
5136
5556
|
drainCapturedRuns: () => drainCapturedRuns,
|
|
5137
5557
|
getActivePipeline: () => getActivePipeline,
|
|
5138
5558
|
getCardOrigin: () => getCardOrigin,
|
|
5559
|
+
getRegisteredFilterKind: () => getRegisteredFilterKind,
|
|
5139
5560
|
getRegisteredNavigator: () => getRegisteredNavigator,
|
|
5140
5561
|
getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
|
|
5141
5562
|
getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
|
|
@@ -5164,6 +5585,10 @@ function hasRegisteredNavigator(implementingClass) {
|
|
|
5164
5585
|
function getRegisteredNavigatorRole(implementingClass) {
|
|
5165
5586
|
return navigatorRegistry.get(implementingClass)?.role;
|
|
5166
5587
|
}
|
|
5588
|
+
function getRegisteredFilterKind(implementingClass) {
|
|
5589
|
+
const ctor = navigatorRegistry.get(implementingClass)?.constructor;
|
|
5590
|
+
return ctor?.kind;
|
|
5591
|
+
}
|
|
5167
5592
|
function getRegisteredNavigatorNames() {
|
|
5168
5593
|
return Array.from(navigatorRegistry.keys());
|
|
5169
5594
|
}
|
|
@@ -5181,17 +5606,20 @@ async function initializeNavigatorRegistry() {
|
|
|
5181
5606
|
hierarchyModule,
|
|
5182
5607
|
interferenceModule,
|
|
5183
5608
|
relativePriorityModule,
|
|
5184
|
-
userTagPreferenceModule
|
|
5609
|
+
userTagPreferenceModule,
|
|
5610
|
+
eloDistanceModule
|
|
5185
5611
|
] = await Promise.all([
|
|
5186
5612
|
Promise.resolve().then(() => (init_hierarchyDefinition(), hierarchyDefinition_exports)),
|
|
5187
5613
|
Promise.resolve().then(() => (init_interferenceMitigator(), interferenceMitigator_exports)),
|
|
5188
5614
|
Promise.resolve().then(() => (init_relativePriority(), relativePriority_exports)),
|
|
5189
|
-
Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports))
|
|
5615
|
+
Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports)),
|
|
5616
|
+
Promise.resolve().then(() => (init_eloDistance(), eloDistance_exports))
|
|
5190
5617
|
]);
|
|
5191
5618
|
registerNavigator("hierarchyDefinition", hierarchyModule.default);
|
|
5192
5619
|
registerNavigator("interferenceMitigator", interferenceModule.default);
|
|
5193
5620
|
registerNavigator("relativePriority", relativePriorityModule.default);
|
|
5194
5621
|
registerNavigator("userTagPreference", userTagPreferenceModule.default);
|
|
5622
|
+
registerNavigator("eloDistance", eloDistanceModule.default);
|
|
5195
5623
|
logger.debug(
|
|
5196
5624
|
`[NavigatorRegistry] Initialized ${navigatorRegistry.size} navigators: ${getRegisteredNavigatorNames().join(", ")}`
|
|
5197
5625
|
);
|
|
@@ -5239,6 +5667,7 @@ var init_navigators = __esm({
|
|
|
5239
5667
|
Navigators2["INTERFERENCE"] = "interferenceMitigator";
|
|
5240
5668
|
Navigators2["RELATIVE_PRIORITY"] = "relativePriority";
|
|
5241
5669
|
Navigators2["USER_TAG_PREFERENCE"] = "userTagPreference";
|
|
5670
|
+
Navigators2["ELO_DISTANCE"] = "eloDistance";
|
|
5242
5671
|
return Navigators2;
|
|
5243
5672
|
})(Navigators || {});
|
|
5244
5673
|
NavigatorRole = /* @__PURE__ */ ((NavigatorRole2) => {
|
|
@@ -5253,7 +5682,8 @@ var init_navigators = __esm({
|
|
|
5253
5682
|
["hierarchyDefinition" /* HIERARCHY */]: "filter" /* FILTER */,
|
|
5254
5683
|
["interferenceMitigator" /* INTERFERENCE */]: "filter" /* FILTER */,
|
|
5255
5684
|
["relativePriority" /* RELATIVE_PRIORITY */]: "filter" /* FILTER */,
|
|
5256
|
-
["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER
|
|
5685
|
+
["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER */,
|
|
5686
|
+
["eloDistance" /* ELO_DISTANCE */]: "filter" /* FILTER */
|
|
5257
5687
|
};
|
|
5258
5688
|
ContentNavigator = class {
|
|
5259
5689
|
/** User interface for this navigation session */
|
|
@@ -6074,6 +6504,14 @@ ${e.stack}` : JSON.stringify(e);
|
|
|
6074
6504
|
setEphemeralHints(hints) {
|
|
6075
6505
|
this._pendingHints = hints;
|
|
6076
6506
|
}
|
|
6507
|
+
/**
|
|
6508
|
+
* Forward a presentation to the navigator (a new card restarts its intake
|
|
6509
|
+
* clock). Builds the navigator if the cached one has expired.
|
|
6510
|
+
*/
|
|
6511
|
+
notePresented(card) {
|
|
6512
|
+
if (card.status !== "new") return;
|
|
6513
|
+
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}`));
|
|
6514
|
+
}
|
|
6077
6515
|
async getWeightedCards(limit) {
|
|
6078
6516
|
const u = await this._getCurrentUser();
|
|
6079
6517
|
try {
|
|
@@ -8838,10 +9276,11 @@ function backlogHtml(backlog) {
|
|
|
8838
9276
|
const rows = backlog.map((b) => {
|
|
8839
9277
|
const hot = b.backlogMultiplier >= 3;
|
|
8840
9278
|
const multColor = b.backlogMultiplier <= 1 ? "#86efac" : hot ? "#fca5a5" : "#fcd34d";
|
|
8841
|
-
const headroom = b.backlogMultiplier > 1 ? `climbing (\xD7${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog}
|
|
9279
|
+
const headroom = b.backlogMultiplier > 1 ? `climbing (\xD7${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog} of mass in excess, unbounded)` : "healthy \u2014 no pressure";
|
|
9280
|
+
const mass = b.reviewMass !== null ? ` \xB7 mass ${b.reviewMass.toFixed(1)}` : "";
|
|
8842
9281
|
const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
|
|
8843
9282
|
const next = b.nextDueIn ? ` <span style="opacity:.6">\xB7 next due ${esc(b.nextDueIn)}</span>` : "";
|
|
8844
|
-
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>`;
|
|
9283
|
+
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>`;
|
|
8845
9284
|
}).join("");
|
|
8846
9285
|
return `<div style="margin-bottom:6px"><div style="color:#93c5fd">review backpressure</div>${rows}</div>`;
|
|
8847
9286
|
}
|
|
@@ -8980,8 +9419,9 @@ function snapshotToText(s) {
|
|
|
8980
9419
|
const headroom = b.backlogMultiplier > 1 ? "climbing" : "healthy";
|
|
8981
9420
|
const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
|
|
8982
9421
|
const next = b.nextDueIn ? `, next due ${b.nextDueIn}` : "";
|
|
9422
|
+
const mass = b.reviewMass !== null ? `, mass ${b.reviewMass.toFixed(1)}` : "";
|
|
8983
9423
|
lines.push(
|
|
8984
|
-
` ${b.courseId.slice(0, 8)}: due ${b.dueNow}/${b.scheduledTotal} (healthy ${b.healthyBacklog})${next}; pressure \xD7${b.backlogMultiplier.toFixed(2)} ${headroom}; top review ${top}`
|
|
9424
|
+
` ${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}`
|
|
8985
9425
|
);
|
|
8986
9426
|
}
|
|
8987
9427
|
}
|