@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
|
@@ -509,7 +509,7 @@ function parseCardElo(provenance) {
|
|
|
509
509
|
const match = eloEntry.reason.match(/card:\s*(\d+)/);
|
|
510
510
|
return match ? parseInt(match[1], 10) : void 0;
|
|
511
511
|
}
|
|
512
|
-
function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints, scoredCards) {
|
|
512
|
+
function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints, scoredCards, regulators) {
|
|
513
513
|
const selectedIds = new Set(selectedCards.map((c) => c.cardId));
|
|
514
514
|
const toReport = (card) => ({
|
|
515
515
|
cardId: card.cardId,
|
|
@@ -517,7 +517,7 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
|
|
|
517
517
|
origin: getOrigin(card),
|
|
518
518
|
generator: card.provenance[0]?.strategyName || card.provenance[0]?.strategy,
|
|
519
519
|
finalScore: card.score,
|
|
520
|
-
cardElo: parseCardElo(card.provenance),
|
|
520
|
+
cardElo: card.cardElo ?? parseCardElo(card.provenance),
|
|
521
521
|
provenance: card.provenance,
|
|
522
522
|
tags: card.tags,
|
|
523
523
|
selected: selectedIds.has(card.cardId)
|
|
@@ -595,7 +595,8 @@ function buildRunReport(courseId, courseName, generatorName, generators, generat
|
|
|
595
595
|
newSelected,
|
|
596
596
|
cards,
|
|
597
597
|
unselectedNew,
|
|
598
|
-
discardedTail
|
|
598
|
+
discardedTail,
|
|
599
|
+
...regulators ? { regulators } : {}
|
|
599
600
|
};
|
|
600
601
|
}
|
|
601
602
|
function formatProvenance(provenance) {
|
|
@@ -1319,11 +1320,23 @@ var SrsDebugger_exports = {};
|
|
|
1319
1320
|
__export(SrsDebugger_exports, {
|
|
1320
1321
|
captureSrsBacklog: () => captureSrsBacklog,
|
|
1321
1322
|
clearSrsBacklogDebug: () => clearSrsBacklogDebug,
|
|
1322
|
-
getSrsBacklogDebug: () => getSrsBacklogDebug
|
|
1323
|
+
getSrsBacklogDebug: () => getSrsBacklogDebug,
|
|
1324
|
+
noteReviewPressure: () => noteReviewPressure
|
|
1323
1325
|
});
|
|
1324
1326
|
function captureSrsBacklog(snapshot) {
|
|
1325
1327
|
snapshots.set(snapshot.courseId, snapshot);
|
|
1326
1328
|
}
|
|
1329
|
+
function noteReviewPressure(courseId, pressure) {
|
|
1330
|
+
const snapshot = snapshots.get(courseId);
|
|
1331
|
+
if (!snapshot) return;
|
|
1332
|
+
snapshots.set(courseId, {
|
|
1333
|
+
...snapshot,
|
|
1334
|
+
reviewMass: pressure.mass,
|
|
1335
|
+
healthyBacklog: pressure.healthyMass,
|
|
1336
|
+
backlogGrowthRate: pressure.rate,
|
|
1337
|
+
backlogMultiplier: pressure.multiplier
|
|
1338
|
+
});
|
|
1339
|
+
}
|
|
1327
1340
|
function getSrsBacklogDebug() {
|
|
1328
1341
|
return [...snapshots.values()].sort((a, b) => b.timestamp - a.timestamp);
|
|
1329
1342
|
}
|
|
@@ -1602,13 +1615,12 @@ __export(elo_exports, {
|
|
|
1602
1615
|
default: () => ELONavigator
|
|
1603
1616
|
});
|
|
1604
1617
|
import { toCourseElo as toCourseElo2 } from "@vue-skuilder/common";
|
|
1605
|
-
var
|
|
1618
|
+
var ELONavigator;
|
|
1606
1619
|
var init_elo = __esm({
|
|
1607
1620
|
"src/core/navigators/generators/elo.ts"() {
|
|
1608
1621
|
"use strict";
|
|
1609
1622
|
init_navigators();
|
|
1610
1623
|
init_logger();
|
|
1611
|
-
ELO_RELEVANCE_SIGMA = 300;
|
|
1612
1624
|
ELONavigator = class extends ContentNavigator {
|
|
1613
1625
|
/** Human-readable name for CardGenerator interface */
|
|
1614
1626
|
name;
|
|
@@ -1617,10 +1629,8 @@ var init_elo = __esm({
|
|
|
1617
1629
|
this.name = strategyData?.name || "ELO";
|
|
1618
1630
|
}
|
|
1619
1631
|
/**
|
|
1620
|
-
* Get new cards
|
|
1621
|
-
*
|
|
1622
|
-
* Cards closer to user's ELO get higher scores.
|
|
1623
|
-
* Score formula: max(0, 1 - distance / 500)
|
|
1632
|
+
* Get the new cards nearest the learner's ELO, each scored with a flat
|
|
1633
|
+
* jitter in [0.5, 1]. Carries each card's ELO for the ELO distance filter.
|
|
1624
1634
|
*
|
|
1625
1635
|
* NOTE: This generator only handles NEW cards. Reviews are handled by
|
|
1626
1636
|
* SRSNavigator. Use CompositeGenerator to combine both.
|
|
@@ -1648,20 +1658,20 @@ var init_elo = __esm({
|
|
|
1648
1658
|
const scored = newCards.map((c) => {
|
|
1649
1659
|
const cardElo = c.elo ?? 1e3;
|
|
1650
1660
|
const distance = Math.abs(cardElo - userGlobalElo);
|
|
1651
|
-
const
|
|
1652
|
-
const samplingKey = relevance * (0.5 + 0.5 * Math.random());
|
|
1661
|
+
const jitter = 0.5 + 0.5 * Math.random();
|
|
1653
1662
|
return {
|
|
1654
1663
|
cardId: c.cardID,
|
|
1655
1664
|
courseId: c.courseID,
|
|
1656
|
-
score:
|
|
1665
|
+
score: jitter,
|
|
1666
|
+
cardElo,
|
|
1657
1667
|
provenance: [
|
|
1658
1668
|
{
|
|
1659
1669
|
strategy: "elo",
|
|
1660
1670
|
strategyName: this.strategyName || this.name,
|
|
1661
1671
|
strategyId: this.strategyId || "NAVIGATION_STRATEGY-ELO-default",
|
|
1662
1672
|
action: "generated",
|
|
1663
|
-
score:
|
|
1664
|
-
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}),
|
|
1673
|
+
score: jitter,
|
|
1674
|
+
reason: `new card near learner ELO: distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}), jitter ${jitter.toFixed(3)}`
|
|
1665
1675
|
}
|
|
1666
1676
|
]
|
|
1667
1677
|
};
|
|
@@ -2537,43 +2547,132 @@ var init_prescribed = __esm({
|
|
|
2537
2547
|
}
|
|
2538
2548
|
});
|
|
2539
2549
|
|
|
2550
|
+
// src/core/navigators/regulators.ts
|
|
2551
|
+
var regulators_exports = {};
|
|
2552
|
+
__export(regulators_exports, {
|
|
2553
|
+
DEFAULT_REGULATOR_CONFIG: () => DEFAULT_REGULATOR_CONFIG,
|
|
2554
|
+
INTAKE_CLOCK_KEY: () => INTAKE_CLOCK_KEY,
|
|
2555
|
+
applyReading: () => applyReading,
|
|
2556
|
+
frozenMsAt: () => frozenMsAt,
|
|
2557
|
+
intakeHours: () => intakeHours,
|
|
2558
|
+
intakeReading: () => intakeReading,
|
|
2559
|
+
resetIntakeClock: () => resetIntakeClock,
|
|
2560
|
+
reviewMassReading: () => reviewMassReading,
|
|
2561
|
+
reviewWeight: () => reviewWeight,
|
|
2562
|
+
stepIntakeClock: () => stepIntakeClock
|
|
2563
|
+
});
|
|
2564
|
+
function clamp01(x) {
|
|
2565
|
+
return Math.min(1, Math.max(0, x));
|
|
2566
|
+
}
|
|
2567
|
+
function reviewWeight(card, generatedScore, referenceScore) {
|
|
2568
|
+
if (card.reviewUrgency !== void 0 && generatedScore !== void 0 && generatedScore > 0) {
|
|
2569
|
+
return clamp01(card.reviewUrgency * (card.score / generatedScore));
|
|
2570
|
+
}
|
|
2571
|
+
return clamp01(card.score / referenceScore);
|
|
2572
|
+
}
|
|
2573
|
+
function reviewMassReading(reviews, generatedScores, config = DEFAULT_REGULATOR_CONFIG.reviewMass) {
|
|
2574
|
+
const mass = reviews.reduce(
|
|
2575
|
+
(m, c) => m + reviewWeight(c, generatedScores.get(c.cardId), config.referenceScore),
|
|
2576
|
+
0
|
|
2577
|
+
);
|
|
2578
|
+
const multiplier = mass > config.healthyMass ? Math.pow(config.rate, (mass - config.healthyMass) / config.healthyMass) : 1;
|
|
2579
|
+
return {
|
|
2580
|
+
name: "review-mass",
|
|
2581
|
+
class: "review",
|
|
2582
|
+
urgency: mass,
|
|
2583
|
+
multiplier,
|
|
2584
|
+
applied: reviews.length,
|
|
2585
|
+
inputs: { due: reviews.length, mass, healthyMass: config.healthyMass }
|
|
2586
|
+
};
|
|
2587
|
+
}
|
|
2588
|
+
function resetIntakeClock(nowMs) {
|
|
2589
|
+
return { lastNewAt: new Date(nowMs).toISOString(), frozenMs: 0, unservableSince: null };
|
|
2590
|
+
}
|
|
2591
|
+
function frozenMsAt(state, nowMs) {
|
|
2592
|
+
const open = state.unservableSince ? Math.max(0, nowMs - Date.parse(state.unservableSince)) : 0;
|
|
2593
|
+
return state.frozenMs + open;
|
|
2594
|
+
}
|
|
2595
|
+
function intakeHours(state, nowMs) {
|
|
2596
|
+
const elapsed = nowMs - Date.parse(state.lastNewAt);
|
|
2597
|
+
return Math.max(0, elapsed - frozenMsAt(state, nowMs)) / 36e5;
|
|
2598
|
+
}
|
|
2599
|
+
function stepIntakeClock(state, nowMs, eligibleNew) {
|
|
2600
|
+
if (eligibleNew === 0 && !state.unservableSince) {
|
|
2601
|
+
return { ...state, unservableSince: new Date(nowMs).toISOString() };
|
|
2602
|
+
}
|
|
2603
|
+
if (eligibleNew > 0 && state.unservableSince) {
|
|
2604
|
+
return { ...state, frozenMs: frozenMsAt(state, nowMs), unservableSince: null };
|
|
2605
|
+
}
|
|
2606
|
+
return state;
|
|
2607
|
+
}
|
|
2608
|
+
function intakeReading(state, nowMs, counts, config = DEFAULT_REGULATOR_CONFIG.intake) {
|
|
2609
|
+
const hours = intakeHours(state, nowMs);
|
|
2610
|
+
const multiplier = counts.eligibleNew > 0 ? Math.pow(config.rate, hours / config.scaleHours) : 1;
|
|
2611
|
+
return {
|
|
2612
|
+
name: "intake",
|
|
2613
|
+
class: "new",
|
|
2614
|
+
urgency: hours,
|
|
2615
|
+
multiplier,
|
|
2616
|
+
applied: counts.eligibleNew,
|
|
2617
|
+
inputs: {
|
|
2618
|
+
hoursSinceNew: hours,
|
|
2619
|
+
frozenHours: frozenMsAt(state, nowMs) / 36e5,
|
|
2620
|
+
eligibleNew: counts.eligibleNew,
|
|
2621
|
+
newCandidates: counts.newCandidates
|
|
2622
|
+
}
|
|
2623
|
+
};
|
|
2624
|
+
}
|
|
2625
|
+
function applyReading(cards, reading) {
|
|
2626
|
+
if (reading.multiplier === 1) return;
|
|
2627
|
+
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)}`;
|
|
2628
|
+
for (const card of cards) {
|
|
2629
|
+
card.score *= reading.multiplier;
|
|
2630
|
+
card.provenance.push({
|
|
2631
|
+
strategy: "regulator",
|
|
2632
|
+
strategyName: `Regulator: ${REGULATOR_LABEL[reading.name]}`,
|
|
2633
|
+
strategyId: `regulator-${reading.name}`,
|
|
2634
|
+
action: reading.multiplier > 1 ? "boosted" : "penalized",
|
|
2635
|
+
score: card.score,
|
|
2636
|
+
reason
|
|
2637
|
+
});
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
var DEFAULT_REGULATOR_CONFIG, INTAKE_CLOCK_KEY, REGULATOR_LABEL;
|
|
2641
|
+
var init_regulators = __esm({
|
|
2642
|
+
"src/core/navigators/regulators.ts"() {
|
|
2643
|
+
"use strict";
|
|
2644
|
+
DEFAULT_REGULATOR_CONFIG = {
|
|
2645
|
+
reviewMass: { referenceScore: 0.95, healthyMass: 20, rate: 2 },
|
|
2646
|
+
intake: { rate: 2, scaleHours: 24 }
|
|
2647
|
+
};
|
|
2648
|
+
INTAKE_CLOCK_KEY = "IntakeClock";
|
|
2649
|
+
REGULATOR_LABEL = {
|
|
2650
|
+
"review-mass": "Review mass",
|
|
2651
|
+
intake: "Intake"
|
|
2652
|
+
};
|
|
2653
|
+
}
|
|
2654
|
+
});
|
|
2655
|
+
|
|
2540
2656
|
// src/core/navigators/generators/srs.ts
|
|
2541
2657
|
var srs_exports = {};
|
|
2542
2658
|
__export(srs_exports, {
|
|
2543
2659
|
default: () => SRSNavigator
|
|
2544
2660
|
});
|
|
2545
2661
|
import moment from "moment";
|
|
2546
|
-
var
|
|
2662
|
+
var SRSNavigator;
|
|
2547
2663
|
var init_srs = __esm({
|
|
2548
2664
|
"src/core/navigators/generators/srs.ts"() {
|
|
2549
2665
|
"use strict";
|
|
2550
2666
|
init_navigators();
|
|
2551
2667
|
init_SrsDebugger();
|
|
2668
|
+
init_regulators();
|
|
2552
2669
|
init_logger();
|
|
2553
|
-
DEFAULT_HEALTHY_BACKLOG = 20;
|
|
2554
|
-
BACKLOG_GROWTH_RATE = 2;
|
|
2555
2670
|
SRSNavigator = class extends ContentNavigator {
|
|
2556
2671
|
/** Human-readable name for CardGenerator interface */
|
|
2557
2672
|
name;
|
|
2558
|
-
/** Healthy backlog threshold - when exceeded, backlog pressure kicks in */
|
|
2559
|
-
healthyBacklog;
|
|
2560
2673
|
constructor(user, course, strategyData) {
|
|
2561
2674
|
super(user, course, strategyData);
|
|
2562
2675
|
this.name = strategyData?.name || "SRS";
|
|
2563
|
-
const config = this.parseConfig(strategyData?.serializedData);
|
|
2564
|
-
this.healthyBacklog = config.healthyBacklog ?? DEFAULT_HEALTHY_BACKLOG;
|
|
2565
|
-
}
|
|
2566
|
-
/**
|
|
2567
|
-
* Parse configuration from serialized JSON.
|
|
2568
|
-
*/
|
|
2569
|
-
parseConfig(serializedData) {
|
|
2570
|
-
if (!serializedData) return {};
|
|
2571
|
-
try {
|
|
2572
|
-
return JSON.parse(serializedData);
|
|
2573
|
-
} catch {
|
|
2574
|
-
logger.warn("[SRS] Failed to parse strategy config, using defaults");
|
|
2575
|
-
return {};
|
|
2576
|
-
}
|
|
2577
2676
|
}
|
|
2578
2677
|
/**
|
|
2579
2678
|
* Get review cards scored by urgency.
|
|
@@ -2581,7 +2680,6 @@ var init_srs = __esm({
|
|
|
2581
2680
|
* Score formula combines:
|
|
2582
2681
|
* - Relative overdueness: hoursOverdue / intervalHours
|
|
2583
2682
|
* - Interval recency: exponential decay favoring shorter intervals
|
|
2584
|
-
* - Backlog pressure: boost when due reviews exceed healthy threshold
|
|
2585
2683
|
*
|
|
2586
2684
|
* Cards not yet due are excluded (not scored as 0).
|
|
2587
2685
|
*
|
|
@@ -2618,7 +2716,6 @@ var init_srs = __esm({
|
|
|
2618
2716
|
}
|
|
2619
2717
|
}
|
|
2620
2718
|
}
|
|
2621
|
-
const backlogMultiplier = this.computeBacklogMultiplier(dueReviews.length);
|
|
2622
2719
|
const notDue = reviews.filter((r) => !now.isAfter(moment.utc(r.reviewTime)));
|
|
2623
2720
|
let nextDueIn = null;
|
|
2624
2721
|
if (notDue.length > 0) {
|
|
@@ -2629,9 +2726,8 @@ var init_srs = __esm({
|
|
|
2629
2726
|
nextDueIn = until.asHours() < 1 ? `${Math.round(until.asMinutes())}m` : until.asHours() < 24 ? `${Math.round(until.asHours())}h` : `${Math.round(until.asDays())}d`;
|
|
2630
2727
|
}
|
|
2631
2728
|
if (dueReviews.length > 0) {
|
|
2632
|
-
const pressureNote = backlogMultiplier > 1 ? ` [backlog pressure: \xD7${backlogMultiplier.toFixed(2)}]` : ` [healthy backlog]`;
|
|
2633
2729
|
logger.info(
|
|
2634
|
-
`[SRS] Course ${courseId}: ${dueReviews.length} reviews due now (of ${reviews.length} scheduled)
|
|
2730
|
+
`[SRS] Course ${courseId}: ${dueReviews.length} reviews due now (of ${reviews.length} scheduled)`
|
|
2635
2731
|
);
|
|
2636
2732
|
} else if (reviews.length > 0) {
|
|
2637
2733
|
const sortedByDue = [...reviews].sort(
|
|
@@ -2648,11 +2744,12 @@ var init_srs = __esm({
|
|
|
2648
2744
|
logger.info(`[SRS] Course ${courseId}: No reviews scheduled`);
|
|
2649
2745
|
}
|
|
2650
2746
|
const scored = dueReviews.map((review) => {
|
|
2651
|
-
const { score, reason } = this.computeUrgencyScore(review, now
|
|
2747
|
+
const { score, urgency, reason } = this.computeUrgencyScore(review, now);
|
|
2652
2748
|
return {
|
|
2653
2749
|
cardId: review.cardId,
|
|
2654
2750
|
courseId: review.courseId,
|
|
2655
2751
|
score,
|
|
2752
|
+
reviewUrgency: urgency,
|
|
2656
2753
|
reviewID: review._id,
|
|
2657
2754
|
provenance: [
|
|
2658
2755
|
{
|
|
@@ -2671,47 +2768,20 @@ var init_srs = __esm({
|
|
|
2671
2768
|
courseId,
|
|
2672
2769
|
scheduledTotal: reviews.length,
|
|
2673
2770
|
dueNow: dueReviews.length,
|
|
2674
|
-
healthyBacklog:
|
|
2675
|
-
|
|
2676
|
-
|
|
2771
|
+
healthyBacklog: DEFAULT_REGULATOR_CONFIG.reviewMass.healthyMass,
|
|
2772
|
+
reviewMass: null,
|
|
2773
|
+
backlogMultiplier: 1,
|
|
2774
|
+
backlogGrowthRate: DEFAULT_REGULATOR_CONFIG.reviewMass.rate,
|
|
2677
2775
|
topReviewScore: sorted.length > 0 ? sorted[0].score : null,
|
|
2678
2776
|
nextDueIn,
|
|
2679
2777
|
timestamp: Date.now()
|
|
2680
2778
|
});
|
|
2681
2779
|
return { cards: sorted.slice(0, limit) };
|
|
2682
2780
|
}
|
|
2683
|
-
/**
|
|
2684
|
-
* Compute the multiplicative backlog pressure based on number of due reviews.
|
|
2685
|
-
*
|
|
2686
|
-
* ×1.0 at or below the healthy threshold (no boost); above it, grows as
|
|
2687
|
-
* BACKLOG_GROWTH_RATE raised to the excess expressed in multiples of the
|
|
2688
|
-
* healthy threshold. Uncapped — self-regulating instead: reviews winning
|
|
2689
|
-
* slots depletes dueCount, which drops the ratio and relaxes the multiplier
|
|
2690
|
-
* next run.
|
|
2691
|
-
*
|
|
2692
|
-
* Examples (with default healthyBacklog=20, BACKLOG_GROWTH_RATE=1.5):
|
|
2693
|
-
* - 10 due reviews → ×1.00 (healthy)
|
|
2694
|
-
* - 20 due reviews → ×1.00 (at threshold, ratio 0)
|
|
2695
|
-
* - 40 due reviews → ×1.50 (ratio 1, 2x threshold)
|
|
2696
|
-
* - 60 due reviews → ×2.25 (ratio 2, 3x threshold — old hard cap was ×2.00 here)
|
|
2697
|
-
* - 100 due reviews → ×5.06 (ratio 4, 5x threshold)
|
|
2698
|
-
* - 160 due reviews → ×17.09 (ratio 7, 8x threshold)
|
|
2699
|
-
*
|
|
2700
|
-
* @param dueCount - Number of reviews currently due
|
|
2701
|
-
* @returns Multiplier applied to review urgency (>= 1.0, unbounded)
|
|
2702
|
-
*/
|
|
2703
|
-
computeBacklogMultiplier(dueCount) {
|
|
2704
|
-
if (dueCount <= this.healthyBacklog) {
|
|
2705
|
-
return 1;
|
|
2706
|
-
}
|
|
2707
|
-
const excess = dueCount - this.healthyBacklog;
|
|
2708
|
-
const ratio = excess / this.healthyBacklog;
|
|
2709
|
-
return Math.pow(BACKLOG_GROWTH_RATE, ratio);
|
|
2710
|
-
}
|
|
2711
2781
|
/**
|
|
2712
2782
|
* Compute urgency score for a review card.
|
|
2713
2783
|
*
|
|
2714
|
-
*
|
|
2784
|
+
* Two factors:
|
|
2715
2785
|
* 1. Relative overdueness = hoursOverdue / intervalHours
|
|
2716
2786
|
* - 2 days overdue on 3-day interval = 0.67 (urgent)
|
|
2717
2787
|
* - 2 days overdue on 180-day interval = 0.01 (not urgent)
|
|
@@ -2721,20 +2791,14 @@ var init_srs = __esm({
|
|
|
2721
2791
|
* - 30 days (720h) → ~0.56
|
|
2722
2792
|
* - 180 days → ~0.30
|
|
2723
2793
|
*
|
|
2724
|
-
*
|
|
2725
|
-
*
|
|
2726
|
-
*
|
|
2727
|
-
* Combined: (base 0.5 + urgency factors * 0.45) × backlog multiplier.
|
|
2728
|
-
* Per-card range before pressure: ~0.57–0.95. NOT clamped to 1.0 — under a
|
|
2729
|
-
* heavy backlog reviews scale onto the open scale to compete with (and exceed)
|
|
2730
|
-
* new cards; there's no ceiling at all now, so a bad enough backlog always
|
|
2731
|
-
* wins eventually — self-regulating because winning slots depletes dueCount.
|
|
2794
|
+
* Combined: base 0.5 + urgency factors * 0.45, so ~0.57–0.95 per card.
|
|
2795
|
+
* Backlog pressure is applied later, by the regulator stage, which can lift
|
|
2796
|
+
* reviews onto the open scale above new cards (see regulators.ts).
|
|
2732
2797
|
*
|
|
2733
2798
|
* @param review - The scheduled card to score
|
|
2734
2799
|
* @param now - Current time
|
|
2735
|
-
* @param backlogMultiplier - Pre-computed backlog multiplier (>= 1.0, unbounded)
|
|
2736
2800
|
*/
|
|
2737
|
-
computeUrgencyScore(review, now
|
|
2801
|
+
computeUrgencyScore(review, now) {
|
|
2738
2802
|
const scheduledAt = moment.utc(review.scheduledAt);
|
|
2739
2803
|
const due = moment.utc(review.reviewTime);
|
|
2740
2804
|
const intervalHours = Math.max(1, due.diff(scheduledAt, "hours"));
|
|
@@ -2743,20 +2807,16 @@ var init_srs = __esm({
|
|
|
2743
2807
|
const recencyFactor = 0.3 + 0.7 * Math.exp(-intervalHours / 720);
|
|
2744
2808
|
const overdueContribution = Math.min(1, Math.max(0, relativeOverdue));
|
|
2745
2809
|
const urgency = overdueContribution * 0.5 + recencyFactor * 0.5;
|
|
2746
|
-
const
|
|
2747
|
-
const score = baseScore * backlogMultiplier;
|
|
2810
|
+
const score = 0.5 + urgency * 0.45;
|
|
2748
2811
|
const reasonParts = [
|
|
2749
2812
|
`${Math.round(hoursOverdue)}h overdue`,
|
|
2750
2813
|
`interval: ${Math.round(intervalHours)}h`,
|
|
2751
2814
|
`relative: ${relativeOverdue.toFixed(2)}`,
|
|
2752
2815
|
`recency: ${recencyFactor.toFixed(2)}`
|
|
2753
2816
|
];
|
|
2754
|
-
if (backlogMultiplier > 1) {
|
|
2755
|
-
reasonParts.push(`backlog: \xD7${backlogMultiplier.toFixed(2)}`);
|
|
2756
|
-
}
|
|
2757
2817
|
reasonParts.push("review");
|
|
2758
2818
|
const reason = reasonParts.join(", ");
|
|
2759
|
-
return { score, reason };
|
|
2819
|
+
return { score, urgency, reason };
|
|
2760
2820
|
}
|
|
2761
2821
|
};
|
|
2762
2822
|
}
|
|
@@ -2811,6 +2871,8 @@ var init_WeightedFilter = __esm({
|
|
|
2811
2871
|
init_contentNavigationStrategy();
|
|
2812
2872
|
WeightedFilter = class {
|
|
2813
2873
|
name;
|
|
2874
|
+
kind;
|
|
2875
|
+
liveOnly;
|
|
2814
2876
|
inner;
|
|
2815
2877
|
learnable;
|
|
2816
2878
|
staticWeight;
|
|
@@ -2818,6 +2880,8 @@ var init_WeightedFilter = __esm({
|
|
|
2818
2880
|
constructor(inner, learnable = DEFAULT_LEARNABLE_WEIGHT, staticWeight = false, strategyId) {
|
|
2819
2881
|
this.inner = inner;
|
|
2820
2882
|
this.name = inner.name;
|
|
2883
|
+
this.kind = inner.kind;
|
|
2884
|
+
this.liveOnly = inner.liveOnly;
|
|
2821
2885
|
this.learnable = learnable;
|
|
2822
2886
|
this.staticWeight = staticWeight;
|
|
2823
2887
|
this.strategyId = strategyId;
|
|
@@ -2882,58 +2946,141 @@ var init_WeightedFilter = __esm({
|
|
|
2882
2946
|
// src/core/navigators/filters/eloDistance.ts
|
|
2883
2947
|
var eloDistance_exports = {};
|
|
2884
2948
|
__export(eloDistance_exports, {
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2949
|
+
DEFAULT_ELO_DISTANCE_CONFIG: () => DEFAULT_ELO_DISTANCE_CONFIG,
|
|
2950
|
+
createEloDistanceFilter: () => createEloDistanceFilter,
|
|
2951
|
+
default: () => EloDistanceFilter,
|
|
2952
|
+
tagAwareGap: () => tagAwareGap
|
|
2889
2953
|
});
|
|
2890
2954
|
function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
|
|
2891
2955
|
const normalizedDistance = distance / halfLife;
|
|
2892
2956
|
const decay = Math.exp(-(normalizedDistance * normalizedDistance));
|
|
2893
2957
|
return minMultiplier + (maxMultiplier - minMultiplier) * decay;
|
|
2894
2958
|
}
|
|
2959
|
+
function resolveConfig(config) {
|
|
2960
|
+
return { ...DEFAULT_ELO_DISTANCE_CONFIG, ...config };
|
|
2961
|
+
}
|
|
2962
|
+
function tagAwareGap(cardTags, cardElo, userElo, minTagCount) {
|
|
2963
|
+
const globalGap = cardElo.global.score - userElo.global.score;
|
|
2964
|
+
const tags = [];
|
|
2965
|
+
for (const tag of cardTags) {
|
|
2966
|
+
const user = userElo.tags[tag];
|
|
2967
|
+
if (!user || user.score === COUNT_ONLY_SENTINEL || user.count < minTagCount) continue;
|
|
2968
|
+
const card = cardElo.tags[tag]?.score ?? cardElo.global.score;
|
|
2969
|
+
tags.push({
|
|
2970
|
+
tag,
|
|
2971
|
+
gap: card - user.score,
|
|
2972
|
+
weight: user.count / (user.count + TAG_CONFIDENCE_HALF)
|
|
2973
|
+
});
|
|
2974
|
+
}
|
|
2975
|
+
if (tags.length === 0) return { gap: globalGap, globalGap, tags };
|
|
2976
|
+
const total = tags.reduce((w, t) => w + t.weight, 0);
|
|
2977
|
+
const tagGap = tags.reduce((g, t) => g + t.weight * t.gap, 0) / total;
|
|
2978
|
+
const lambda = total / (total + 1);
|
|
2979
|
+
return { gap: lambda * tagGap + (1 - lambda) * globalGap, globalGap, tags };
|
|
2980
|
+
}
|
|
2981
|
+
function tagReason(tags, globalGap) {
|
|
2982
|
+
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(", ");
|
|
2983
|
+
const more = tags.length > 3 ? `, +${tags.length - 3} more` : "";
|
|
2984
|
+
return ` on ${tags.length} shared tag(s) [${shown}${more}] (global ${globalGap >= 0 ? "+" : ""}${Math.round(globalGap)})`;
|
|
2985
|
+
}
|
|
2986
|
+
async function applyEloDistance(cards, context, config, source) {
|
|
2987
|
+
const { course, userElo, userCourseElo } = context;
|
|
2988
|
+
const { halfLife, minMultiplier, maxMultiplier } = config;
|
|
2989
|
+
const tagAware = config.tagAware && userCourseElo !== void 0;
|
|
2990
|
+
const missing = cards.filter((c) => tagAware || c.cardElo === void 0).map((c) => c.cardId);
|
|
2991
|
+
const fetched = /* @__PURE__ */ new Map();
|
|
2992
|
+
if (missing.length > 0) {
|
|
2993
|
+
const elos = await course.getCardEloData(missing);
|
|
2994
|
+
missing.forEach((id, i) => {
|
|
2995
|
+
if (elos[i]) fetched.set(id, elos[i]);
|
|
2996
|
+
});
|
|
2997
|
+
}
|
|
2998
|
+
return cards.map((card) => {
|
|
2999
|
+
const full = fetched.get(card.cardId);
|
|
3000
|
+
const cardElo = full?.global?.score ?? card.cardElo ?? DEFAULT_CARD_ELO;
|
|
3001
|
+
let distance = Math.abs(cardElo - userElo);
|
|
3002
|
+
let how = "";
|
|
3003
|
+
if (tagAware && full) {
|
|
3004
|
+
const t = tagAwareGap(card.tags ?? [], full, userCourseElo, config.minTagCount);
|
|
3005
|
+
distance = Math.abs(t.gap);
|
|
3006
|
+
if (t.tags.length > 0) how = tagReason(t.tags, t.globalGap);
|
|
3007
|
+
}
|
|
3008
|
+
const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
|
|
3009
|
+
const newScore = card.score * multiplier;
|
|
3010
|
+
const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
|
|
3011
|
+
return {
|
|
3012
|
+
...card,
|
|
3013
|
+
cardElo,
|
|
3014
|
+
score: newScore,
|
|
3015
|
+
provenance: [
|
|
3016
|
+
...card.provenance,
|
|
3017
|
+
{
|
|
3018
|
+
strategy: "eloDistance",
|
|
3019
|
+
strategyName: source.name,
|
|
3020
|
+
strategyId: source.strategyId,
|
|
3021
|
+
action,
|
|
3022
|
+
score: newScore,
|
|
3023
|
+
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)})${how} \u2192 ${multiplier.toFixed(2)}x`
|
|
3024
|
+
}
|
|
3025
|
+
]
|
|
3026
|
+
};
|
|
3027
|
+
});
|
|
3028
|
+
}
|
|
2895
3029
|
function createEloDistanceFilter(config) {
|
|
2896
|
-
const
|
|
2897
|
-
const
|
|
2898
|
-
const maxMultiplier = config?.maxMultiplier ?? DEFAULT_MAX_MULTIPLIER;
|
|
3030
|
+
const resolved = resolveConfig(config);
|
|
3031
|
+
const source = { name: "ELO Distance Filter", strategyId: "ELO_DISTANCE_FILTER" };
|
|
2899
3032
|
return {
|
|
2900
|
-
name:
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
const cardElos = await course.getCardEloData(cardIds);
|
|
2905
|
-
return cards.map((card, i) => {
|
|
2906
|
-
const cardElo = cardElos[i]?.global?.score ?? 1e3;
|
|
2907
|
-
const distance = Math.abs(cardElo - userElo);
|
|
2908
|
-
const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
|
|
2909
|
-
const newScore = card.score * multiplier;
|
|
2910
|
-
const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
|
|
2911
|
-
return {
|
|
2912
|
-
...card,
|
|
2913
|
-
score: newScore,
|
|
2914
|
-
provenance: [
|
|
2915
|
-
...card.provenance,
|
|
2916
|
-
{
|
|
2917
|
-
strategy: "eloDistance",
|
|
2918
|
-
strategyName: "ELO Distance Filter",
|
|
2919
|
-
strategyId: "ELO_DISTANCE_FILTER",
|
|
2920
|
-
action,
|
|
2921
|
-
score: newScore,
|
|
2922
|
-
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)}) \u2192 ${multiplier.toFixed(2)}x`
|
|
2923
|
-
}
|
|
2924
|
-
]
|
|
2925
|
-
};
|
|
2926
|
-
});
|
|
2927
|
-
}
|
|
3033
|
+
name: source.name,
|
|
3034
|
+
kind: "signal",
|
|
3035
|
+
liveOnly: true,
|
|
3036
|
+
transform: (cards, context) => applyEloDistance(cards, context, resolved, source)
|
|
2928
3037
|
};
|
|
2929
3038
|
}
|
|
2930
|
-
var
|
|
3039
|
+
var DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, COUNT_ONLY_SENTINEL, DEFAULT_CARD_ELO, EloDistanceFilter;
|
|
2931
3040
|
var init_eloDistance = __esm({
|
|
2932
3041
|
"src/core/navigators/filters/eloDistance.ts"() {
|
|
2933
3042
|
"use strict";
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
3043
|
+
init_navigators();
|
|
3044
|
+
DEFAULT_ELO_DISTANCE_CONFIG = {
|
|
3045
|
+
halfLife: 300,
|
|
3046
|
+
minMultiplier: 0.05,
|
|
3047
|
+
maxMultiplier: 1,
|
|
3048
|
+
tagAware: true,
|
|
3049
|
+
minTagCount: 3
|
|
3050
|
+
};
|
|
3051
|
+
TAG_CONFIDENCE_HALF = 10;
|
|
3052
|
+
COUNT_ONLY_SENTINEL = -1;
|
|
3053
|
+
DEFAULT_CARD_ELO = 1e3;
|
|
3054
|
+
EloDistanceFilter = class _EloDistanceFilter extends ContentNavigator {
|
|
3055
|
+
name;
|
|
3056
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3057
|
+
static kind = "signal";
|
|
3058
|
+
kind = _EloDistanceFilter.kind;
|
|
3059
|
+
liveOnly = true;
|
|
3060
|
+
config;
|
|
3061
|
+
constructor(user, course, strategyData) {
|
|
3062
|
+
super(user, course, strategyData);
|
|
3063
|
+
this.name = strategyData.name || "ELO Distance";
|
|
3064
|
+
let parsed;
|
|
3065
|
+
try {
|
|
3066
|
+
parsed = strategyData.serializedData ? JSON.parse(strategyData.serializedData) : void 0;
|
|
3067
|
+
} catch {
|
|
3068
|
+
parsed = void 0;
|
|
3069
|
+
}
|
|
3070
|
+
this.config = resolveConfig(parsed);
|
|
3071
|
+
}
|
|
3072
|
+
transform(cards, context) {
|
|
3073
|
+
return applyEloDistance(cards, context, this.config, {
|
|
3074
|
+
name: this.name,
|
|
3075
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-eloDistance-default"
|
|
3076
|
+
});
|
|
3077
|
+
}
|
|
3078
|
+
async getWeightedCards(_limit) {
|
|
3079
|
+
throw new Error(
|
|
3080
|
+
"EloDistanceFilter is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
|
|
3081
|
+
);
|
|
3082
|
+
}
|
|
3083
|
+
};
|
|
2937
3084
|
}
|
|
2938
3085
|
});
|
|
2939
3086
|
|
|
@@ -2950,10 +3097,13 @@ var init_hierarchyDefinition = __esm({
|
|
|
2950
3097
|
init_navigators();
|
|
2951
3098
|
init_logger();
|
|
2952
3099
|
DEFAULT_MIN_COUNT2 = 3;
|
|
2953
|
-
HierarchyDefinitionNavigator = class extends ContentNavigator {
|
|
3100
|
+
HierarchyDefinitionNavigator = class _HierarchyDefinitionNavigator extends ContentNavigator {
|
|
2954
3101
|
config;
|
|
2955
3102
|
/** Human-readable name for CardFilter interface */
|
|
2956
3103
|
name;
|
|
3104
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3105
|
+
static kind = "gate";
|
|
3106
|
+
kind = _HierarchyDefinitionNavigator.kind;
|
|
2957
3107
|
constructor(user, course, strategyData) {
|
|
2958
3108
|
super(user, course, strategyData);
|
|
2959
3109
|
this.config = this.parseConfig(strategyData.serializedData);
|
|
@@ -3220,10 +3370,13 @@ var init_userTagPreference = __esm({
|
|
|
3220
3370
|
"src/core/navigators/filters/userTagPreference.ts"() {
|
|
3221
3371
|
"use strict";
|
|
3222
3372
|
init_navigators();
|
|
3223
|
-
UserTagPreferenceFilter = class extends ContentNavigator {
|
|
3373
|
+
UserTagPreferenceFilter = class _UserTagPreferenceFilter extends ContentNavigator {
|
|
3224
3374
|
_strategyData;
|
|
3225
3375
|
/** Human-readable name for CardFilter interface */
|
|
3226
3376
|
name;
|
|
3377
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3378
|
+
static kind = "signal";
|
|
3379
|
+
kind = _UserTagPreferenceFilter.kind;
|
|
3227
3380
|
constructor(user, course, strategyData) {
|
|
3228
3381
|
super(user, course, strategyData);
|
|
3229
3382
|
this._strategyData = strategyData;
|
|
@@ -3333,6 +3486,7 @@ var init_userTagPreference = __esm({
|
|
|
3333
3486
|
// src/core/navigators/filters/index.ts
|
|
3334
3487
|
var filters_exports = {};
|
|
3335
3488
|
__export(filters_exports, {
|
|
3489
|
+
EloDistanceFilter: () => EloDistanceFilter,
|
|
3336
3490
|
UserTagPreferenceFilter: () => UserTagPreferenceFilter,
|
|
3337
3491
|
createEloDistanceFilter: () => createEloDistanceFilter
|
|
3338
3492
|
});
|
|
@@ -3371,10 +3525,13 @@ var init_interferenceMitigator = __esm({
|
|
|
3371
3525
|
DEFAULT_MIN_COUNT3 = 10;
|
|
3372
3526
|
DEFAULT_MIN_ELAPSED_DAYS = 3;
|
|
3373
3527
|
DEFAULT_INTERFERENCE_DECAY = 0.8;
|
|
3374
|
-
InterferenceMitigatorNavigator = class extends ContentNavigator {
|
|
3528
|
+
InterferenceMitigatorNavigator = class _InterferenceMitigatorNavigator extends ContentNavigator {
|
|
3375
3529
|
config;
|
|
3376
3530
|
/** Human-readable name for CardFilter interface */
|
|
3377
3531
|
name;
|
|
3532
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3533
|
+
static kind = "signal";
|
|
3534
|
+
kind = _InterferenceMitigatorNavigator.kind;
|
|
3378
3535
|
/** Precomputed map: tag -> set of { partner, decay } it interferes with */
|
|
3379
3536
|
interferenceMap;
|
|
3380
3537
|
constructor(user, course, strategyData) {
|
|
@@ -3590,10 +3747,13 @@ var init_relativePriority = __esm({
|
|
|
3590
3747
|
DEFAULT_PRIORITY = 0.5;
|
|
3591
3748
|
DEFAULT_PRIORITY_INFLUENCE = 0.5;
|
|
3592
3749
|
DEFAULT_COMBINE_MODE = "max";
|
|
3593
|
-
RelativePriorityNavigator = class extends ContentNavigator {
|
|
3750
|
+
RelativePriorityNavigator = class _RelativePriorityNavigator extends ContentNavigator {
|
|
3594
3751
|
config;
|
|
3595
3752
|
/** Human-readable name for CardFilter interface */
|
|
3596
3753
|
name;
|
|
3754
|
+
/** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
|
|
3755
|
+
static kind = "signal";
|
|
3756
|
+
kind = _RelativePriorityNavigator.kind;
|
|
3597
3757
|
constructor(user, course, strategyData) {
|
|
3598
3758
|
super(user, course, strategyData);
|
|
3599
3759
|
this.config = this.parseConfig(strategyData.serializedData);
|
|
@@ -4001,6 +4161,8 @@ var init_Pipeline = __esm({
|
|
|
4001
4161
|
init_orchestration();
|
|
4002
4162
|
init_PipelineDebugger();
|
|
4003
4163
|
init_diversityRerank();
|
|
4164
|
+
init_regulators();
|
|
4165
|
+
init_SrsDebugger();
|
|
4004
4166
|
VERBOSE_RESULTS = true;
|
|
4005
4167
|
Pipeline = class extends ContentNavigator {
|
|
4006
4168
|
generator;
|
|
@@ -4026,6 +4188,13 @@ var init_Pipeline = __esm({
|
|
|
4026
4188
|
* getWeightedCards() call, then cleared.
|
|
4027
4189
|
*/
|
|
4028
4190
|
_ephemeralHints = null;
|
|
4191
|
+
/**
|
|
4192
|
+
* The intake valve's clock (see regulators.ts), loaded from strategy state on
|
|
4193
|
+
* first use and kept in memory. Writes are chained so a presentation and a
|
|
4194
|
+
* run can't race each other's revision.
|
|
4195
|
+
*/
|
|
4196
|
+
_intakeClock = null;
|
|
4197
|
+
_intakeClockWrite = Promise.resolve();
|
|
4029
4198
|
/**
|
|
4030
4199
|
* Create a new pipeline.
|
|
4031
4200
|
*
|
|
@@ -4100,13 +4269,12 @@ var init_Pipeline = __esm({
|
|
|
4100
4269
|
}
|
|
4101
4270
|
}
|
|
4102
4271
|
generatorSummaries = Array.from(genMap.entries()).map(([name, data]) => {
|
|
4103
|
-
const
|
|
4104
|
-
const reviewCards = data.cards.filter((c) => c.provenance[0]?.reason?.includes("review"));
|
|
4272
|
+
const reviewCount = data.cards.filter((c) => c.reviewID).length;
|
|
4105
4273
|
return {
|
|
4106
4274
|
name,
|
|
4107
4275
|
cardCount: data.cards.length,
|
|
4108
|
-
newCount:
|
|
4109
|
-
reviewCount
|
|
4276
|
+
newCount: data.cards.length - reviewCount,
|
|
4277
|
+
reviewCount,
|
|
4110
4278
|
topScore: Math.max(...data.cards.map((c) => c.score), 0)
|
|
4111
4279
|
};
|
|
4112
4280
|
});
|
|
@@ -4142,19 +4310,24 @@ var init_Pipeline = __esm({
|
|
|
4142
4310
|
cards.filter((c) => c.provenance.some((p) => p.strategy === "prescribed")).map((c) => c.cardId)
|
|
4143
4311
|
);
|
|
4144
4312
|
const filterImpacts = [];
|
|
4313
|
+
const generatedScores = new Map(cards.map((c) => [c.cardId, c.score]));
|
|
4314
|
+
const gated = /* @__PURE__ */ new Set();
|
|
4145
4315
|
for (const filter of this.filters) {
|
|
4146
4316
|
const beforeCount = cards.length;
|
|
4147
4317
|
const beforeScores = new Map(cards.map((c) => [c.cardId, c.score]));
|
|
4148
4318
|
cards = await filter.transform(cards, context);
|
|
4149
4319
|
let boosted = 0, penalized = 0, passed = 0;
|
|
4150
4320
|
const removed = beforeCount - cards.length;
|
|
4321
|
+
const kind = filter.kind ?? "gate";
|
|
4151
4322
|
for (const card of cards) {
|
|
4152
4323
|
const before = beforeScores.get(card.cardId) ?? 0;
|
|
4153
4324
|
if (card.score > before) boosted++;
|
|
4154
|
-
else if (card.score < before)
|
|
4155
|
-
|
|
4325
|
+
else if (card.score < before) {
|
|
4326
|
+
penalized++;
|
|
4327
|
+
if (kind === "gate") gated.add(card.cardId);
|
|
4328
|
+
} else passed++;
|
|
4156
4329
|
}
|
|
4157
|
-
filterImpacts.push({ name: filter.name, boosted, penalized, passed, removed });
|
|
4330
|
+
filterImpacts.push({ name: filter.name, kind, boosted, penalized, passed, removed });
|
|
4158
4331
|
if (prescribedIds.size > 0) {
|
|
4159
4332
|
const survivingIds = new Set(cards.map((c) => c.cardId));
|
|
4160
4333
|
const killedPrescribed = [...prescribedIds].filter((id) => !survivingIds.has(id));
|
|
@@ -4170,6 +4343,7 @@ var init_Pipeline = __esm({
|
|
|
4170
4343
|
}
|
|
4171
4344
|
const scoredCards = cards;
|
|
4172
4345
|
cards = cards.filter((c) => c.score > 0);
|
|
4346
|
+
const regulators = await this.regulate(cards, generatedScores, gated);
|
|
4173
4347
|
const hints = this._ephemeralHints;
|
|
4174
4348
|
if (hints) {
|
|
4175
4349
|
this._ephemeralHints = null;
|
|
@@ -4206,7 +4380,8 @@ var init_Pipeline = __esm({
|
|
|
4206
4380
|
result,
|
|
4207
4381
|
context.userElo,
|
|
4208
4382
|
hints ?? void 0,
|
|
4209
|
-
scoredCards
|
|
4383
|
+
scoredCards,
|
|
4384
|
+
regulators
|
|
4210
4385
|
);
|
|
4211
4386
|
captureRun(report);
|
|
4212
4387
|
} catch (e) {
|
|
@@ -4385,6 +4560,77 @@ var init_Pipeline = __esm({
|
|
|
4385
4560
|
logger.info(`[Pipeline] Hints applied: ${beforeCount} \u2192 ${cards.length} cards`);
|
|
4386
4561
|
return cards;
|
|
4387
4562
|
}
|
|
4563
|
+
/**
|
|
4564
|
+
* The regulator stage: measure each class's pressure and scale it.
|
|
4565
|
+
*
|
|
4566
|
+
* - Review mass: every due review's SRS urgency times the filters' net
|
|
4567
|
+
* effect on it.
|
|
4568
|
+
* - Intake: servable hours since a new card was presented, applied only to
|
|
4569
|
+
* eligible new cards (no gate penalized them). With none eligible, the
|
|
4570
|
+
* clock freezes.
|
|
4571
|
+
*
|
|
4572
|
+
* Mutates `cards` in place; returns the readings for the run report.
|
|
4573
|
+
*/
|
|
4574
|
+
async regulate(cards, generatedScores, gated) {
|
|
4575
|
+
const config = DEFAULT_REGULATOR_CONFIG;
|
|
4576
|
+
const reviews = cards.filter((c) => c.reviewID);
|
|
4577
|
+
const newCards = cards.filter((c) => !c.reviewID);
|
|
4578
|
+
const eligibleNew = newCards.filter((c) => !gated.has(c.cardId));
|
|
4579
|
+
const mass = reviewMassReading(reviews, generatedScores, config.reviewMass);
|
|
4580
|
+
applyReading(reviews, mass);
|
|
4581
|
+
noteReviewPressure(this.course.getCourseID(), {
|
|
4582
|
+
mass: mass.urgency,
|
|
4583
|
+
healthyMass: config.reviewMass.healthyMass,
|
|
4584
|
+
rate: config.reviewMass.rate,
|
|
4585
|
+
multiplier: mass.multiplier
|
|
4586
|
+
});
|
|
4587
|
+
const now = Date.now();
|
|
4588
|
+
const clock = await this.loadIntakeClock(now);
|
|
4589
|
+
const stepped = stepIntakeClock(clock, now, eligibleNew.length);
|
|
4590
|
+
if (stepped !== clock) this.saveIntakeClock(stepped);
|
|
4591
|
+
const intake = intakeReading(
|
|
4592
|
+
stepped,
|
|
4593
|
+
now,
|
|
4594
|
+
{ eligibleNew: eligibleNew.length, newCandidates: newCards.length },
|
|
4595
|
+
config.intake
|
|
4596
|
+
);
|
|
4597
|
+
applyReading(eligibleNew, intake);
|
|
4598
|
+
logger.info(
|
|
4599
|
+
`[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)}`
|
|
4600
|
+
);
|
|
4601
|
+
return [mass, intake];
|
|
4602
|
+
}
|
|
4603
|
+
/**
|
|
4604
|
+
* A card was presented. A new card's first presentation discharges the
|
|
4605
|
+
* intake valve: its clock restarts. Called by the SessionController.
|
|
4606
|
+
*/
|
|
4607
|
+
notePresented(card) {
|
|
4608
|
+
if (card.status !== "new" || card.courseId !== this.course?.getCourseID()) return;
|
|
4609
|
+
this.saveIntakeClock(resetIntakeClock(Date.now()));
|
|
4610
|
+
}
|
|
4611
|
+
async loadIntakeClock(nowMs) {
|
|
4612
|
+
if (this._intakeClock) return this._intakeClock;
|
|
4613
|
+
let stored = null;
|
|
4614
|
+
try {
|
|
4615
|
+
stored = await this.user.getStrategyState(
|
|
4616
|
+
this.course.getCourseID(),
|
|
4617
|
+
INTAKE_CLOCK_KEY
|
|
4618
|
+
);
|
|
4619
|
+
} catch (e) {
|
|
4620
|
+
logger.warn(`[Pipeline:regulators] Could not read the intake clock: ${e}`);
|
|
4621
|
+
}
|
|
4622
|
+
if (stored) {
|
|
4623
|
+
this._intakeClock = stored;
|
|
4624
|
+
} else {
|
|
4625
|
+
this.saveIntakeClock(resetIntakeClock(nowMs));
|
|
4626
|
+
}
|
|
4627
|
+
return this._intakeClock;
|
|
4628
|
+
}
|
|
4629
|
+
saveIntakeClock(state) {
|
|
4630
|
+
this._intakeClock = state;
|
|
4631
|
+
const courseId = this.course.getCourseID();
|
|
4632
|
+
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}`));
|
|
4633
|
+
}
|
|
4388
4634
|
/**
|
|
4389
4635
|
* Build shared context for generator and filters.
|
|
4390
4636
|
*
|
|
@@ -4395,10 +4641,11 @@ var init_Pipeline = __esm({
|
|
|
4395
4641
|
*/
|
|
4396
4642
|
async buildContext() {
|
|
4397
4643
|
let userElo = 1e3;
|
|
4644
|
+
let userCourseElo;
|
|
4398
4645
|
try {
|
|
4399
4646
|
const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
|
|
4400
|
-
|
|
4401
|
-
userElo =
|
|
4647
|
+
userCourseElo = toCourseElo5(courseReg.elo);
|
|
4648
|
+
userElo = userCourseElo.global.score;
|
|
4402
4649
|
} catch (e) {
|
|
4403
4650
|
logger.debug(`[Pipeline] Could not get user ELO, using default: ${e}`);
|
|
4404
4651
|
}
|
|
@@ -4410,6 +4657,7 @@ var init_Pipeline = __esm({
|
|
|
4410
4657
|
user: this.user,
|
|
4411
4658
|
course: this.course,
|
|
4412
4659
|
userElo,
|
|
4660
|
+
...userCourseElo ? { userCourseElo } : {},
|
|
4413
4661
|
orchestration
|
|
4414
4662
|
};
|
|
4415
4663
|
}
|
|
@@ -4523,7 +4771,7 @@ var init_Pipeline = __esm({
|
|
|
4523
4771
|
cards = await this.hydrateTags(cards);
|
|
4524
4772
|
const fullPool = cards.slice();
|
|
4525
4773
|
const context = await this.buildContext();
|
|
4526
|
-
for (const filter of this.
|
|
4774
|
+
for (const filter of this.forecastFilters()) {
|
|
4527
4775
|
cards = await filter.transform(cards, context);
|
|
4528
4776
|
}
|
|
4529
4777
|
if (opts?.hints) {
|
|
@@ -4542,6 +4790,14 @@ var init_Pipeline = __esm({
|
|
|
4542
4790
|
cards.sort((a, b) => b.score - a.score);
|
|
4543
4791
|
return opts?.limit ? cards.slice(0, opts.limit) : cards;
|
|
4544
4792
|
}
|
|
4793
|
+
/**
|
|
4794
|
+
* The filters a forecast or card-space scan applies. Those start every card at
|
|
4795
|
+
* 1.0 without a generator, so they skip `liveOnly` filters (ELO distance),
|
|
4796
|
+
* which only make sense against generator scores.
|
|
4797
|
+
*/
|
|
4798
|
+
forecastFilters() {
|
|
4799
|
+
return this.filters.filter((f) => !f.liveOnly);
|
|
4800
|
+
}
|
|
4545
4801
|
/**
|
|
4546
4802
|
* Scan every card in the course through the filter chain and report
|
|
4547
4803
|
* how many are "well indicated" (score >= threshold) for the current user.
|
|
@@ -4563,7 +4819,7 @@ var init_Pipeline = __esm({
|
|
|
4563
4819
|
cards = await this.hydrateTags(cards);
|
|
4564
4820
|
const context = await this.buildContext();
|
|
4565
4821
|
const filterBreakdown = [];
|
|
4566
|
-
for (const filter of this.
|
|
4822
|
+
for (const filter of this.forecastFilters()) {
|
|
4567
4823
|
cards = await filter.transform(cards, context);
|
|
4568
4824
|
const wi = cards.filter((c) => c.score >= THRESHOLD).length;
|
|
4569
4825
|
filterBreakdown.push({ name: filter.name, wellIndicated: wi });
|
|
@@ -4627,6 +4883,7 @@ var init_Pipeline = __esm({
|
|
|
4627
4883
|
// src/core/navigators/defaults.ts
|
|
4628
4884
|
var defaults_exports = {};
|
|
4629
4885
|
__export(defaults_exports, {
|
|
4886
|
+
createDefaultEloDistanceStrategy: () => createDefaultEloDistanceStrategy,
|
|
4630
4887
|
createDefaultEloStrategy: () => createDefaultEloStrategy,
|
|
4631
4888
|
createDefaultPipeline: () => createDefaultPipeline,
|
|
4632
4889
|
createDefaultSrsStrategy: () => createDefaultSrsStrategy
|
|
@@ -4653,12 +4910,28 @@ function createDefaultSrsStrategy(courseId) {
|
|
|
4653
4910
|
serializedData: ""
|
|
4654
4911
|
};
|
|
4655
4912
|
}
|
|
4913
|
+
function createDefaultEloDistanceStrategy(courseId) {
|
|
4914
|
+
return {
|
|
4915
|
+
_id: "NAVIGATION_STRATEGY-eloDistance-default",
|
|
4916
|
+
docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
|
|
4917
|
+
name: "ELO Distance (default)",
|
|
4918
|
+
description: "Scales every candidate, new or review, by its distance from the learner's ELO",
|
|
4919
|
+
implementingClass: "eloDistance" /* ELO_DISTANCE */,
|
|
4920
|
+
course: courseId,
|
|
4921
|
+
// Explicit, though the filter would default to it anyway: views show what runs.
|
|
4922
|
+
serializedData: JSON.stringify(DEFAULT_ELO_DISTANCE_CONFIG)
|
|
4923
|
+
};
|
|
4924
|
+
}
|
|
4656
4925
|
function createDefaultPipeline(user, course) {
|
|
4657
4926
|
const courseId = course.getCourseID();
|
|
4658
4927
|
const eloNavigator = new ELONavigator(user, course, createDefaultEloStrategy(courseId));
|
|
4659
4928
|
const srsNavigator = new SRSNavigator(user, course, createDefaultSrsStrategy(courseId));
|
|
4660
4929
|
const compositeGenerator = new CompositeGenerator([eloNavigator, srsNavigator]);
|
|
4661
|
-
const eloDistanceFilter =
|
|
4930
|
+
const eloDistanceFilter = new EloDistanceFilter(
|
|
4931
|
+
user,
|
|
4932
|
+
course,
|
|
4933
|
+
createDefaultEloDistanceStrategy(courseId)
|
|
4934
|
+
);
|
|
4662
4935
|
return new Pipeline(compositeGenerator, [eloDistanceFilter], user, course);
|
|
4663
4936
|
}
|
|
4664
4937
|
var init_defaults = __esm({
|
|
@@ -4674,6 +4947,131 @@ var init_defaults = __esm({
|
|
|
4674
4947
|
}
|
|
4675
4948
|
});
|
|
4676
4949
|
|
|
4950
|
+
// src/core/navigators/pipelinePlan.ts
|
|
4951
|
+
var pipelinePlan_exports = {};
|
|
4952
|
+
__export(pipelinePlan_exports, {
|
|
4953
|
+
PIPELINE_STAGES: () => PIPELINE_STAGES,
|
|
4954
|
+
planPipeline: () => planPipeline
|
|
4955
|
+
});
|
|
4956
|
+
function planned(strategy, role, origin) {
|
|
4957
|
+
const kind = role === "filter" /* FILTER */ ? getRegisteredFilterKind(strategy.implementingClass) : void 0;
|
|
4958
|
+
return {
|
|
4959
|
+
role,
|
|
4960
|
+
origin,
|
|
4961
|
+
name: strategy.name,
|
|
4962
|
+
implementingClass: strategy.implementingClass,
|
|
4963
|
+
strategy,
|
|
4964
|
+
...kind ? { kind } : {}
|
|
4965
|
+
};
|
|
4966
|
+
}
|
|
4967
|
+
function planPipeline(strategies, courseId) {
|
|
4968
|
+
if (strategies.length === 0) {
|
|
4969
|
+
return {
|
|
4970
|
+
kind: "default",
|
|
4971
|
+
generators: [
|
|
4972
|
+
planned(createDefaultEloStrategy(courseId), "generator" /* GENERATOR */, "default-pipeline"),
|
|
4973
|
+
planned(createDefaultSrsStrategy(courseId), "generator" /* GENERATOR */, "default-pipeline")
|
|
4974
|
+
],
|
|
4975
|
+
filters: [
|
|
4976
|
+
planned(
|
|
4977
|
+
createDefaultEloDistanceStrategy(courseId),
|
|
4978
|
+
"filter" /* FILTER */,
|
|
4979
|
+
"default-pipeline"
|
|
4980
|
+
)
|
|
4981
|
+
],
|
|
4982
|
+
skipped: [],
|
|
4983
|
+
warnings: [],
|
|
4984
|
+
notes: [],
|
|
4985
|
+
regulators: DEFAULT_REGULATOR_CONFIG
|
|
4986
|
+
};
|
|
4987
|
+
}
|
|
4988
|
+
const generators = [];
|
|
4989
|
+
const filters = [];
|
|
4990
|
+
const skipped = [];
|
|
4991
|
+
const warnings = [];
|
|
4992
|
+
for (const s of strategies) {
|
|
4993
|
+
if (isGenerator(s.implementingClass)) {
|
|
4994
|
+
generators.push(planned(s, "generator" /* GENERATOR */, "strategy-doc"));
|
|
4995
|
+
} else if (isFilter(s.implementingClass)) {
|
|
4996
|
+
filters.push(planned(s, "filter" /* FILTER */, "strategy-doc"));
|
|
4997
|
+
} else {
|
|
4998
|
+
skipped.push({ strategy: s, reason: "not a registered generator or filter" });
|
|
4999
|
+
warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
|
|
5000
|
+
}
|
|
5001
|
+
}
|
|
5002
|
+
const declared = new Set(generators.map((g) => g.implementingClass));
|
|
5003
|
+
if (!declared.has(createDefaultEloStrategy(courseId).implementingClass)) {
|
|
5004
|
+
generators.push(
|
|
5005
|
+
planned(createDefaultEloStrategy(courseId), "generator" /* GENERATOR */, "assembler-default")
|
|
5006
|
+
);
|
|
5007
|
+
}
|
|
5008
|
+
if (!declared.has(createDefaultSrsStrategy(courseId).implementingClass)) {
|
|
5009
|
+
generators.push(
|
|
5010
|
+
planned(createDefaultSrsStrategy(courseId), "generator" /* GENERATOR */, "assembler-default")
|
|
5011
|
+
);
|
|
5012
|
+
}
|
|
5013
|
+
const eloDistance = createDefaultEloDistanceStrategy(courseId);
|
|
5014
|
+
if (!filters.some((f) => f.implementingClass === eloDistance.implementingClass)) {
|
|
5015
|
+
filters.push(planned(eloDistance, "filter" /* FILTER */, "assembler-default"));
|
|
5016
|
+
}
|
|
5017
|
+
filters.sort((a, b) => a.name.localeCompare(b.name));
|
|
5018
|
+
return {
|
|
5019
|
+
kind: "assembled",
|
|
5020
|
+
generators,
|
|
5021
|
+
filters,
|
|
5022
|
+
skipped,
|
|
5023
|
+
warnings,
|
|
5024
|
+
notes: [],
|
|
5025
|
+
regulators: DEFAULT_REGULATOR_CONFIG
|
|
5026
|
+
};
|
|
5027
|
+
}
|
|
5028
|
+
var PIPELINE_STAGES;
|
|
5029
|
+
var init_pipelinePlan = __esm({
|
|
5030
|
+
"src/core/navigators/pipelinePlan.ts"() {
|
|
5031
|
+
"use strict";
|
|
5032
|
+
init_navigators();
|
|
5033
|
+
init_regulators();
|
|
5034
|
+
init_defaults();
|
|
5035
|
+
PIPELINE_STAGES = [
|
|
5036
|
+
{
|
|
5037
|
+
key: "generate",
|
|
5038
|
+
title: "Generate",
|
|
5039
|
+
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."
|
|
5040
|
+
},
|
|
5041
|
+
{
|
|
5042
|
+
key: "filter",
|
|
5043
|
+
title: "Filter",
|
|
5044
|
+
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."
|
|
5045
|
+
},
|
|
5046
|
+
{
|
|
5047
|
+
key: "drop-zero",
|
|
5048
|
+
title: "Drop zero scores",
|
|
5049
|
+
summary: "Candidates whose score reached 0 leave the pool."
|
|
5050
|
+
},
|
|
5051
|
+
{
|
|
5052
|
+
key: "regulate",
|
|
5053
|
+
title: "Regulate",
|
|
5054
|
+
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."
|
|
5055
|
+
},
|
|
5056
|
+
{
|
|
5057
|
+
key: "hints",
|
|
5058
|
+
title: "Apply hints",
|
|
5059
|
+
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."
|
|
5060
|
+
},
|
|
5061
|
+
{
|
|
5062
|
+
key: "diversity",
|
|
5063
|
+
title: "Diversity re-rank",
|
|
5064
|
+
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."
|
|
5065
|
+
},
|
|
5066
|
+
{
|
|
5067
|
+
key: "select",
|
|
5068
|
+
title: "Select",
|
|
5069
|
+
summary: "Highest scores first, up to the run's limit. The session mixes them into its supply queue."
|
|
5070
|
+
}
|
|
5071
|
+
];
|
|
5072
|
+
}
|
|
5073
|
+
});
|
|
5074
|
+
|
|
4677
5075
|
// src/core/navigators/PipelineAssembler.ts
|
|
4678
5076
|
var PipelineAssembler_exports = {};
|
|
4679
5077
|
__export(PipelineAssembler_exports, {
|
|
@@ -4688,16 +5086,16 @@ var init_PipelineAssembler = __esm({
|
|
|
4688
5086
|
init_Pipeline();
|
|
4689
5087
|
init_logger();
|
|
4690
5088
|
init_CompositeGenerator();
|
|
4691
|
-
|
|
5089
|
+
init_pipelinePlan();
|
|
4692
5090
|
PipelineAssembler = class {
|
|
4693
5091
|
/**
|
|
4694
5092
|
* Assembles a navigation pipeline from strategy documents.
|
|
4695
5093
|
*
|
|
4696
|
-
* 1.
|
|
4697
|
-
*
|
|
4698
|
-
*
|
|
4699
|
-
*
|
|
4700
|
-
*
|
|
5094
|
+
* 1. Plans: classifies by role, adds default ELO/SRS and ELO distance, orders filters
|
|
5095
|
+
* (`planPipeline`)
|
|
5096
|
+
* 2. Instantiates generators - wraps multiple in CompositeGenerator
|
|
5097
|
+
* 3. Instantiates filters
|
|
5098
|
+
* 4. Returns Pipeline(generator, filters)
|
|
4701
5099
|
*
|
|
4702
5100
|
* @param input - Strategy documents plus user/course interfaces
|
|
4703
5101
|
* @returns Assembled pipeline and any warnings
|
|
@@ -4713,28 +5111,17 @@ var init_PipelineAssembler = __esm({
|
|
|
4713
5111
|
warnings
|
|
4714
5112
|
};
|
|
4715
5113
|
}
|
|
4716
|
-
const
|
|
4717
|
-
|
|
4718
|
-
for (const
|
|
4719
|
-
if (
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
} else {
|
|
4724
|
-
warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
|
|
5114
|
+
const plan = planPipeline(strategies, course.getCourseID());
|
|
5115
|
+
warnings.push(...plan.warnings);
|
|
5116
|
+
for (const n of [...plan.generators, ...plan.filters]) {
|
|
5117
|
+
if (n.origin === "assembler-default") {
|
|
5118
|
+
logger.debug(
|
|
5119
|
+
`[PipelineAssembler] No ${n.implementingClass} ${n.role} configured, adding default`
|
|
5120
|
+
);
|
|
4725
5121
|
}
|
|
4726
5122
|
}
|
|
4727
|
-
const
|
|
4728
|
-
const
|
|
4729
|
-
const hasSrs = generatorStrategies.some((s) => s.implementingClass === "srs" /* SRS */);
|
|
4730
|
-
if (!hasElo) {
|
|
4731
|
-
logger.debug("[PipelineAssembler] No ELO generator configured, adding default");
|
|
4732
|
-
generatorStrategies.push(createDefaultEloStrategy(courseId));
|
|
4733
|
-
}
|
|
4734
|
-
if (!hasSrs) {
|
|
4735
|
-
logger.debug("[PipelineAssembler] No SRS generator configured, adding default");
|
|
4736
|
-
generatorStrategies.push(createDefaultSrsStrategy(courseId));
|
|
4737
|
-
}
|
|
5123
|
+
const generatorStrategies = plan.generators.map((g) => g.strategy);
|
|
5124
|
+
const sortedFilterStrategies = plan.filters.map((f) => f.strategy);
|
|
4738
5125
|
if (generatorStrategies.length === 0) {
|
|
4739
5126
|
warnings.push("No generator strategy found");
|
|
4740
5127
|
return {
|
|
@@ -4756,9 +5143,6 @@ var init_PipelineAssembler = __esm({
|
|
|
4756
5143
|
generator = await CompositeGenerator.fromStrategies(user, course, generatorStrategies);
|
|
4757
5144
|
}
|
|
4758
5145
|
const filters = [];
|
|
4759
|
-
const sortedFilterStrategies = [...filterStrategies].sort(
|
|
4760
|
-
(a, b) => a.name.localeCompare(b.name)
|
|
4761
|
-
);
|
|
4762
5146
|
for (const filterStrategy of sortedFilterStrategies) {
|
|
4763
5147
|
try {
|
|
4764
5148
|
const nav = await ContentNavigator.create(user, course, filterStrategy);
|
|
@@ -4826,7 +5210,9 @@ var init_3 = __esm({
|
|
|
4826
5210
|
"./generators/prescribed.ts": () => Promise.resolve().then(() => (init_prescribed(), prescribed_exports)),
|
|
4827
5211
|
"./generators/srs.ts": () => Promise.resolve().then(() => (init_srs(), srs_exports)),
|
|
4828
5212
|
"./generators/types.ts": () => Promise.resolve().then(() => (init_types(), types_exports)),
|
|
4829
|
-
"./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports))
|
|
5213
|
+
"./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports)),
|
|
5214
|
+
"./pipelinePlan.ts": () => Promise.resolve().then(() => (init_pipelinePlan(), pipelinePlan_exports)),
|
|
5215
|
+
"./regulators.ts": () => Promise.resolve().then(() => (init_regulators(), regulators_exports))
|
|
4830
5216
|
});
|
|
4831
5217
|
}
|
|
4832
5218
|
});
|
|
@@ -4847,6 +5233,7 @@ __export(navigators_exports, {
|
|
|
4847
5233
|
drainCapturedRuns: () => drainCapturedRuns,
|
|
4848
5234
|
getActivePipeline: () => getActivePipeline,
|
|
4849
5235
|
getCardOrigin: () => getCardOrigin,
|
|
5236
|
+
getRegisteredFilterKind: () => getRegisteredFilterKind,
|
|
4850
5237
|
getRegisteredNavigator: () => getRegisteredNavigator,
|
|
4851
5238
|
getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
|
|
4852
5239
|
getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
|
|
@@ -4875,6 +5262,10 @@ function hasRegisteredNavigator(implementingClass) {
|
|
|
4875
5262
|
function getRegisteredNavigatorRole(implementingClass) {
|
|
4876
5263
|
return navigatorRegistry.get(implementingClass)?.role;
|
|
4877
5264
|
}
|
|
5265
|
+
function getRegisteredFilterKind(implementingClass) {
|
|
5266
|
+
const ctor = navigatorRegistry.get(implementingClass)?.constructor;
|
|
5267
|
+
return ctor?.kind;
|
|
5268
|
+
}
|
|
4878
5269
|
function getRegisteredNavigatorNames() {
|
|
4879
5270
|
return Array.from(navigatorRegistry.keys());
|
|
4880
5271
|
}
|
|
@@ -4892,17 +5283,20 @@ async function initializeNavigatorRegistry() {
|
|
|
4892
5283
|
hierarchyModule,
|
|
4893
5284
|
interferenceModule,
|
|
4894
5285
|
relativePriorityModule,
|
|
4895
|
-
userTagPreferenceModule
|
|
5286
|
+
userTagPreferenceModule,
|
|
5287
|
+
eloDistanceModule
|
|
4896
5288
|
] = await Promise.all([
|
|
4897
5289
|
Promise.resolve().then(() => (init_hierarchyDefinition(), hierarchyDefinition_exports)),
|
|
4898
5290
|
Promise.resolve().then(() => (init_interferenceMitigator(), interferenceMitigator_exports)),
|
|
4899
5291
|
Promise.resolve().then(() => (init_relativePriority(), relativePriority_exports)),
|
|
4900
|
-
Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports))
|
|
5292
|
+
Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports)),
|
|
5293
|
+
Promise.resolve().then(() => (init_eloDistance(), eloDistance_exports))
|
|
4901
5294
|
]);
|
|
4902
5295
|
registerNavigator("hierarchyDefinition", hierarchyModule.default);
|
|
4903
5296
|
registerNavigator("interferenceMitigator", interferenceModule.default);
|
|
4904
5297
|
registerNavigator("relativePriority", relativePriorityModule.default);
|
|
4905
5298
|
registerNavigator("userTagPreference", userTagPreferenceModule.default);
|
|
5299
|
+
registerNavigator("eloDistance", eloDistanceModule.default);
|
|
4906
5300
|
logger.debug(
|
|
4907
5301
|
`[NavigatorRegistry] Initialized ${navigatorRegistry.size} navigators: ${getRegisteredNavigatorNames().join(", ")}`
|
|
4908
5302
|
);
|
|
@@ -4950,6 +5344,7 @@ var init_navigators = __esm({
|
|
|
4950
5344
|
Navigators2["INTERFERENCE"] = "interferenceMitigator";
|
|
4951
5345
|
Navigators2["RELATIVE_PRIORITY"] = "relativePriority";
|
|
4952
5346
|
Navigators2["USER_TAG_PREFERENCE"] = "userTagPreference";
|
|
5347
|
+
Navigators2["ELO_DISTANCE"] = "eloDistance";
|
|
4953
5348
|
return Navigators2;
|
|
4954
5349
|
})(Navigators || {});
|
|
4955
5350
|
NavigatorRole = /* @__PURE__ */ ((NavigatorRole2) => {
|
|
@@ -4964,7 +5359,8 @@ var init_navigators = __esm({
|
|
|
4964
5359
|
["hierarchyDefinition" /* HIERARCHY */]: "filter" /* FILTER */,
|
|
4965
5360
|
["interferenceMitigator" /* INTERFERENCE */]: "filter" /* FILTER */,
|
|
4966
5361
|
["relativePriority" /* RELATIVE_PRIORITY */]: "filter" /* FILTER */,
|
|
4967
|
-
["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER
|
|
5362
|
+
["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER */,
|
|
5363
|
+
["eloDistance" /* ELO_DISTANCE */]: "filter" /* FILTER */
|
|
4968
5364
|
};
|
|
4969
5365
|
ContentNavigator = class {
|
|
4970
5366
|
/** User interface for this navigation session */
|
|
@@ -6813,10 +7209,11 @@ function backlogHtml(backlog) {
|
|
|
6813
7209
|
const rows = backlog.map((b) => {
|
|
6814
7210
|
const hot = b.backlogMultiplier >= 3;
|
|
6815
7211
|
const multColor = b.backlogMultiplier <= 1 ? "#86efac" : hot ? "#fca5a5" : "#fcd34d";
|
|
6816
|
-
const headroom = b.backlogMultiplier > 1 ? `climbing (\xD7${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog}
|
|
7212
|
+
const headroom = b.backlogMultiplier > 1 ? `climbing (\xD7${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog} of mass in excess, unbounded)` : "healthy \u2014 no pressure";
|
|
7213
|
+
const mass = b.reviewMass !== null ? ` \xB7 mass ${b.reviewMass.toFixed(1)}` : "";
|
|
6817
7214
|
const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
|
|
6818
7215
|
const next = b.nextDueIn ? ` <span style="opacity:.6">\xB7 next due ${esc(b.nextDueIn)}</span>` : "";
|
|
6819
|
-
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>`;
|
|
7216
|
+
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>`;
|
|
6820
7217
|
}).join("");
|
|
6821
7218
|
return `<div style="margin-bottom:6px"><div style="color:#93c5fd">review backpressure</div>${rows}</div>`;
|
|
6822
7219
|
}
|
|
@@ -6955,8 +7352,9 @@ function snapshotToText(s) {
|
|
|
6955
7352
|
const headroom = b.backlogMultiplier > 1 ? "climbing" : "healthy";
|
|
6956
7353
|
const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : "\u2014";
|
|
6957
7354
|
const next = b.nextDueIn ? `, next due ${b.nextDueIn}` : "";
|
|
7355
|
+
const mass = b.reviewMass !== null ? `, mass ${b.reviewMass.toFixed(1)}` : "";
|
|
6958
7356
|
lines.push(
|
|
6959
|
-
` ${b.courseId.slice(0, 8)}: due ${b.dueNow}/${b.scheduledTotal} (healthy ${b.healthyBacklog})${next}; pressure \xD7${b.backlogMultiplier.toFixed(2)} ${headroom}; top review ${top}`
|
|
7357
|
+
` ${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}`
|
|
6960
7358
|
);
|
|
6961
7359
|
}
|
|
6962
7360
|
}
|
|
@@ -9978,6 +10376,11 @@ var init_courseDB3 = __esm({
|
|
|
9978
10376
|
setEphemeralHints(hints) {
|
|
9979
10377
|
this._pendingHints = hints;
|
|
9980
10378
|
}
|
|
10379
|
+
/** Forward a presentation to the navigator (a new card restarts its intake clock). */
|
|
10380
|
+
notePresented(card) {
|
|
10381
|
+
if (card.status !== "new") return;
|
|
10382
|
+
void this.createNavigator(this.userDB).then((navigator2) => navigator2.notePresented?.(card)).catch((e) => logger.warn(`[static/courseDB] Could not note a presentation: ${e}`));
|
|
10383
|
+
}
|
|
9981
10384
|
async getWeightedCards(limit) {
|
|
9982
10385
|
try {
|
|
9983
10386
|
const navigator2 = await this.createNavigator(this.userDB);
|