@vue-skuilder/db 0.2.28 → 0.2.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{contentSource-DpQqTG3m.d.cts → contentSource-B6FrSihy.d.cts} +218 -2
- package/dist/{contentSource-BoFBwvYa.d.ts → contentSource-CqJmbOZN.d.ts} +218 -2
- package/dist/core/index.d.cts +13 -90
- package/dist/core/index.d.ts +13 -90
- package/dist/core/index.js +587 -179
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +586 -179
- package/dist/core/index.mjs.map +1 -1
- package/dist/{dataLayerProvider-D_LJT3F4.d.ts → dataLayerProvider-B9_UCvkR.d.ts} +1 -1
- package/dist/{dataLayerProvider-Dl3cAAvQ.d.cts → dataLayerProvider-DUxDqMtZ.d.cts} +1 -1
- package/dist/diagnostics/index.d.cts +79 -6
- package/dist/diagnostics/index.d.ts +79 -6
- package/dist/diagnostics/index.js +158 -4
- package/dist/diagnostics/index.js.map +1 -1
- package/dist/diagnostics/index.mjs +156 -4
- package/dist/diagnostics/index.mjs.map +1 -1
- package/dist/impl/couch/index.d.cts +11 -2
- package/dist/impl/couch/index.d.ts +11 -2
- package/dist/impl/couch/index.js +585 -179
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +585 -179
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.d.cts +8 -2
- package/dist/impl/static/index.d.ts +8 -2
- package/dist/impl/static/index.js +582 -179
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +582 -179
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/index.d.cts +66 -5
- package/dist/index.d.ts +66 -5
- package/dist/index.js +635 -180
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +622 -180
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/interfaces/contentSource.ts +7 -0
- package/src/core/navigators/Pipeline.ts +145 -13
- package/src/core/navigators/PipelineAssembler.ts +19 -40
- package/src/core/navigators/PipelineDebugger.ts +11 -2
- package/src/core/navigators/SrsDebugger.ts +37 -12
- package/src/core/navigators/defaults.ts +29 -5
- package/src/core/navigators/filters/WeightedFilter.ts +5 -1
- package/src/core/navigators/filters/eloDistance.ts +261 -76
- package/src/core/navigators/filters/hierarchyDefinition.ts +5 -1
- package/src/core/navigators/filters/index.ts +2 -2
- package/src/core/navigators/filters/interferenceMitigator.ts +5 -1
- package/src/core/navigators/filters/relativePriority.ts +5 -1
- package/src/core/navigators/filters/types.ts +24 -1
- package/src/core/navigators/filters/userTagPreference.ts +5 -1
- package/src/core/navigators/generators/elo.ts +23 -53
- package/src/core/navigators/generators/srs.ts +27 -124
- package/src/core/navigators/index.ts +31 -5
- package/src/core/navigators/pipelinePlan.ts +245 -0
- package/src/core/navigators/regulators.ts +230 -0
- package/src/core/types/studySession.ts +3 -0
- package/src/diagnostics/dataset.ts +13 -2
- package/src/diagnostics/index.ts +3 -0
- package/src/diagnostics/loader.ts +5 -2
- package/src/diagnostics/pipeline.ts +236 -0
- package/src/diagnostics/text.ts +26 -3
- package/src/impl/couch/courseDB.ts +13 -0
- package/src/impl/static/courseDB.ts +9 -0
- package/src/index.ts +4 -0
- package/src/study/SessionController.ts +20 -0
- package/src/study/SessionOverlay.ts +7 -4
- package/tests/core/navigators/PipelineAssembler.test.ts +20 -5
- package/tests/core/navigators/eloDistanceFilter.test.ts +9 -9
package/dist/core/index.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, scoredCards) {
|
|
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)
|
|
@@ -809,7 +809,8 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
|
|
|
809
809
|
newSelected,
|
|
810
810
|
cards,
|
|
811
811
|
unselectedNew,
|
|
812
|
-
discardedTail
|
|
812
|
+
discardedTail,
|
|
813
|
+
...regulators ? { regulators } : {}
|
|
813
814
|
};
|
|
814
815
|
}
|
|
815
816
|
function formatProvenance(provenance) {
|
|
@@ -1533,11 +1534,23 @@ var SrsDebugger_exports = {};
|
|
|
1533
1534
|
__export(SrsDebugger_exports, {
|
|
1534
1535
|
captureSrsBacklog: () => captureSrsBacklog,
|
|
1535
1536
|
clearSrsBacklogDebug: () => clearSrsBacklogDebug,
|
|
1536
|
-
getSrsBacklogDebug: () => getSrsBacklogDebug
|
|
1537
|
+
getSrsBacklogDebug: () => getSrsBacklogDebug,
|
|
1538
|
+
noteReviewPressure: () => noteReviewPressure
|
|
1537
1539
|
});
|
|
1538
1540
|
function captureSrsBacklog(snapshot) {
|
|
1539
1541
|
snapshots.set(snapshot.courseId, snapshot);
|
|
1540
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
|
+
}
|
|
1541
1554
|
function getSrsBacklogDebug() {
|
|
1542
1555
|
return [...snapshots.values()].sort((a, b) => b.timestamp - a.timestamp);
|
|
1543
1556
|
}
|
|
@@ -1815,14 +1828,13 @@ var elo_exports = {};
|
|
|
1815
1828
|
__export(elo_exports, {
|
|
1816
1829
|
default: () => ELONavigator
|
|
1817
1830
|
});
|
|
1818
|
-
var import_common5,
|
|
1831
|
+
var import_common5, ELONavigator;
|
|
1819
1832
|
var init_elo = __esm({
|
|
1820
1833
|
"src/core/navigators/generators/elo.ts"() {
|
|
1821
1834
|
"use strict";
|
|
1822
1835
|
init_navigators();
|
|
1823
1836
|
import_common5 = require("@vue-skuilder/common");
|
|
1824
1837
|
init_logger();
|
|
1825
|
-
ELO_RELEVANCE_SIGMA = 300;
|
|
1826
1838
|
ELONavigator = class extends ContentNavigator {
|
|
1827
1839
|
/** Human-readable name for CardGenerator interface */
|
|
1828
1840
|
name;
|
|
@@ -1831,10 +1843,8 @@ var init_elo = __esm({
|
|
|
1831
1843
|
this.name = strategyData?.name || "ELO";
|
|
1832
1844
|
}
|
|
1833
1845
|
/**
|
|
1834
|
-
* Get new cards
|
|
1835
|
-
*
|
|
1836
|
-
* Cards closer to user's ELO get higher scores.
|
|
1837
|
-
* 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.
|
|
1838
1848
|
*
|
|
1839
1849
|
* NOTE: This generator only handles NEW cards. Reviews are handled by
|
|
1840
1850
|
* SRSNavigator. Use CompositeGenerator to combine both.
|
|
@@ -1862,20 +1872,20 @@ var init_elo = __esm({
|
|
|
1862
1872
|
const scored = newCards.map((c) => {
|
|
1863
1873
|
const cardElo = c.elo ?? 1e3;
|
|
1864
1874
|
const distance = Math.abs(cardElo - userGlobalElo);
|
|
1865
|
-
const
|
|
1866
|
-
const samplingKey = relevance * (0.5 + 0.5 * Math.random());
|
|
1875
|
+
const jitter = 0.5 + 0.5 * Math.random();
|
|
1867
1876
|
return {
|
|
1868
1877
|
cardId: c.cardID,
|
|
1869
1878
|
courseId: c.courseID,
|
|
1870
|
-
score:
|
|
1879
|
+
score: jitter,
|
|
1880
|
+
cardElo,
|
|
1871
1881
|
provenance: [
|
|
1872
1882
|
{
|
|
1873
1883
|
strategy: "elo",
|
|
1874
1884
|
strategyName: this.strategyName || this.name,
|
|
1875
1885
|
strategyId: this.strategyId || "NAVIGATION_STRATEGY-ELO-default",
|
|
1876
1886
|
action: "generated",
|
|
1877
|
-
score:
|
|
1878
|
-
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)}`
|
|
1879
1889
|
}
|
|
1880
1890
|
]
|
|
1881
1891
|
};
|
|
@@ -2751,43 +2761,132 @@ var init_prescribed = __esm({
|
|
|
2751
2761
|
}
|
|
2752
2762
|
});
|
|
2753
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
|
+
|
|
2754
2870
|
// src/core/navigators/generators/srs.ts
|
|
2755
2871
|
var srs_exports = {};
|
|
2756
2872
|
__export(srs_exports, {
|
|
2757
2873
|
default: () => SRSNavigator
|
|
2758
2874
|
});
|
|
2759
|
-
var import_moment,
|
|
2875
|
+
var import_moment, SRSNavigator;
|
|
2760
2876
|
var init_srs = __esm({
|
|
2761
2877
|
"src/core/navigators/generators/srs.ts"() {
|
|
2762
2878
|
"use strict";
|
|
2763
2879
|
import_moment = __toESM(require("moment"), 1);
|
|
2764
2880
|
init_navigators();
|
|
2765
2881
|
init_SrsDebugger();
|
|
2882
|
+
init_regulators();
|
|
2766
2883
|
init_logger();
|
|
2767
|
-
DEFAULT_HEALTHY_BACKLOG = 20;
|
|
2768
|
-
BACKLOG_GROWTH_RATE = 2;
|
|
2769
2884
|
SRSNavigator = class extends ContentNavigator {
|
|
2770
2885
|
/** Human-readable name for CardGenerator interface */
|
|
2771
2886
|
name;
|
|
2772
|
-
/** Healthy backlog threshold - when exceeded, backlog pressure kicks in */
|
|
2773
|
-
healthyBacklog;
|
|
2774
2887
|
constructor(user, course, strategyData) {
|
|
2775
2888
|
super(user, course, strategyData);
|
|
2776
2889
|
this.name = strategyData?.name || "SRS";
|
|
2777
|
-
const config = this.parseConfig(strategyData?.serializedData);
|
|
2778
|
-
this.healthyBacklog = config.healthyBacklog ?? DEFAULT_HEALTHY_BACKLOG;
|
|
2779
|
-
}
|
|
2780
|
-
/**
|
|
2781
|
-
* Parse configuration from serialized JSON.
|
|
2782
|
-
*/
|
|
2783
|
-
parseConfig(serializedData) {
|
|
2784
|
-
if (!serializedData) return {};
|
|
2785
|
-
try {
|
|
2786
|
-
return JSON.parse(serializedData);
|
|
2787
|
-
} catch {
|
|
2788
|
-
logger.warn("[SRS] Failed to parse strategy config, using defaults");
|
|
2789
|
-
return {};
|
|
2790
|
-
}
|
|
2791
2890
|
}
|
|
2792
2891
|
/**
|
|
2793
2892
|
* Get review cards scored by urgency.
|
|
@@ -2795,7 +2894,6 @@ var init_srs = __esm({
|
|
|
2795
2894
|
* Score formula combines:
|
|
2796
2895
|
* - Relative overdueness: hoursOverdue / intervalHours
|
|
2797
2896
|
* - Interval recency: exponential decay favoring shorter intervals
|
|
2798
|
-
* - Backlog pressure: boost when due reviews exceed healthy threshold
|
|
2799
2897
|
*
|
|
2800
2898
|
* Cards not yet due are excluded (not scored as 0).
|
|
2801
2899
|
*
|
|
@@ -2832,7 +2930,6 @@ var init_srs = __esm({
|
|
|
2832
2930
|
}
|
|
2833
2931
|
}
|
|
2834
2932
|
}
|
|
2835
|
-
const backlogMultiplier = this.computeBacklogMultiplier(dueReviews.length);
|
|
2836
2933
|
const notDue = reviews.filter((r) => !now.isAfter(import_moment.default.utc(r.reviewTime)));
|
|
2837
2934
|
let nextDueIn = null;
|
|
2838
2935
|
if (notDue.length > 0) {
|
|
@@ -2843,9 +2940,8 @@ var init_srs = __esm({
|
|
|
2843
2940
|
nextDueIn = until.asHours() < 1 ? `${Math.round(until.asMinutes())}m` : until.asHours() < 24 ? `${Math.round(until.asHours())}h` : `${Math.round(until.asDays())}d`;
|
|
2844
2941
|
}
|
|
2845
2942
|
if (dueReviews.length > 0) {
|
|
2846
|
-
const pressureNote = backlogMultiplier > 1 ? ` [backlog pressure: \xD7${backlogMultiplier.toFixed(2)}]` : ` [healthy backlog]`;
|
|
2847
2943
|
logger.info(
|
|
2848
|
-
`[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)`
|
|
2849
2945
|
);
|
|
2850
2946
|
} else if (reviews.length > 0) {
|
|
2851
2947
|
const sortedByDue = [...reviews].sort(
|
|
@@ -2862,11 +2958,12 @@ var init_srs = __esm({
|
|
|
2862
2958
|
logger.info(`[SRS] Course ${courseId}: No reviews scheduled`);
|
|
2863
2959
|
}
|
|
2864
2960
|
const scored = dueReviews.map((review) => {
|
|
2865
|
-
const { score, reason } = this.computeUrgencyScore(review, now
|
|
2961
|
+
const { score, urgency, reason } = this.computeUrgencyScore(review, now);
|
|
2866
2962
|
return {
|
|
2867
2963
|
cardId: review.cardId,
|
|
2868
2964
|
courseId: review.courseId,
|
|
2869
2965
|
score,
|
|
2966
|
+
reviewUrgency: urgency,
|
|
2870
2967
|
reviewID: review._id,
|
|
2871
2968
|
provenance: [
|
|
2872
2969
|
{
|
|
@@ -2885,47 +2982,20 @@ var init_srs = __esm({
|
|
|
2885
2982
|
courseId,
|
|
2886
2983
|
scheduledTotal: reviews.length,
|
|
2887
2984
|
dueNow: dueReviews.length,
|
|
2888
|
-
healthyBacklog:
|
|
2889
|
-
|
|
2890
|
-
|
|
2985
|
+
healthyBacklog: DEFAULT_REGULATOR_CONFIG.reviewMass.healthyMass,
|
|
2986
|
+
reviewMass: null,
|
|
2987
|
+
backlogMultiplier: 1,
|
|
2988
|
+
backlogGrowthRate: DEFAULT_REGULATOR_CONFIG.reviewMass.rate,
|
|
2891
2989
|
topReviewScore: sorted.length > 0 ? sorted[0].score : null,
|
|
2892
2990
|
nextDueIn,
|
|
2893
2991
|
timestamp: Date.now()
|
|
2894
2992
|
});
|
|
2895
2993
|
return { cards: sorted.slice(0, limit) };
|
|
2896
2994
|
}
|
|
2897
|
-
/**
|
|
2898
|
-
* Compute the multiplicative backlog pressure based on number of due reviews.
|
|
2899
|
-
*
|
|
2900
|
-
* ×1.0 at or below the healthy threshold (no boost); above it, grows as
|
|
2901
|
-
* BACKLOG_GROWTH_RATE raised to the excess expressed in multiples of the
|
|
2902
|
-
* healthy threshold. Uncapped — self-regulating instead: reviews winning
|
|
2903
|
-
* slots depletes dueCount, which drops the ratio and relaxes the multiplier
|
|
2904
|
-
* next run.
|
|
2905
|
-
*
|
|
2906
|
-
* Examples (with default healthyBacklog=20, BACKLOG_GROWTH_RATE=1.5):
|
|
2907
|
-
* - 10 due reviews → ×1.00 (healthy)
|
|
2908
|
-
* - 20 due reviews → ×1.00 (at threshold, ratio 0)
|
|
2909
|
-
* - 40 due reviews → ×1.50 (ratio 1, 2x threshold)
|
|
2910
|
-
* - 60 due reviews → ×2.25 (ratio 2, 3x threshold — old hard cap was ×2.00 here)
|
|
2911
|
-
* - 100 due reviews → ×5.06 (ratio 4, 5x threshold)
|
|
2912
|
-
* - 160 due reviews → ×17.09 (ratio 7, 8x threshold)
|
|
2913
|
-
*
|
|
2914
|
-
* @param dueCount - Number of reviews currently due
|
|
2915
|
-
* @returns Multiplier applied to review urgency (>= 1.0, unbounded)
|
|
2916
|
-
*/
|
|
2917
|
-
computeBacklogMultiplier(dueCount) {
|
|
2918
|
-
if (dueCount <= this.healthyBacklog) {
|
|
2919
|
-
return 1;
|
|
2920
|
-
}
|
|
2921
|
-
const excess = dueCount - this.healthyBacklog;
|
|
2922
|
-
const ratio = excess / this.healthyBacklog;
|
|
2923
|
-
return Math.pow(BACKLOG_GROWTH_RATE, ratio);
|
|
2924
|
-
}
|
|
2925
2995
|
/**
|
|
2926
2996
|
* Compute urgency score for a review card.
|
|
2927
2997
|
*
|
|
2928
|
-
*
|
|
2998
|
+
* Two factors:
|
|
2929
2999
|
* 1. Relative overdueness = hoursOverdue / intervalHours
|
|
2930
3000
|
* - 2 days overdue on 3-day interval = 0.67 (urgent)
|
|
2931
3001
|
* - 2 days overdue on 180-day interval = 0.01 (not urgent)
|
|
@@ -2935,20 +3005,14 @@ var init_srs = __esm({
|
|
|
2935
3005
|
* - 30 days (720h) → ~0.56
|
|
2936
3006
|
* - 180 days → ~0.30
|
|
2937
3007
|
*
|
|
2938
|
-
*
|
|
2939
|
-
*
|
|
2940
|
-
*
|
|
2941
|
-
* Combined: (base 0.5 + urgency factors * 0.45) × backlog multiplier.
|
|
2942
|
-
* Per-card range before pressure: ~0.57–0.95. NOT clamped to 1.0 — under a
|
|
2943
|
-
* heavy backlog reviews scale onto the open scale to compete with (and exceed)
|
|
2944
|
-
* new cards; there's no ceiling at all now, so a bad enough backlog always
|
|
2945
|
-
* 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).
|
|
2946
3011
|
*
|
|
2947
3012
|
* @param review - The scheduled card to score
|
|
2948
3013
|
* @param now - Current time
|
|
2949
|
-
* @param backlogMultiplier - Pre-computed backlog multiplier (>= 1.0, unbounded)
|
|
2950
3014
|
*/
|
|
2951
|
-
computeUrgencyScore(review, now
|
|
3015
|
+
computeUrgencyScore(review, now) {
|
|
2952
3016
|
const scheduledAt = import_moment.default.utc(review.scheduledAt);
|
|
2953
3017
|
const due = import_moment.default.utc(review.reviewTime);
|
|
2954
3018
|
const intervalHours = Math.max(1, due.diff(scheduledAt, "hours"));
|
|
@@ -2957,20 +3021,16 @@ var init_srs = __esm({
|
|
|
2957
3021
|
const recencyFactor = 0.3 + 0.7 * Math.exp(-intervalHours / 720);
|
|
2958
3022
|
const overdueContribution = Math.min(1, Math.max(0, relativeOverdue));
|
|
2959
3023
|
const urgency = overdueContribution * 0.5 + recencyFactor * 0.5;
|
|
2960
|
-
const
|
|
2961
|
-
const score = baseScore * backlogMultiplier;
|
|
3024
|
+
const score = 0.5 + urgency * 0.45;
|
|
2962
3025
|
const reasonParts = [
|
|
2963
3026
|
`${Math.round(hoursOverdue)}h overdue`,
|
|
2964
3027
|
`interval: ${Math.round(intervalHours)}h`,
|
|
2965
3028
|
`relative: ${relativeOverdue.toFixed(2)}`,
|
|
2966
3029
|
`recency: ${recencyFactor.toFixed(2)}`
|
|
2967
3030
|
];
|
|
2968
|
-
if (backlogMultiplier > 1) {
|
|
2969
|
-
reasonParts.push(`backlog: \xD7${backlogMultiplier.toFixed(2)}`);
|
|
2970
|
-
}
|
|
2971
3031
|
reasonParts.push("review");
|
|
2972
3032
|
const reason = reasonParts.join(", ");
|
|
2973
|
-
return { score, reason };
|
|
3033
|
+
return { score, urgency, reason };
|
|
2974
3034
|
}
|
|
2975
3035
|
};
|
|
2976
3036
|
}
|
|
@@ -3025,6 +3085,8 @@ var init_WeightedFilter = __esm({
|
|
|
3025
3085
|
init_contentNavigationStrategy();
|
|
3026
3086
|
WeightedFilter = class {
|
|
3027
3087
|
name;
|
|
3088
|
+
kind;
|
|
3089
|
+
liveOnly;
|
|
3028
3090
|
inner;
|
|
3029
3091
|
learnable;
|
|
3030
3092
|
staticWeight;
|
|
@@ -3032,6 +3094,8 @@ var init_WeightedFilter = __esm({
|
|
|
3032
3094
|
constructor(inner, learnable = DEFAULT_LEARNABLE_WEIGHT, staticWeight = false, strategyId) {
|
|
3033
3095
|
this.inner = inner;
|
|
3034
3096
|
this.name = inner.name;
|
|
3097
|
+
this.kind = inner.kind;
|
|
3098
|
+
this.liveOnly = inner.liveOnly;
|
|
3035
3099
|
this.learnable = learnable;
|
|
3036
3100
|
this.staticWeight = staticWeight;
|
|
3037
3101
|
this.strategyId = strategyId;
|
|
@@ -3096,58 +3160,141 @@ var init_WeightedFilter = __esm({
|
|
|
3096
3160
|
// src/core/navigators/filters/eloDistance.ts
|
|
3097
3161
|
var eloDistance_exports = {};
|
|
3098
3162
|
__export(eloDistance_exports, {
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3163
|
+
DEFAULT_ELO_DISTANCE_CONFIG: () => DEFAULT_ELO_DISTANCE_CONFIG,
|
|
3164
|
+
createEloDistanceFilter: () => createEloDistanceFilter,
|
|
3165
|
+
default: () => EloDistanceFilter,
|
|
3166
|
+
tagAwareGap: () => tagAwareGap
|
|
3103
3167
|
});
|
|
3104
3168
|
function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
|
|
3105
3169
|
const normalizedDistance = distance / halfLife;
|
|
3106
3170
|
const decay = Math.exp(-(normalizedDistance * normalizedDistance));
|
|
3107
3171
|
return minMultiplier + (maxMultiplier - minMultiplier) * decay;
|
|
3108
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
|
+
}
|
|
3109
3243
|
function createEloDistanceFilter(config) {
|
|
3110
|
-
const
|
|
3111
|
-
const
|
|
3112
|
-
const maxMultiplier = config?.maxMultiplier ?? DEFAULT_MAX_MULTIPLIER;
|
|
3244
|
+
const resolved = resolveConfig(config);
|
|
3245
|
+
const source = { name: "ELO Distance Filter", strategyId: "ELO_DISTANCE_FILTER" };
|
|
3113
3246
|
return {
|
|
3114
|
-
name:
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
const cardElos = await course.getCardEloData(cardIds);
|
|
3119
|
-
return cards.map((card, i) => {
|
|
3120
|
-
const cardElo = cardElos[i]?.global?.score ?? 1e3;
|
|
3121
|
-
const distance = Math.abs(cardElo - userElo);
|
|
3122
|
-
const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
|
|
3123
|
-
const newScore = card.score * multiplier;
|
|
3124
|
-
const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
|
|
3125
|
-
return {
|
|
3126
|
-
...card,
|
|
3127
|
-
score: newScore,
|
|
3128
|
-
provenance: [
|
|
3129
|
-
...card.provenance,
|
|
3130
|
-
{
|
|
3131
|
-
strategy: "eloDistance",
|
|
3132
|
-
strategyName: "ELO Distance Filter",
|
|
3133
|
-
strategyId: "ELO_DISTANCE_FILTER",
|
|
3134
|
-
action,
|
|
3135
|
-
score: newScore,
|
|
3136
|
-
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)}) \u2192 ${multiplier.toFixed(2)}x`
|
|
3137
|
-
}
|
|
3138
|
-
]
|
|
3139
|
-
};
|
|
3140
|
-
});
|
|
3141
|
-
}
|
|
3247
|
+
name: source.name,
|
|
3248
|
+
kind: "signal",
|
|
3249
|
+
liveOnly: true,
|
|
3250
|
+
transform: (cards, context) => applyEloDistance(cards, context, resolved, source)
|
|
3142
3251
|
};
|
|
3143
3252
|
}
|
|
3144
|
-
var
|
|
3253
|
+
var DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, COUNT_ONLY_SENTINEL, DEFAULT_CARD_ELO, EloDistanceFilter;
|
|
3145
3254
|
var init_eloDistance = __esm({
|
|
3146
3255
|
"src/core/navigators/filters/eloDistance.ts"() {
|
|
3147
3256
|
"use strict";
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
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
|
+
};
|
|
3151
3298
|
}
|
|
3152
3299
|
});
|
|
3153
3300
|
|
|
@@ -3164,10 +3311,13 @@ var init_hierarchyDefinition = __esm({
|
|
|
3164
3311
|
import_common6 = require("@vue-skuilder/common");
|
|
3165
3312
|
init_logger();
|
|
3166
3313
|
DEFAULT_MIN_COUNT2 = 3;
|
|
3167
|
-
HierarchyDefinitionNavigator = class extends ContentNavigator {
|
|
3314
|
+
HierarchyDefinitionNavigator = class _HierarchyDefinitionNavigator extends ContentNavigator {
|
|
3168
3315
|
config;
|
|
3169
3316
|
/** Human-readable name for CardFilter interface */
|
|
3170
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;
|
|
3171
3321
|
constructor(user, course, strategyData) {
|
|
3172
3322
|
super(user, course, strategyData);
|
|
3173
3323
|
this.config = this.parseConfig(strategyData.serializedData);
|
|
@@ -3434,10 +3584,13 @@ var init_userTagPreference = __esm({
|
|
|
3434
3584
|
"src/core/navigators/filters/userTagPreference.ts"() {
|
|
3435
3585
|
"use strict";
|
|
3436
3586
|
init_navigators();
|
|
3437
|
-
UserTagPreferenceFilter = class extends ContentNavigator {
|
|
3587
|
+
UserTagPreferenceFilter = class _UserTagPreferenceFilter extends ContentNavigator {
|
|
3438
3588
|
_strategyData;
|
|
3439
3589
|
/** Human-readable name for CardFilter interface */
|
|
3440
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;
|
|
3441
3594
|
constructor(user, course, strategyData) {
|
|
3442
3595
|
super(user, course, strategyData);
|
|
3443
3596
|
this._strategyData = strategyData;
|
|
@@ -3547,6 +3700,7 @@ var init_userTagPreference = __esm({
|
|
|
3547
3700
|
// src/core/navigators/filters/index.ts
|
|
3548
3701
|
var filters_exports = {};
|
|
3549
3702
|
__export(filters_exports, {
|
|
3703
|
+
EloDistanceFilter: () => EloDistanceFilter,
|
|
3550
3704
|
UserTagPreferenceFilter: () => UserTagPreferenceFilter,
|
|
3551
3705
|
createEloDistanceFilter: () => createEloDistanceFilter
|
|
3552
3706
|
});
|
|
@@ -3585,10 +3739,13 @@ var init_interferenceMitigator = __esm({
|
|
|
3585
3739
|
DEFAULT_MIN_COUNT3 = 10;
|
|
3586
3740
|
DEFAULT_MIN_ELAPSED_DAYS = 3;
|
|
3587
3741
|
DEFAULT_INTERFERENCE_DECAY = 0.8;
|
|
3588
|
-
InterferenceMitigatorNavigator = class extends ContentNavigator {
|
|
3742
|
+
InterferenceMitigatorNavigator = class _InterferenceMitigatorNavigator extends ContentNavigator {
|
|
3589
3743
|
config;
|
|
3590
3744
|
/** Human-readable name for CardFilter interface */
|
|
3591
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;
|
|
3592
3749
|
/** Precomputed map: tag -> set of { partner, decay } it interferes with */
|
|
3593
3750
|
interferenceMap;
|
|
3594
3751
|
constructor(user, course, strategyData) {
|
|
@@ -3804,10 +3961,13 @@ var init_relativePriority = __esm({
|
|
|
3804
3961
|
DEFAULT_PRIORITY = 0.5;
|
|
3805
3962
|
DEFAULT_PRIORITY_INFLUENCE = 0.5;
|
|
3806
3963
|
DEFAULT_COMBINE_MODE = "max";
|
|
3807
|
-
RelativePriorityNavigator = class extends ContentNavigator {
|
|
3964
|
+
RelativePriorityNavigator = class _RelativePriorityNavigator extends ContentNavigator {
|
|
3808
3965
|
config;
|
|
3809
3966
|
/** Human-readable name for CardFilter interface */
|
|
3810
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;
|
|
3811
3971
|
constructor(user, course, strategyData) {
|
|
3812
3972
|
super(user, course, strategyData);
|
|
3813
3973
|
this.config = this.parseConfig(strategyData.serializedData);
|
|
@@ -4461,6 +4621,8 @@ var init_Pipeline = __esm({
|
|
|
4461
4621
|
init_orchestration();
|
|
4462
4622
|
init_PipelineDebugger();
|
|
4463
4623
|
init_diversityRerank();
|
|
4624
|
+
init_regulators();
|
|
4625
|
+
init_SrsDebugger();
|
|
4464
4626
|
VERBOSE_RESULTS = true;
|
|
4465
4627
|
Pipeline = class extends ContentNavigator {
|
|
4466
4628
|
generator;
|
|
@@ -4486,6 +4648,13 @@ var init_Pipeline = __esm({
|
|
|
4486
4648
|
* getWeightedCards() call, then cleared.
|
|
4487
4649
|
*/
|
|
4488
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();
|
|
4489
4658
|
/**
|
|
4490
4659
|
* Create a new pipeline.
|
|
4491
4660
|
*
|
|
@@ -4560,13 +4729,12 @@ var init_Pipeline = __esm({
|
|
|
4560
4729
|
}
|
|
4561
4730
|
}
|
|
4562
4731
|
generatorSummaries = Array.from(genMap.entries()).map(([name, data]) => {
|
|
4563
|
-
const
|
|
4564
|
-
const reviewCards = data.cards.filter((c) => c.provenance[0]?.reason?.includes("review"));
|
|
4732
|
+
const reviewCount = data.cards.filter((c) => c.reviewID).length;
|
|
4565
4733
|
return {
|
|
4566
4734
|
name,
|
|
4567
4735
|
cardCount: data.cards.length,
|
|
4568
|
-
newCount:
|
|
4569
|
-
reviewCount
|
|
4736
|
+
newCount: data.cards.length - reviewCount,
|
|
4737
|
+
reviewCount,
|
|
4570
4738
|
topScore: Math.max(...data.cards.map((c) => c.score), 0)
|
|
4571
4739
|
};
|
|
4572
4740
|
});
|
|
@@ -4602,19 +4770,24 @@ var init_Pipeline = __esm({
|
|
|
4602
4770
|
cards.filter((c) => c.provenance.some((p) => p.strategy === "prescribed")).map((c) => c.cardId)
|
|
4603
4771
|
);
|
|
4604
4772
|
const filterImpacts = [];
|
|
4773
|
+
const generatedScores = new Map(cards.map((c) => [c.cardId, c.score]));
|
|
4774
|
+
const gated = /* @__PURE__ */ new Set();
|
|
4605
4775
|
for (const filter of this.filters) {
|
|
4606
4776
|
const beforeCount = cards.length;
|
|
4607
4777
|
const beforeScores = new Map(cards.map((c) => [c.cardId, c.score]));
|
|
4608
4778
|
cards = await filter.transform(cards, context);
|
|
4609
4779
|
let boosted = 0, penalized = 0, passed = 0;
|
|
4610
4780
|
const removed = beforeCount - cards.length;
|
|
4781
|
+
const kind = filter.kind ?? "gate";
|
|
4611
4782
|
for (const card of cards) {
|
|
4612
4783
|
const before = beforeScores.get(card.cardId) ?? 0;
|
|
4613
4784
|
if (card.score > before) boosted++;
|
|
4614
|
-
else if (card.score < before)
|
|
4615
|
-
|
|
4785
|
+
else if (card.score < before) {
|
|
4786
|
+
penalized++;
|
|
4787
|
+
if (kind === "gate") gated.add(card.cardId);
|
|
4788
|
+
} else passed++;
|
|
4616
4789
|
}
|
|
4617
|
-
filterImpacts.push({ name: filter.name, boosted, penalized, passed, removed });
|
|
4790
|
+
filterImpacts.push({ name: filter.name, kind, boosted, penalized, passed, removed });
|
|
4618
4791
|
if (prescribedIds.size > 0) {
|
|
4619
4792
|
const survivingIds = new Set(cards.map((c) => c.cardId));
|
|
4620
4793
|
const killedPrescribed = [...prescribedIds].filter((id) => !survivingIds.has(id));
|
|
@@ -4630,6 +4803,7 @@ var init_Pipeline = __esm({
|
|
|
4630
4803
|
}
|
|
4631
4804
|
const scoredCards = cards;
|
|
4632
4805
|
cards = cards.filter((c) => c.score > 0);
|
|
4806
|
+
const regulators = await this.regulate(cards, generatedScores, gated);
|
|
4633
4807
|
const hints = this._ephemeralHints;
|
|
4634
4808
|
if (hints) {
|
|
4635
4809
|
this._ephemeralHints = null;
|
|
@@ -4666,7 +4840,8 @@ var init_Pipeline = __esm({
|
|
|
4666
4840
|
result,
|
|
4667
4841
|
context.userElo,
|
|
4668
4842
|
hints ?? void 0,
|
|
4669
|
-
scoredCards
|
|
4843
|
+
scoredCards,
|
|
4844
|
+
regulators
|
|
4670
4845
|
);
|
|
4671
4846
|
captureRun(report);
|
|
4672
4847
|
} catch (e) {
|
|
@@ -4845,6 +5020,77 @@ var init_Pipeline = __esm({
|
|
|
4845
5020
|
logger.info(`[Pipeline] Hints applied: ${beforeCount} \u2192 ${cards.length} cards`);
|
|
4846
5021
|
return cards;
|
|
4847
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
|
+
}
|
|
4848
5094
|
/**
|
|
4849
5095
|
* Build shared context for generator and filters.
|
|
4850
5096
|
*
|
|
@@ -4855,10 +5101,11 @@ var init_Pipeline = __esm({
|
|
|
4855
5101
|
*/
|
|
4856
5102
|
async buildContext() {
|
|
4857
5103
|
let userElo = 1e3;
|
|
5104
|
+
let userCourseElo;
|
|
4858
5105
|
try {
|
|
4859
5106
|
const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
|
|
4860
|
-
|
|
4861
|
-
userElo =
|
|
5107
|
+
userCourseElo = (0, import_common8.toCourseElo)(courseReg.elo);
|
|
5108
|
+
userElo = userCourseElo.global.score;
|
|
4862
5109
|
} catch (e) {
|
|
4863
5110
|
logger.debug(`[Pipeline] Could not get user ELO, using default: ${e}`);
|
|
4864
5111
|
}
|
|
@@ -4870,6 +5117,7 @@ var init_Pipeline = __esm({
|
|
|
4870
5117
|
user: this.user,
|
|
4871
5118
|
course: this.course,
|
|
4872
5119
|
userElo,
|
|
5120
|
+
...userCourseElo ? { userCourseElo } : {},
|
|
4873
5121
|
orchestration
|
|
4874
5122
|
};
|
|
4875
5123
|
}
|
|
@@ -4983,7 +5231,7 @@ var init_Pipeline = __esm({
|
|
|
4983
5231
|
cards = await this.hydrateTags(cards);
|
|
4984
5232
|
const fullPool = cards.slice();
|
|
4985
5233
|
const context = await this.buildContext();
|
|
4986
|
-
for (const filter of this.
|
|
5234
|
+
for (const filter of this.forecastFilters()) {
|
|
4987
5235
|
cards = await filter.transform(cards, context);
|
|
4988
5236
|
}
|
|
4989
5237
|
if (opts?.hints) {
|
|
@@ -5002,6 +5250,14 @@ var init_Pipeline = __esm({
|
|
|
5002
5250
|
cards.sort((a, b) => b.score - a.score);
|
|
5003
5251
|
return opts?.limit ? cards.slice(0, opts.limit) : cards;
|
|
5004
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
|
+
}
|
|
5005
5261
|
/**
|
|
5006
5262
|
* Scan every card in the course through the filter chain and report
|
|
5007
5263
|
* how many are "well indicated" (score >= threshold) for the current user.
|
|
@@ -5023,7 +5279,7 @@ var init_Pipeline = __esm({
|
|
|
5023
5279
|
cards = await this.hydrateTags(cards);
|
|
5024
5280
|
const context = await this.buildContext();
|
|
5025
5281
|
const filterBreakdown = [];
|
|
5026
|
-
for (const filter of this.
|
|
5282
|
+
for (const filter of this.forecastFilters()) {
|
|
5027
5283
|
cards = await filter.transform(cards, context);
|
|
5028
5284
|
const wi = cards.filter((c) => c.score >= THRESHOLD).length;
|
|
5029
5285
|
filterBreakdown.push({ name: filter.name, wellIndicated: wi });
|
|
@@ -5087,6 +5343,7 @@ var init_Pipeline = __esm({
|
|
|
5087
5343
|
// src/core/navigators/defaults.ts
|
|
5088
5344
|
var defaults_exports = {};
|
|
5089
5345
|
__export(defaults_exports, {
|
|
5346
|
+
createDefaultEloDistanceStrategy: () => createDefaultEloDistanceStrategy,
|
|
5090
5347
|
createDefaultEloStrategy: () => createDefaultEloStrategy,
|
|
5091
5348
|
createDefaultPipeline: () => createDefaultPipeline,
|
|
5092
5349
|
createDefaultSrsStrategy: () => createDefaultSrsStrategy
|
|
@@ -5113,12 +5370,28 @@ function createDefaultSrsStrategy(courseId) {
|
|
|
5113
5370
|
serializedData: ""
|
|
5114
5371
|
};
|
|
5115
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
|
+
}
|
|
5116
5385
|
function createDefaultPipeline(user, course) {
|
|
5117
5386
|
const courseId = course.getCourseID();
|
|
5118
5387
|
const eloNavigator = new ELONavigator(user, course, createDefaultEloStrategy(courseId));
|
|
5119
5388
|
const srsNavigator = new SRSNavigator(user, course, createDefaultSrsStrategy(courseId));
|
|
5120
5389
|
const compositeGenerator = new CompositeGenerator([eloNavigator, srsNavigator]);
|
|
5121
|
-
const eloDistanceFilter =
|
|
5390
|
+
const eloDistanceFilter = new EloDistanceFilter(
|
|
5391
|
+
user,
|
|
5392
|
+
course,
|
|
5393
|
+
createDefaultEloDistanceStrategy(courseId)
|
|
5394
|
+
);
|
|
5122
5395
|
return new Pipeline(compositeGenerator, [eloDistanceFilter], user, course);
|
|
5123
5396
|
}
|
|
5124
5397
|
var init_defaults = __esm({
|
|
@@ -5134,6 +5407,131 @@ var init_defaults = __esm({
|
|
|
5134
5407
|
}
|
|
5135
5408
|
});
|
|
5136
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
|
+
|
|
5137
5535
|
// src/core/navigators/PipelineAssembler.ts
|
|
5138
5536
|
var PipelineAssembler_exports = {};
|
|
5139
5537
|
__export(PipelineAssembler_exports, {
|
|
@@ -5148,16 +5546,16 @@ var init_PipelineAssembler = __esm({
|
|
|
5148
5546
|
init_Pipeline();
|
|
5149
5547
|
init_logger();
|
|
5150
5548
|
init_CompositeGenerator();
|
|
5151
|
-
|
|
5549
|
+
init_pipelinePlan();
|
|
5152
5550
|
PipelineAssembler = class {
|
|
5153
5551
|
/**
|
|
5154
5552
|
* Assembles a navigation pipeline from strategy documents.
|
|
5155
5553
|
*
|
|
5156
|
-
* 1.
|
|
5157
|
-
*
|
|
5158
|
-
*
|
|
5159
|
-
*
|
|
5160
|
-
*
|
|
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)
|
|
5161
5559
|
*
|
|
5162
5560
|
* @param input - Strategy documents plus user/course interfaces
|
|
5163
5561
|
* @returns Assembled pipeline and any warnings
|
|
@@ -5173,28 +5571,17 @@ var init_PipelineAssembler = __esm({
|
|
|
5173
5571
|
warnings
|
|
5174
5572
|
};
|
|
5175
5573
|
}
|
|
5176
|
-
const
|
|
5177
|
-
|
|
5178
|
-
for (const
|
|
5179
|
-
if (
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
} else {
|
|
5184
|
-
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
|
+
);
|
|
5185
5581
|
}
|
|
5186
5582
|
}
|
|
5187
|
-
const
|
|
5188
|
-
const
|
|
5189
|
-
const hasSrs = generatorStrategies.some((s) => s.implementingClass === "srs" /* SRS */);
|
|
5190
|
-
if (!hasElo) {
|
|
5191
|
-
logger.debug("[PipelineAssembler] No ELO generator configured, adding default");
|
|
5192
|
-
generatorStrategies.push(createDefaultEloStrategy(courseId));
|
|
5193
|
-
}
|
|
5194
|
-
if (!hasSrs) {
|
|
5195
|
-
logger.debug("[PipelineAssembler] No SRS generator configured, adding default");
|
|
5196
|
-
generatorStrategies.push(createDefaultSrsStrategy(courseId));
|
|
5197
|
-
}
|
|
5583
|
+
const generatorStrategies = plan.generators.map((g) => g.strategy);
|
|
5584
|
+
const sortedFilterStrategies = plan.filters.map((f) => f.strategy);
|
|
5198
5585
|
if (generatorStrategies.length === 0) {
|
|
5199
5586
|
warnings.push("No generator strategy found");
|
|
5200
5587
|
return {
|
|
@@ -5216,9 +5603,6 @@ var init_PipelineAssembler = __esm({
|
|
|
5216
5603
|
generator = await CompositeGenerator.fromStrategies(user, course, generatorStrategies);
|
|
5217
5604
|
}
|
|
5218
5605
|
const filters = [];
|
|
5219
|
-
const sortedFilterStrategies = [...filterStrategies].sort(
|
|
5220
|
-
(a, b) => a.name.localeCompare(b.name)
|
|
5221
|
-
);
|
|
5222
5606
|
for (const filterStrategy of sortedFilterStrategies) {
|
|
5223
5607
|
try {
|
|
5224
5608
|
const nav = await ContentNavigator.create(user, course, filterStrategy);
|
|
@@ -5286,7 +5670,9 @@ var init_3 = __esm({
|
|
|
5286
5670
|
"./generators/prescribed.ts": () => Promise.resolve().then(() => (init_prescribed(), prescribed_exports)),
|
|
5287
5671
|
"./generators/srs.ts": () => Promise.resolve().then(() => (init_srs(), srs_exports)),
|
|
5288
5672
|
"./generators/types.ts": () => Promise.resolve().then(() => (init_types(), types_exports)),
|
|
5289
|
-
"./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))
|
|
5290
5676
|
});
|
|
5291
5677
|
}
|
|
5292
5678
|
});
|
|
@@ -5307,6 +5693,7 @@ __export(navigators_exports, {
|
|
|
5307
5693
|
drainCapturedRuns: () => drainCapturedRuns,
|
|
5308
5694
|
getActivePipeline: () => getActivePipeline,
|
|
5309
5695
|
getCardOrigin: () => getCardOrigin,
|
|
5696
|
+
getRegisteredFilterKind: () => getRegisteredFilterKind,
|
|
5310
5697
|
getRegisteredNavigator: () => getRegisteredNavigator,
|
|
5311
5698
|
getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
|
|
5312
5699
|
getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
|
|
@@ -5335,6 +5722,10 @@ function hasRegisteredNavigator(implementingClass) {
|
|
|
5335
5722
|
function getRegisteredNavigatorRole(implementingClass) {
|
|
5336
5723
|
return navigatorRegistry.get(implementingClass)?.role;
|
|
5337
5724
|
}
|
|
5725
|
+
function getRegisteredFilterKind(implementingClass) {
|
|
5726
|
+
const ctor = navigatorRegistry.get(implementingClass)?.constructor;
|
|
5727
|
+
return ctor?.kind;
|
|
5728
|
+
}
|
|
5338
5729
|
function getRegisteredNavigatorNames() {
|
|
5339
5730
|
return Array.from(navigatorRegistry.keys());
|
|
5340
5731
|
}
|
|
@@ -5352,17 +5743,20 @@ async function initializeNavigatorRegistry() {
|
|
|
5352
5743
|
hierarchyModule,
|
|
5353
5744
|
interferenceModule,
|
|
5354
5745
|
relativePriorityModule,
|
|
5355
|
-
userTagPreferenceModule
|
|
5746
|
+
userTagPreferenceModule,
|
|
5747
|
+
eloDistanceModule
|
|
5356
5748
|
] = await Promise.all([
|
|
5357
5749
|
Promise.resolve().then(() => (init_hierarchyDefinition(), hierarchyDefinition_exports)),
|
|
5358
5750
|
Promise.resolve().then(() => (init_interferenceMitigator(), interferenceMitigator_exports)),
|
|
5359
5751
|
Promise.resolve().then(() => (init_relativePriority(), relativePriority_exports)),
|
|
5360
|
-
Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports))
|
|
5752
|
+
Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports)),
|
|
5753
|
+
Promise.resolve().then(() => (init_eloDistance(), eloDistance_exports))
|
|
5361
5754
|
]);
|
|
5362
5755
|
registerNavigator("hierarchyDefinition", hierarchyModule.default);
|
|
5363
5756
|
registerNavigator("interferenceMitigator", interferenceModule.default);
|
|
5364
5757
|
registerNavigator("relativePriority", relativePriorityModule.default);
|
|
5365
5758
|
registerNavigator("userTagPreference", userTagPreferenceModule.default);
|
|
5759
|
+
registerNavigator("eloDistance", eloDistanceModule.default);
|
|
5366
5760
|
logger.debug(
|
|
5367
5761
|
`[NavigatorRegistry] Initialized ${navigatorRegistry.size} navigators: ${getRegisteredNavigatorNames().join(", ")}`
|
|
5368
5762
|
);
|
|
@@ -5410,6 +5804,7 @@ var init_navigators = __esm({
|
|
|
5410
5804
|
Navigators2["INTERFERENCE"] = "interferenceMitigator";
|
|
5411
5805
|
Navigators2["RELATIVE_PRIORITY"] = "relativePriority";
|
|
5412
5806
|
Navigators2["USER_TAG_PREFERENCE"] = "userTagPreference";
|
|
5807
|
+
Navigators2["ELO_DISTANCE"] = "eloDistance";
|
|
5413
5808
|
return Navigators2;
|
|
5414
5809
|
})(Navigators || {});
|
|
5415
5810
|
NavigatorRole = /* @__PURE__ */ ((NavigatorRole2) => {
|
|
@@ -5424,7 +5819,8 @@ var init_navigators = __esm({
|
|
|
5424
5819
|
["hierarchyDefinition" /* HIERARCHY */]: "filter" /* FILTER */,
|
|
5425
5820
|
["interferenceMitigator" /* INTERFERENCE */]: "filter" /* FILTER */,
|
|
5426
5821
|
["relativePriority" /* RELATIVE_PRIORITY */]: "filter" /* FILTER */,
|
|
5427
|
-
["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER
|
|
5822
|
+
["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER */,
|
|
5823
|
+
["eloDistance" /* ELO_DISTANCE */]: "filter" /* FILTER */
|
|
5428
5824
|
};
|
|
5429
5825
|
ContentNavigator = class {
|
|
5430
5826
|
/** User interface for this navigation session */
|
|
@@ -6158,6 +6554,14 @@ ${e.stack}` : JSON.stringify(e);
|
|
|
6158
6554
|
setEphemeralHints(hints) {
|
|
6159
6555
|
this._pendingHints = hints;
|
|
6160
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
|
+
}
|
|
6161
6565
|
async getWeightedCards(limit) {
|
|
6162
6566
|
const u = await this._getCurrentUser();
|
|
6163
6567
|
try {
|
|
@@ -8207,10 +8611,11 @@ function backlogHtml(backlog) {
|
|
|
8207
8611
|
const rows = backlog.map((b) => {
|
|
8208
8612
|
const hot = b.backlogMultiplier >= 3;
|
|
8209
8613
|
const multColor = b.backlogMultiplier <= 1 ? "#86efac" : hot ? "#fca5a5" : "#fcd34d";
|
|
8210
|
-
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)}` : "";
|
|
8211
8616
|
const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
|
|
8212
8617
|
const next = b.nextDueIn ? ` <span style="opacity:.6">\xB7 next due ${esc(b.nextDueIn)}</span>` : "";
|
|
8213
|
-
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>`;
|
|
8214
8619
|
}).join("");
|
|
8215
8620
|
return `<div style="margin-bottom:6px"><div style="color:#93c5fd">review backpressure</div>${rows}</div>`;
|
|
8216
8621
|
}
|
|
@@ -8349,8 +8754,9 @@ function snapshotToText(s) {
|
|
|
8349
8754
|
const headroom = b.backlogMultiplier > 1 ? "climbing" : "healthy";
|
|
8350
8755
|
const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
|
|
8351
8756
|
const next = b.nextDueIn ? `, next due ${b.nextDueIn}` : "";
|
|
8757
|
+
const mass = b.reviewMass !== null ? `, mass ${b.reviewMass.toFixed(1)}` : "";
|
|
8352
8758
|
lines.push(
|
|
8353
|
-
` ${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}`
|
|
8354
8760
|
);
|
|
8355
8761
|
}
|
|
8356
8762
|
}
|
|
@@ -10832,6 +11238,7 @@ __export(core_exports, {
|
|
|
10832
11238
|
getCardHistoryID: () => getCardHistoryID,
|
|
10833
11239
|
getCardOrigin: () => getCardOrigin,
|
|
10834
11240
|
getDefaultLearnableWeight: () => getDefaultLearnableWeight,
|
|
11241
|
+
getRegisteredFilterKind: () => getRegisteredFilterKind,
|
|
10835
11242
|
getRegisteredNavigator: () => getRegisteredNavigator,
|
|
10836
11243
|
getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
|
|
10837
11244
|
getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
|
|
@@ -10914,6 +11321,7 @@ init_core();
|
|
|
10914
11321
|
getCardHistoryID,
|
|
10915
11322
|
getCardOrigin,
|
|
10916
11323
|
getDefaultLearnableWeight,
|
|
11324
|
+
getRegisteredFilterKind,
|
|
10917
11325
|
getRegisteredNavigator,
|
|
10918
11326
|
getRegisteredNavigatorNames,
|
|
10919
11327
|
getRegisteredNavigatorRole,
|