@vue-skuilder/db 0.3.1 → 0.3.3
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-2zVmcjKA.d.ts → contentSource-CSI0pJ2D.d.ts} +10 -0
- package/dist/core/index.cjs +62 -14
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +3 -3
- package/dist/core/interfaces/contentSource.mjs.map +1 -1
- package/dist/core/navigators/Pipeline.mjs +7 -1
- package/dist/core/navigators/Pipeline.mjs.map +1 -1
- package/dist/core/navigators/filters/eloDistance.mjs +17 -2
- package/dist/core/navigators/filters/eloDistance.mjs.map +1 -1
- package/dist/core/navigators/generators/prescribed.mjs +20 -10
- package/dist/core/navigators/generators/prescribed.mjs.map +1 -1
- package/dist/core/navigators/index.mjs +2 -0
- package/dist/core/navigators/index.mjs.map +1 -1
- package/dist/core/versionStamps.mjs +1 -1
- package/dist/{dataLayerProvider-rGyLQ93v.d.ts → dataLayerProvider-D5n1gGc_.d.ts} +1 -1
- package/dist/diagnostics/derive.mjs.map +1 -1
- package/dist/diagnostics/index.cjs +16 -3
- package/dist/diagnostics/index.cjs.map +1 -1
- package/dist/diagnostics/index.d.ts +29 -6
- package/dist/diagnostics/tagElo.mjs +20 -4
- package/dist/diagnostics/tagElo.mjs.map +1 -1
- package/dist/impl/couch/courseDB.mjs +5 -0
- package/dist/impl/couch/courseDB.mjs.map +1 -1
- package/dist/impl/couch/index.cjs +37 -2
- package/dist/impl/couch/index.cjs.map +1 -1
- package/dist/impl/couch/index.d.ts +4 -2
- package/dist/impl/static/courseDB.mjs +5 -0
- package/dist/impl/static/courseDB.mjs.map +1 -1
- package/dist/impl/static/index.cjs +37 -2
- package/dist/impl/static/index.cjs.map +1 -1
- package/dist/impl/static/index.d.ts +4 -2
- package/dist/index.cjs +80 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/study/SessionController.mjs +1 -0
- package/dist/study/SessionController.mjs.map +1 -1
- package/dist/study/services/tagRecent.mjs +2 -1
- package/dist/study/services/tagRecent.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/interfaces/contentSource.ts +7 -0
- package/src/core/navigators/Pipeline.ts +7 -0
- package/src/core/navigators/filters/eloDistance.ts +31 -2
- package/src/core/navigators/generators/prescribed.ts +55 -11
- package/src/core/navigators/generators/types.ts +3 -0
- package/src/core/navigators/index.ts +5 -0
- package/src/diagnostics/derive.ts +6 -1
- package/src/diagnostics/tagElo.ts +43 -3
- package/src/impl/couch/courseDB.ts +13 -0
- package/src/impl/static/courseDB.ts +13 -0
- package/src/study/SessionController.ts +3 -0
- package/src/study/services/tagRecent.test.ts +57 -3
- package/src/study/services/tagRecent.ts +8 -1
- package/tests/core/navigators/eloDistanceFilter.test.ts +15 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C as ClassroomDBInterface, A as AdminDBInterface } from '../../classroomDB-DLTtLZct.js';
|
|
2
|
-
import { U as UserDBInterface, C as CourseDBInterface, a as CoursesDBInterface, b as CourseInfo, S as StudySessionItem, D as DataLayerResult, c as ContentNavigationStrategyData, d as ContentNavigator, R as ReplanHints, G as GeneratorResult } from '../../contentSource-
|
|
3
|
-
import { D as DataLayerProvider } from '../../dataLayerProvider-
|
|
2
|
+
import { U as UserDBInterface, C as CourseDBInterface, a as CoursesDBInterface, b as CourseInfo, S as StudySessionItem, D as DataLayerResult, c as ContentNavigationStrategyData, d as ContentNavigator, R as ReplanHints, G as GeneratorResult } from '../../contentSource-CSI0pJ2D.js';
|
|
3
|
+
import { D as DataLayerProvider } from '../../dataLayerProvider-D5n1gGc_.js';
|
|
4
4
|
import { S as StaticCourseManifest } from '../../types-DF0JuPbs.js';
|
|
5
5
|
import { CourseConfig, CourseElo, DataShape } from '@vue-skuilder/common';
|
|
6
6
|
import { S as SkuilderCourseData, Q as QualifiedCardID, T as TagStub, a as Tag } from '../../types-legacy-DdVjg81H.js';
|
|
@@ -176,6 +176,8 @@ declare class StaticCourseDB implements CourseDBInterface {
|
|
|
176
176
|
createNavigator(user: UserDBInterface): Promise<ContentNavigator>;
|
|
177
177
|
private _pendingHints;
|
|
178
178
|
setEphemeralHints(hints: ReplanHints): void;
|
|
179
|
+
private _sessionId;
|
|
180
|
+
setSessionId(sessionId: string): void;
|
|
179
181
|
/** Forward a presentation to the navigator (a new card restarts its intake clock). */
|
|
180
182
|
notePresented(card: {
|
|
181
183
|
cardId: string;
|
package/dist/index.cjs
CHANGED
|
@@ -1621,9 +1621,12 @@ var init_prescribed = __esm({
|
|
|
1621
1621
|
const allRelevantIds = dedupe([...allTargetIds, ...allSupportIds]);
|
|
1622
1622
|
const tagsByCard = allRelevantIds.length > 0 ? await this.course.getAppliedTagsBatch(allRelevantIds) : /* @__PURE__ */ new Map();
|
|
1623
1623
|
const cardsByTag = await this.loadCardsByTag();
|
|
1624
|
+
const sessionId = context?.sessionId;
|
|
1625
|
+
const newSession = sessionId === void 0 || sessionId !== progress.lastSessionId;
|
|
1624
1626
|
const nextState = {
|
|
1625
1627
|
updatedAt: isoNow(),
|
|
1626
|
-
groups: {}
|
|
1628
|
+
groups: {},
|
|
1629
|
+
...sessionId || progress.lastSessionId ? { lastSessionId: sessionId ?? progress.lastSessionId } : {}
|
|
1627
1630
|
};
|
|
1628
1631
|
const emitted = [];
|
|
1629
1632
|
const emittedIds = /* @__PURE__ */ new Set();
|
|
@@ -1663,7 +1666,11 @@ var init_prescribed = __esm({
|
|
|
1663
1666
|
);
|
|
1664
1667
|
}
|
|
1665
1668
|
}
|
|
1666
|
-
nextState.groups[group.id] = this.buildNextGroupState(
|
|
1669
|
+
nextState.groups[group.id] = this.buildNextGroupState(
|
|
1670
|
+
runtime,
|
|
1671
|
+
progress.groups[group.id],
|
|
1672
|
+
newSession
|
|
1673
|
+
);
|
|
1667
1674
|
const directCards = this.buildDirectTargetCards(
|
|
1668
1675
|
runtime,
|
|
1669
1676
|
courseId,
|
|
@@ -1735,12 +1742,8 @@ var init_prescribed = __esm({
|
|
|
1735
1742
|
for (const group of this.config.groups) {
|
|
1736
1743
|
const groupState = nextState.groups[group.id];
|
|
1737
1744
|
const surfaced = surfacedByGroup.get(group.id);
|
|
1738
|
-
if (surfaced &&
|
|
1739
|
-
groupState.
|
|
1740
|
-
groupState.sessionsSinceSurfaced = 0;
|
|
1741
|
-
if (surfaced.supportIds.length > 0) {
|
|
1742
|
-
groupState.lastSupportAt = isoNow();
|
|
1743
|
-
}
|
|
1745
|
+
if (surfaced && surfaced.supportIds.length > 0) {
|
|
1746
|
+
groupState.lastSupportAt = isoNow();
|
|
1744
1747
|
}
|
|
1745
1748
|
}
|
|
1746
1749
|
await this.putStrategyState(nextState).catch((e) => {
|
|
@@ -2006,14 +2009,24 @@ var init_prescribed = __esm({
|
|
|
2006
2009
|
debugVersion: PRESCRIBED_DEBUG_VERSION
|
|
2007
2010
|
};
|
|
2008
2011
|
}
|
|
2009
|
-
|
|
2012
|
+
/**
|
|
2013
|
+
* The group's state after this run. The staleness clock resets only when a
|
|
2014
|
+
* target has reached the learner since the last run: it is newly in
|
|
2015
|
+
* `encounteredTargets`, which reads card history and scheduled reviews, so
|
|
2016
|
+
* the card was shown and answered. Emitting a target does not count; it may
|
|
2017
|
+
* lose to the rest of the heap. (Before 2026-11, emission reset the clock,
|
|
2018
|
+
* and a group that emitted every run never escalated.) The clock advances
|
|
2019
|
+
* once per study session, not per run.
|
|
2020
|
+
*/
|
|
2021
|
+
buildNextGroupState(runtime, prior, newSession) {
|
|
2010
2022
|
const carriedSessions = prior?.sessionsSinceSurfaced ?? 0;
|
|
2011
|
-
const
|
|
2023
|
+
const previouslyEncountered = new Set(prior?.encounteredCardIds ?? []);
|
|
2024
|
+
const surfacedThisRun = prior !== void 0 && [...runtime.encounteredTargets].some((id) => !previouslyEncountered.has(id));
|
|
2012
2025
|
return {
|
|
2013
2026
|
encounteredCardIds: [...runtime.encounteredTargets].sort(),
|
|
2014
2027
|
pendingTargetIds: [...runtime.pendingTargets].sort(),
|
|
2015
|
-
lastSurfacedAt: prior?.lastSurfacedAt ?? null,
|
|
2016
|
-
sessionsSinceSurfaced: surfacedThisRun ? 0 : carriedSessions + 1,
|
|
2028
|
+
lastSurfacedAt: surfacedThisRun ? isoNow() : prior?.lastSurfacedAt ?? null,
|
|
2029
|
+
sessionsSinceSurfaced: surfacedThisRun ? 0 : carriedSessions + (newSession ? 1 : 0),
|
|
2017
2030
|
lastSupportAt: prior?.lastSupportAt ?? null,
|
|
2018
2031
|
blockedTargetIds: [...runtime.blockedTargets].sort(),
|
|
2019
2032
|
lastResolvedSupportTags: [...runtime.supportTags].sort()
|
|
@@ -3140,6 +3153,9 @@ __export(eloDistance_exports, {
|
|
|
3140
3153
|
mountMultiDimEloToggle: () => mountMultiDimEloToggle,
|
|
3141
3154
|
tagAwareGap: () => tagAwareGap
|
|
3142
3155
|
});
|
|
3156
|
+
function isIntroCard(card) {
|
|
3157
|
+
return (card.tags ?? []).some((t) => (0, import_common5.tagRole)(t) === "intro");
|
|
3158
|
+
}
|
|
3143
3159
|
function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
|
|
3144
3160
|
const normalizedDistance = distance / halfLife;
|
|
3145
3161
|
const decay = Math.exp(-(normalizedDistance * normalizedDistance));
|
|
@@ -3207,7 +3223,7 @@ async function applyEloDistance(cards, context, config, source) {
|
|
|
3207
3223
|
const { course, userElo, userCourseElo } = context;
|
|
3208
3224
|
const { halfLife, minMultiplier, maxMultiplier } = config;
|
|
3209
3225
|
const tagAware = (config.tagAware || multiDimElo) && userCourseElo !== void 0;
|
|
3210
|
-
const missing = cards.filter((c) => tagAware || c.cardElo === void 0).map((c) => c.cardId);
|
|
3226
|
+
const missing = cards.filter((c) => !isIntroCard(c) && (tagAware || c.cardElo === void 0)).map((c) => c.cardId);
|
|
3211
3227
|
const fetched = /* @__PURE__ */ new Map();
|
|
3212
3228
|
if (missing.length > 0) {
|
|
3213
3229
|
const elos = await course.getCardEloData(missing);
|
|
@@ -3216,6 +3232,22 @@ async function applyEloDistance(cards, context, config, source) {
|
|
|
3216
3232
|
});
|
|
3217
3233
|
}
|
|
3218
3234
|
return cards.map((card) => {
|
|
3235
|
+
if (isIntroCard(card)) {
|
|
3236
|
+
return {
|
|
3237
|
+
...card,
|
|
3238
|
+
provenance: [
|
|
3239
|
+
...card.provenance,
|
|
3240
|
+
{
|
|
3241
|
+
strategy: "eloDistance",
|
|
3242
|
+
strategyName: source.name,
|
|
3243
|
+
strategyId: source.strategyId,
|
|
3244
|
+
action: "passed",
|
|
3245
|
+
score: card.score,
|
|
3246
|
+
reason: "intro card: ELO is a placeholder, distance not applied \u2192 1.00x"
|
|
3247
|
+
}
|
|
3248
|
+
]
|
|
3249
|
+
};
|
|
3250
|
+
}
|
|
3219
3251
|
const full = fetched.get(card.cardId);
|
|
3220
3252
|
const cardElo = full?.global?.score ?? card.cardElo ?? DEFAULT_CARD_ELO;
|
|
3221
3253
|
let distance = Math.abs(cardElo - userElo);
|
|
@@ -3588,6 +3620,9 @@ var init_navigators = __esm({
|
|
|
3588
3620
|
*/
|
|
3589
3621
|
setEphemeralHints(_hints) {
|
|
3590
3622
|
}
|
|
3623
|
+
/** See StudyContentSource.setSessionId. No-op for non-Pipeline navigators. */
|
|
3624
|
+
setSessionId(_sessionId) {
|
|
3625
|
+
}
|
|
3591
3626
|
};
|
|
3592
3627
|
}
|
|
3593
3628
|
});
|
|
@@ -3624,7 +3659,7 @@ var FRAMEWORK_VERSION, hostAppVersion, DEFAULT_STRATEGY_HASH;
|
|
|
3624
3659
|
var init_versionStamps = __esm({
|
|
3625
3660
|
"src/core/versionStamps.ts"() {
|
|
3626
3661
|
"use strict";
|
|
3627
|
-
FRAMEWORK_VERSION = true ? "0.3.
|
|
3662
|
+
FRAMEWORK_VERSION = true ? "0.3.3" : "dev";
|
|
3628
3663
|
DEFAULT_STRATEGY_HASH = "default";
|
|
3629
3664
|
}
|
|
3630
3665
|
});
|
|
@@ -4096,7 +4131,13 @@ function recordTagPresentations(userElo, perf, records, cardId, at) {
|
|
|
4096
4131
|
if (tag === "_global") continue;
|
|
4097
4132
|
if (typeof score !== "number") continue;
|
|
4098
4133
|
const rank = userElo.tags[tag] ?? { score: userElo.global.score, count: 0 };
|
|
4099
|
-
const entry = {
|
|
4134
|
+
const entry = {
|
|
4135
|
+
at,
|
|
4136
|
+
ok,
|
|
4137
|
+
tagOk: score > import_common7.TAG_OK_MIN_PERF,
|
|
4138
|
+
perf: score,
|
|
4139
|
+
card: cardId
|
|
4140
|
+
};
|
|
4100
4141
|
userElo.tags[tag] = (0, import_common7.pushTagPresentation)(rank, entry);
|
|
4101
4142
|
written.push(tag);
|
|
4102
4143
|
}
|
|
@@ -7069,6 +7110,7 @@ var init_Pipeline = __esm({
|
|
|
7069
7110
|
* getWeightedCards() call, then cleared.
|
|
7070
7111
|
*/
|
|
7071
7112
|
_ephemeralHints = null;
|
|
7113
|
+
_sessionId;
|
|
7072
7114
|
/**
|
|
7073
7115
|
* The intake valve's clock (see regulators.ts), loaded from strategy state on
|
|
7074
7116
|
* first use and kept in memory. Writes are chained so a presentation and a
|
|
@@ -7104,6 +7146,10 @@ var init_Pipeline = __esm({
|
|
|
7104
7146
|
*
|
|
7105
7147
|
* Overrides ContentNavigator.setEphemeralHints() no-op.
|
|
7106
7148
|
*/
|
|
7149
|
+
/** See StudyContentSource.setSessionId. Carried into every run's context. */
|
|
7150
|
+
setSessionId(sessionId) {
|
|
7151
|
+
this._sessionId = sessionId;
|
|
7152
|
+
}
|
|
7107
7153
|
setEphemeralHints(hints) {
|
|
7108
7154
|
this._ephemeralHints = hints;
|
|
7109
7155
|
logger.info(`[Pipeline] Ephemeral hints set: ${JSON.stringify(hints)}`);
|
|
@@ -7551,7 +7597,8 @@ var init_Pipeline = __esm({
|
|
|
7551
7597
|
course: this.course,
|
|
7552
7598
|
userElo,
|
|
7553
7599
|
...userCourseElo ? { userCourseElo } : {},
|
|
7554
|
-
orchestration
|
|
7600
|
+
orchestration,
|
|
7601
|
+
...this._sessionId ? { sessionId: this._sessionId } : {}
|
|
7555
7602
|
};
|
|
7556
7603
|
}
|
|
7557
7604
|
/**
|
|
@@ -9100,6 +9147,9 @@ var init_SessionController = __esm({
|
|
|
9100
9147
|
)
|
|
9101
9148
|
};
|
|
9102
9149
|
this.sources = sources;
|
|
9150
|
+
for (const source of sources) {
|
|
9151
|
+
source.setSessionId?.(this.sessionId);
|
|
9152
|
+
}
|
|
9103
9153
|
this.startTime = /* @__PURE__ */ new Date();
|
|
9104
9154
|
this._secondsRemaining = time;
|
|
9105
9155
|
this.endTime = new Date(this.startTime.valueOf() + 1e3 * this._secondsRemaining);
|
|
@@ -13354,6 +13404,10 @@ ${e.stack}` : JSON.stringify(e);
|
|
|
13354
13404
|
setEphemeralHints(hints) {
|
|
13355
13405
|
this._pendingHints = hints;
|
|
13356
13406
|
}
|
|
13407
|
+
_sessionId = null;
|
|
13408
|
+
setSessionId(sessionId) {
|
|
13409
|
+
this._sessionId = sessionId;
|
|
13410
|
+
}
|
|
13357
13411
|
/**
|
|
13358
13412
|
* Forward a presentation to the navigator (a new card restarts its intake
|
|
13359
13413
|
* clock). Builds the navigator if the cached one has expired.
|
|
@@ -13370,6 +13424,9 @@ ${e.stack}` : JSON.stringify(e);
|
|
|
13370
13424
|
navigator2.setEphemeralHints(this._pendingHints);
|
|
13371
13425
|
this._pendingHints = null;
|
|
13372
13426
|
}
|
|
13427
|
+
if (this._sessionId) {
|
|
13428
|
+
navigator2.setSessionId(this._sessionId);
|
|
13429
|
+
}
|
|
13373
13430
|
const result = await navigator2.getWeightedCards(limit);
|
|
13374
13431
|
return result;
|
|
13375
13432
|
} catch (e) {
|
|
@@ -15591,6 +15648,10 @@ var init_courseDB2 = __esm({
|
|
|
15591
15648
|
setEphemeralHints(hints) {
|
|
15592
15649
|
this._pendingHints = hints;
|
|
15593
15650
|
}
|
|
15651
|
+
_sessionId = null;
|
|
15652
|
+
setSessionId(sessionId) {
|
|
15653
|
+
this._sessionId = sessionId;
|
|
15654
|
+
}
|
|
15594
15655
|
/** Forward a presentation to the navigator (a new card restarts its intake clock). */
|
|
15595
15656
|
notePresented(card) {
|
|
15596
15657
|
if (card.status !== "new") return;
|
|
@@ -15603,6 +15664,9 @@ var init_courseDB2 = __esm({
|
|
|
15603
15664
|
navigator2.setEphemeralHints(this._pendingHints);
|
|
15604
15665
|
this._pendingHints = null;
|
|
15605
15666
|
}
|
|
15667
|
+
if (this._sessionId) {
|
|
15668
|
+
navigator2.setSessionId(this._sessionId);
|
|
15669
|
+
}
|
|
15606
15670
|
return navigator2.getWeightedCards(limit);
|
|
15607
15671
|
} catch (e) {
|
|
15608
15672
|
logger.error(`[static/courseDB] Error getting weighted cards: ${e}`);
|