@vue-skuilder/db 0.3.2 → 0.3.4

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.
Files changed (40) hide show
  1. package/dist/{contentSource-CSI0pJ2D.d.ts → contentSource-CPM872yn.d.ts} +2 -1
  2. package/dist/core/index.cjs +163 -49
  3. package/dist/core/index.cjs.map +1 -1
  4. package/dist/core/index.d.ts +3 -3
  5. package/dist/core/navigators/filters/eloDistance.mjs.map +1 -1
  6. package/dist/core/navigators/filters/skillPressure.mjs +109 -0
  7. package/dist/core/navigators/filters/skillPressure.mjs.map +1 -0
  8. package/dist/core/navigators/generators/prescribed.mjs.map +1 -1
  9. package/dist/core/navigators/index.mjs +7 -3
  10. package/dist/core/navigators/index.mjs.map +1 -1
  11. package/dist/core/versionStamps.mjs +1 -1
  12. package/dist/{dataLayerProvider-D5n1gGc_.d.ts → dataLayerProvider-CaNgzRCz.d.ts} +1 -1
  13. package/dist/diagnostics/derive.mjs.map +1 -1
  14. package/dist/diagnostics/index.cjs +16 -3
  15. package/dist/diagnostics/index.cjs.map +1 -1
  16. package/dist/diagnostics/index.d.ts +29 -6
  17. package/dist/diagnostics/tagElo.mjs +20 -4
  18. package/dist/diagnostics/tagElo.mjs.map +1 -1
  19. package/dist/impl/couch/index.cjs +2 -1
  20. package/dist/impl/couch/index.cjs.map +1 -1
  21. package/dist/impl/couch/index.d.ts +2 -2
  22. package/dist/impl/static/index.cjs +2 -1
  23. package/dist/impl/static/index.cjs.map +1 -1
  24. package/dist/impl/static/index.d.ts +2 -2
  25. package/dist/index.cjs +211 -91
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.ts +3 -3
  28. package/dist/study/services/tagRecent.mjs +2 -1
  29. package/dist/study/services/tagRecent.mjs.map +1 -1
  30. package/package.json +3 -3
  31. package/src/core/navigators/filters/eloDistance.ts +2 -2
  32. package/src/core/navigators/filters/index.ts +3 -0
  33. package/src/core/navigators/filters/skillPressure.ts +194 -0
  34. package/src/core/navigators/generators/prescribed.ts +5 -6
  35. package/src/core/navigators/index.ts +5 -0
  36. package/src/diagnostics/derive.ts +6 -1
  37. package/src/diagnostics/tagElo.ts +43 -3
  38. package/src/study/services/tagRecent.test.ts +57 -3
  39. package/src/study/services/tagRecent.ts +8 -1
  40. package/tests/core/navigators/skillPressureFilter.test.ts +84 -0
@@ -1,7 +1,7 @@
1
1
  export { A as AdminDBInterface, d as AssignedCard, a as AssignedContent, c as AssignedCourse, b as AssignedTag, C as ClassroomDBInterface, S as StudentClassroomDBInterface, T as TeacherClassroomDBInterface } from '../classroomDB-DLTtLZct.js';
2
- import { av as LearnableWeight, T as UserOutcomeRecord, aw as OrchestrationContext, W as WeightedCard, C as CourseDBInterface } from '../contentSource-CSI0pJ2D.js';
3
- export { P as ActivityRecord, ae as CardFilter, ag as CardFilterFactory, ah as CardGenerator, aj as CardGeneratorFactory, K as ClassroomRegistration, J as ClassroomRegistrationDesignation, L as ClassroomRegistrationDoc, c as ContentNavigationStrategyData, d as ContentNavigator, v as ContentSourceID, b as CourseInfo, Q as CourseRegistration, g as CourseRegistrationDoc, a as CoursesDBInterface, af as FilterContext, at as FilterImpact, F as FilterKind, ai as GeneratorContext, G as GeneratorResult, as as GeneratorSummary, _ as HYDRATION_MARKER_ID, $ as HydrationMarker, a0 as NavigatorConstructor, N as NavigatorRole, ab as NavigatorRoles, aa as Navigators, au as PipelineForecaster, aq as PipelineRunReport, R as ReplanHints, ar as RunReportCard, f as ScheduledCard, m as SessionEloEvent, h as SessionStateSnapshot, x as SessionStateSnapshotProvider, M as SessionTrackingData, a8 as StrategyContribution, o as StudyContentSource, e as StudySessionDoc, p as StudySessionFailedItem, q as StudySessionFailedNewItem, r as StudySessionFailedReviewItem, S as StudySessionItem, s as StudySessionNewItem, t as StudySessionReviewItem, k as StudySessionRunCard, n as StudySessionRunCardTrail, i as StudySessionRunSummary, O as UserConfig, H as UserCourseSetting, E as UserCourseSettings, B as UserDBAuthenticator, U as UserDBInterface, z as UserDBReader, A as UserDBWriter, Y as UserHydrationState, Z as UserHydrationStatus, I as UsrCrsDataInterface, ax as computeDeviation, az as computeEffectiveWeight, ay as computeSpread, aA as createOrchestrationContext, ap as drainCapturedRuns, am as getActivePipeline, a9 as getCardOrigin, a5 as getRegisteredFilterKind, a2 as getRegisteredNavigator, a6 as getRegisteredNavigatorNames, a4 as getRegisteredNavigatorRole, ao as getRunsForSession, w as getStudySource, a3 as hasRegisteredNavigator, a7 as initializeNavigatorRegistry, ad as isFilter, ac as isGenerator, u as isReview, V as makeStudySessionId, al as mountPipelineDebugger, X as newSessionId, ak as pipelineDebugAPI, a1 as registerNavigator, an as setDebugSessionId } from '../contentSource-CSI0pJ2D.js';
4
- export { D as DataLayerProvider } from '../dataLayerProvider-D5n1gGc_.js';
2
+ import { av as LearnableWeight, T as UserOutcomeRecord, aw as OrchestrationContext, W as WeightedCard, C as CourseDBInterface } from '../contentSource-CPM872yn.js';
3
+ export { P as ActivityRecord, ae as CardFilter, ag as CardFilterFactory, ah as CardGenerator, aj as CardGeneratorFactory, K as ClassroomRegistration, J as ClassroomRegistrationDesignation, L as ClassroomRegistrationDoc, c as ContentNavigationStrategyData, d as ContentNavigator, v as ContentSourceID, b as CourseInfo, Q as CourseRegistration, g as CourseRegistrationDoc, a as CoursesDBInterface, af as FilterContext, at as FilterImpact, F as FilterKind, ai as GeneratorContext, G as GeneratorResult, as as GeneratorSummary, _ as HYDRATION_MARKER_ID, $ as HydrationMarker, a0 as NavigatorConstructor, N as NavigatorRole, ab as NavigatorRoles, aa as Navigators, au as PipelineForecaster, aq as PipelineRunReport, R as ReplanHints, ar as RunReportCard, f as ScheduledCard, m as SessionEloEvent, h as SessionStateSnapshot, x as SessionStateSnapshotProvider, M as SessionTrackingData, a8 as StrategyContribution, o as StudyContentSource, e as StudySessionDoc, p as StudySessionFailedItem, q as StudySessionFailedNewItem, r as StudySessionFailedReviewItem, S as StudySessionItem, s as StudySessionNewItem, t as StudySessionReviewItem, k as StudySessionRunCard, n as StudySessionRunCardTrail, i as StudySessionRunSummary, O as UserConfig, H as UserCourseSetting, E as UserCourseSettings, B as UserDBAuthenticator, U as UserDBInterface, z as UserDBReader, A as UserDBWriter, Y as UserHydrationState, Z as UserHydrationStatus, I as UsrCrsDataInterface, ax as computeDeviation, az as computeEffectiveWeight, ay as computeSpread, aA as createOrchestrationContext, ap as drainCapturedRuns, am as getActivePipeline, a9 as getCardOrigin, a5 as getRegisteredFilterKind, a2 as getRegisteredNavigator, a6 as getRegisteredNavigatorNames, a4 as getRegisteredNavigatorRole, ao as getRunsForSession, w as getStudySource, a3 as hasRegisteredNavigator, a7 as initializeNavigatorRegistry, ad as isFilter, ac as isGenerator, u as isReview, V as makeStudySessionId, al as mountPipelineDebugger, X as newSessionId, ak as pipelineDebugAPI, a1 as registerNavigator, an as setDebugSessionId } from '../contentSource-CPM872yn.js';
4
+ export { D as DataLayerProvider } from '../dataLayerProvider-CaNgzRCz.js';
5
5
  import { D as DocType, d as QuestionRecord, f as DocTypePrefixes, e as CardHistory, c as CardRecord } from '../types-legacy-DdVjg81H.js';
6
6
  export { C as CardData, g as CourseListData, h as DataShapeData, b as DisplayableData, F as Field, G as GuestUsername, Q as QualifiedCardID, i as QuestionData, S as SkuilderCourseData, a as Tag, T as TagStub, l as log } from '../types-legacy-DdVjg81H.js';
7
7
  import { DataShape, ParsedCard } from '@vue-skuilder/common';
@@ -1 +1 @@
1
- {"version":3,"file":"eloDistance.mjs","names":[],"sources":["../../../../src/core/navigators/filters/eloDistance.ts"],"sourcesContent":["import type { CourseDBInterface } from '../../interfaces/courseDB';\nimport type { UserDBInterface } from '../../interfaces/userDB';\nimport type { ContentNavigationStrategyData } from '../../types/contentNavigationStrategy';\nimport { ContentNavigator } from '../index';\nimport type { WeightedCard } from '../index';\nimport type { GeneratorResult } from '../generators/types';\nimport type { CardFilter, FilterContext, FilterKind } from './types';\nimport { COUNT_ONLY_SCORE, isCountOnlyTag, tagRole, type CourseElo } from '@vue-skuilder/common';\nimport { logger } from '../../../util/logger';\n\n// ============================================================================\n// ELO DISTANCE FILTER\n// ============================================================================\n//\n// Scales every candidate by how close its ELO is to the learner's, on a smooth\n// Gaussian (no discontinuities, never zero).\n//\n// The one place ELO distance counts. Generators retrieve (the ELO generator\n// pulls a window of cards near the learner's ELO) and score only on what's\n// specific to their source; a signal that applies to every card lives in one\n// heap-wide filter, so new cards and reviews are weighed on the same terms:\n// - reviews the learner has moved beyond fade, and may never surface over\n// higher-priority work;\n// - new cards far from the learner's level rank low (this used to live in the\n// ELO generator's own score, which double-counted alongside this filter).\n//\n// Tag-aware (opt-in, experimental): a card's difficulty for this learner is\n// read on the skills they share, not only on global ELO. Card and learner keep\n// paired ratings per tag (each graded response adjusts both), so a tag's gap\n// (card − learner) is as meaningful as the global one, and often more: a card\n// can sit at the learner's global level while testing their weakest skill.\n// See tagAwareGap for the combination. Global distance is the default; a course\n// opts in with `tagAware`, a browser with `window.skuilder.multiDimElo = true`\n// (see the toggle below), for side-by-side testing.\n//\n// Intro cards pass through untouched. They carry an `intro`-role tag, grade\n// nothing, and their ELO is a placeholder, so a distance on it means nothing.\n// Penalising them starved established learners of every intro (an LP learner\n// at ~1600 saw sight-word intros at 1000 scored ×0.05 for six weeks).\n//\n// A `signal`, not a gate: it expresses preference, not readiness. `liveOnly`:\n// forecasts and card-space scans start every card at 1.0 without a generator,\n// and never applied ELO distance, so they skip it.\n//\n// The assembler adds this filter (as \"ELO Distance (default)\") to every\n// pipeline whose strategy docs don't declare one. A course tunes it by\n// declaring its own `eloDistance` strategy doc with an EloDistanceConfig.\n//\n// ============================================================================\n\n/**\n * Configuration for the ELO distance curve:\n * `minMultiplier + (maxMultiplier − minMultiplier) · exp(−(distance / halfLife)²)`.\n */\nexport interface EloDistanceConfig {\n /**\n * The Gaussian's scale in ELO points (despite the name, not a half-life).\n * Default 300: distance 250 → ~0.5, as the ELO generator scored new cards.\n *\n * - distance 0: maxMultiplier\n * - distance = halfLife: ~0.4 (with the default floor)\n * - distance = 2 · halfLife: ~0.07\n */\n halfLife?: number;\n\n /**\n * Floor, so far-off cards keep a nonzero score (the pipeline drops zero\n * scores before hints, and a hint must be able to lift any card). Default 0.05.\n */\n minMultiplier?: number;\n\n /** Ceiling. Usually 1.0 (no boost for close cards). Default 1.0. */\n maxMultiplier?: number;\n\n /**\n * Measure distance on the tags the card and learner share (see\n * tagAwareGap), falling back to global ELO where they share none.\n * Default false. `window.skuilder.multiDimElo` turns it on in one browser.\n */\n tagAware?: boolean;\n\n /**\n * A learner's tag rating counts once it rests on at least this many graded\n * responses. Count-only (exposure) tags never count. Default 3.\n */\n minTagCount?: number;\n}\n\n/**\n * The default curve. The default strategy doc carries it as its config, so\n * the admin pipeline view shows what runs.\n */\nexport const DEFAULT_ELO_DISTANCE_CONFIG: Required<EloDistanceConfig> = {\n halfLife: 300,\n minMultiplier: 0.05,\n maxMultiplier: 1.0,\n tagAware: false,\n minTagCount: 3,\n};\n\n/**\n * Graded responses at which a tag's gap carries half its full weight. Thin\n * tag evidence leans on global ELO; well-practised tags dominate.\n */\nconst TAG_CONFIDENCE_HALF = 10;\n\n/** Whether the card is an intro: any `intro`-role tag. Its ELO is a placeholder. */\nfunction isIntroCard(card: WeightedCard): boolean {\n return (card.tags ?? []).some((t) => tagRole(t) === 'intro');\n}\n\n/** Fallback card ELO when a card has none recorded. */\nconst DEFAULT_CARD_ELO = 1000;\n\nfunction computeMultiplier(\n distance: number,\n halfLife: number,\n minMultiplier: number,\n maxMultiplier: number\n): number {\n const normalizedDistance = distance / halfLife;\n const decay = Math.exp(-(normalizedDistance * normalizedDistance));\n return minMultiplier + (maxMultiplier - minMultiplier) * decay;\n}\n\nfunction resolveConfig(config?: EloDistanceConfig): Required<EloDistanceConfig> {\n return { ...DEFAULT_ELO_DISTANCE_CONFIG, ...config };\n}\n\n// ----------------------------------------------------------------------------\n// Live toggle: window.skuilder.multiDimElo\n// ----------------------------------------------------------------------------\n//\n// `window.skuilder.multiDimElo = true` turns tag-aware distance on in this\n// browser, whatever the strategy config says; `false` returns it to the\n// config. Read on every run, so it takes effect at the next replan. Kept in\n// localStorage so it survives reloads across a testing stretch. Runs it shapes\n// say so in every card's ELO distance reason (\"tag-aware\").\n\nconst MULTI_DIM_ELO_KEY = 'skuilder:multiDimElo';\n\nlet multiDimElo = readMultiDimElo();\n\nfunction readMultiDimElo(): boolean {\n try {\n return typeof localStorage !== 'undefined' && localStorage.getItem(MULTI_DIM_ELO_KEY) === 'true';\n } catch {\n return false;\n }\n}\n\n/**\n * Mount the toggle on window.skuilder.multiDimElo.\n */\nexport function mountMultiDimEloToggle(): void {\n if (typeof window === 'undefined') return;\n\n const win = window as any;\n win.skuilder = win.skuilder || {};\n Object.defineProperty(win.skuilder, 'multiDimElo', {\n configurable: true,\n enumerable: true,\n get: () => multiDimElo,\n set: (on: unknown) => {\n multiDimElo = on === true;\n try {\n if (multiDimElo) localStorage.setItem(MULTI_DIM_ELO_KEY, 'true');\n else localStorage.removeItem(MULTI_DIM_ELO_KEY);\n } catch (e) {\n logger.warn(`[EloDistance] multiDimElo not persisted (localStorage unavailable): ${e}`);\n }\n logger.print(\n `[EloDistance] multiDimElo ${multiDimElo ? 'on: tag-aware' : 'off: per strategy config'}` +\n ' ELO distance from the next replan'\n );\n },\n });\n}\n\n// Auto-mount when module is loaded\nmountMultiDimEloToggle();\n\n/** One shared tag's contribution to a card's tag-aware gap. */\ninterface TagGap {\n tag: string;\n /** Card's tag rating minus the learner's: positive = harder than their level. */\n gap: number;\n weight: number;\n}\n\n/**\n * The card's difficulty for this learner, in ELO points (card − learner),\n * read on the tags they share.\n *\n * - Shared tags: the card's tags on which the learner has a real rating\n * (not a bookkeeping role, nor the count-only sentinel) resting on at least\n * `minTagCount` graded responses. A card with no rating of its own on a tag\n * uses its global, as the ELO update does when it first grades that tag.\n * - Each tag's gap is weighted by the learner's evidence on it,\n * n / (n + TAG_CONFIDENCE_HALF).\n * - The weighted mean of the tag gaps is blended with the global gap by the\n * total evidence W: λ = W / (W + 1). One thin tag barely moves it; several\n * practised tags dominate it.\n *\n * OPEN (draft, 2026-10-01). Shipped on by default in 0.2.29 by accident (it\n * rode along in the version-bump commit); off by default since, and live only\n * behind the toggle. On one LP learner's 09-30 dump the effect was modest: every touched card shared a rated tag\n * (median 4); mean multiplier ×0.70 → ×0.75 over 352 touched cards, ×0.84 →\n * ×0.88 over 42 due reviews. The biggest movers were old who-said-that cards:\n * ~400 below the learner globally, ~280 below on their own skills.\n *\n * 1. Compensatory or conjunctive. This averages: a weak skill is offset by\n * strong ones. For spelling a word, which needs every grapheme, the hardest\n * shared skill arguably sets the difficulty: take the largest gap instead.\n * The main design question.\n * 2. Which tags count. Broad tags (`concept:match:simple`, `ui:*`) sit on most\n * cards and act like a second global rating. The framework may want the\n * course to say which tags are skills (cf. LP's diagnostics interpreter\n * `isSkillTag`), e.g. as tag patterns in the strategy config.\n * The admin ELO viewer (in progress, 2026-10) answers the same question for\n * display with its own tag batches (role × namespace). Before tag-aware goes\n * on by default, make that one predicate:\n * - a serializable selector (roles, prefix patterns), beside `tagRoles.ts`\n * in common, so a strategy doc can carry it;\n * - an `EloDistanceConfig` field for it, read by `tagAwareGap`;\n * - `tagAwareGap` moved to a pure module (this file imports `core`, which\n * the diagnostics entry can't), so the viewer can show what the filter\n * would compute;\n * - the viewer's default batch read from the course's eloDistance config.\n * 3. New cards matter most, and that dump couldn't show them. An unseen\n * card's tag ratings fall back to its global, so for new cards this reads\n * \"card global vs the learner's rating on that skill\". Measuring it needs a\n * `--course all` dump.\n * 4. Cost. Tag-aware fetches full ratings for every candidate (~500 card docs\n * per run); global-only fetches only reviews'.\n * 5. Retrieval stays global. The ELO generator's window is the cards nearest\n * the learner's global ELO, so a card that's well matched on its skills but\n * far off globally may never be retrieved.\n * 6. Target. Distance 0 means ~50% expected success. Early learners may do\n * better aiming higher: a shift of the curve's centre, independent of this.\n */\nexport function tagAwareGap(\n cardTags: readonly string[],\n cardElo: CourseElo,\n userElo: CourseElo,\n minTagCount: number\n): { gap: number; globalGap: number; tags: TagGap[] } {\n const globalGap = cardElo.global.score - userElo.global.score;\n const tags: TagGap[] = [];\n for (const tag of cardTags) {\n const user = userElo.tags[tag];\n if (isCountOnlyTag(tag) || !user || user.score === COUNT_ONLY_SCORE || user.count < minTagCount) {\n continue;\n }\n const card = cardElo.tags[tag]?.score ?? cardElo.global.score;\n tags.push({\n tag,\n gap: card - user.score,\n weight: user.count / (user.count + TAG_CONFIDENCE_HALF),\n });\n }\n if (tags.length === 0) return { gap: globalGap, globalGap, tags };\n\n const total = tags.reduce((w, t) => w + t.weight, 0);\n const tagGap = tags.reduce((g, t) => g + t.weight * t.gap, 0) / total;\n const lambda = total / (total + 1);\n return { gap: lambda * tagGap + (1 - lambda) * globalGap, globalGap, tags };\n}\n\nfunction tagReason(tags: TagGap[], globalGap: number): string {\n const shown = [...tags]\n .sort((a, b) => Math.abs(b.gap) * b.weight - Math.abs(a.gap) * a.weight)\n .slice(0, 3)\n .map((t) => `${t.tag} ${t.gap >= 0 ? '+' : ''}${Math.round(t.gap)}`)\n .join(', ');\n const more = tags.length > 3 ? `, +${tags.length - 3} more` : '';\n return ` on ${tags.length} shared tag(s) [${shown}${more}] (global ${globalGap >= 0 ? '+' : ''}${Math.round(globalGap)})`;\n}\n\nasync function applyEloDistance(\n cards: WeightedCard[],\n context: FilterContext,\n config: Required<EloDistanceConfig>,\n source: { name: string; strategyId: string }\n): Promise<WeightedCard[]> {\n const { course, userElo, userCourseElo } = context;\n const { halfLife, minMultiplier, maxMultiplier } = config;\n const tagAware = (config.tagAware || multiDimElo) && userCourseElo !== undefined;\n\n // Tag-aware needs every card's full ratings; otherwise only the ELO of cards\n // that don't carry it (reviews). One batch either way.\n const missing = cards\n .filter((c) => !isIntroCard(c) && (tagAware || c.cardElo === undefined))\n .map((c) => c.cardId);\n const fetched = new Map<string, CourseElo>();\n if (missing.length > 0) {\n const elos = await course.getCardEloData(missing);\n missing.forEach((id, i) => {\n if (elos[i]) fetched.set(id, elos[i]);\n });\n }\n\n return cards.map((card) => {\n if (isIntroCard(card)) {\n return {\n ...card,\n provenance: [\n ...card.provenance,\n {\n strategy: 'eloDistance',\n strategyName: source.name,\n strategyId: source.strategyId,\n action: 'passed',\n score: card.score,\n reason: 'intro card: ELO is a placeholder, distance not applied → 1.00x',\n },\n ],\n };\n }\n\n const full = fetched.get(card.cardId);\n const cardElo = full?.global?.score ?? card.cardElo ?? DEFAULT_CARD_ELO;\n\n let distance = Math.abs(cardElo - userElo);\n let how = '';\n if (tagAware) {\n const t = full ? tagAwareGap(card.tags ?? [], full, userCourseElo!, config.minTagCount) : undefined;\n if (t) distance = Math.abs(t.gap);\n how = t?.tags.length\n ? `, tag-aware${tagReason(t.tags, t.globalGap)}`\n : ', tag-aware: global (no shared tags)';\n }\n\n const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);\n const newScore = card.score * multiplier;\n const action = multiplier < maxMultiplier - 0.01 ? 'penalized' : 'passed';\n\n return {\n ...card,\n cardElo,\n score: newScore,\n provenance: [\n ...card.provenance,\n {\n strategy: 'eloDistance',\n strategyName: source.name,\n strategyId: source.strategyId,\n action,\n score: newScore,\n reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)})${how} → ${multiplier.toFixed(2)}x`,\n },\n ],\n };\n });\n}\n\n/**\n * Create an ELO distance filter outside the strategy-doc path.\n *\n * @param config - Optional configuration for the curve\n */\nexport function createEloDistanceFilter(config?: EloDistanceConfig): CardFilter {\n const resolved = resolveConfig(config);\n const source = { name: 'ELO Distance Filter', strategyId: 'ELO_DISTANCE_FILTER' };\n return {\n name: source.name,\n kind: 'signal',\n liveOnly: true,\n transform: (cards, context) => applyEloDistance(cards, context, resolved, source),\n };\n}\n\n/**\n * The ELO distance filter as a strategy-doc navigator (`implementingClass:\n * 'eloDistance'`, serializedData: an EloDistanceConfig as JSON, or empty).\n */\nexport default class EloDistanceFilter extends ContentNavigator implements CardFilter {\n name: string;\n /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */\n static readonly kind: FilterKind = 'signal';\n readonly kind = EloDistanceFilter.kind;\n readonly liveOnly = true;\n private config: Required<EloDistanceConfig>;\n\n constructor(\n user: UserDBInterface,\n course: CourseDBInterface,\n strategyData: ContentNavigationStrategyData\n ) {\n super(user, course, strategyData);\n this.name = strategyData.name || 'ELO Distance';\n let parsed: EloDistanceConfig | undefined;\n try {\n parsed = strategyData.serializedData ? JSON.parse(strategyData.serializedData) : undefined;\n } catch {\n parsed = undefined;\n }\n this.config = resolveConfig(parsed);\n }\n\n transform(cards: WeightedCard[], context: FilterContext): Promise<WeightedCard[]> {\n return applyEloDistance(cards, context, this.config, {\n name: this.name,\n strategyId: this.strategyId || 'NAVIGATION_STRATEGY-eloDistance-default',\n });\n }\n\n async getWeightedCards(_limit: number): Promise<GeneratorResult> {\n throw new Error(\n 'EloDistanceFilter is a filter and should not be used as a generator. ' +\n 'Use Pipeline with a generator and this filter via transform().'\n );\n }\n}\n"],"mappings":";;;;;;;;;AA4FA,MAAa,8BAA2D;CACtE,UAAU;CACV,eAAe;CACf,eAAe;CACf,UAAU;CACV,aAAa;CACd;;;;;AAMD,MAAM,sBAAsB;;AAG5B,SAAS,YAAY,MAA6B;AAChD,SAAQ,KAAK,QAAQ,EAAE,EAAE,MAAM,MAAM,QAAQ,EAAE,KAAK,QAAQ;;;AAI9D,MAAM,mBAAmB;AAEzB,SAAS,kBACP,UACA,UACA,eACA,eACQ;CACR,MAAM,qBAAqB,WAAW;CACtC,MAAM,QAAQ,KAAK,IAAI,EAAE,qBAAqB,oBAAoB;AAClE,QAAO,iBAAiB,gBAAgB,iBAAiB;;AAG3D,SAAS,cAAc,QAAyD;AAC9E,QAAO;EAAE,GAAG;EAA6B,GAAG;EAAQ;;AAatD,MAAM,oBAAoB;AAE1B,IAAI,cAAc,iBAAiB;AAEnC,SAAS,kBAA2B;AAClC,KAAI;AACF,SAAO,OAAO,iBAAiB,eA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ACA,QAAM,MAAM,QAAQ,aAAa;AACjC,OAAK,OAAO,aAAa,QAAQ;EACjC,IAAI;AACJ,MAAI;AACF,YAAS,aAAa,iBAAiB,KAAK,MAAM,aAAa,eAAe,GAAG,KAAA;UAC3E;AACN,YAAS,KAAA;;AAEX,OAAK,SAAS,cAAc,OAAO;;CAGrC,UAAU,OAAuB,SAAiD;AAChF,SAAO,iBAAiB,OAAO,SAAS,KAAK,QAAQ;GACnD,MAAM,KAAK;GACX,YAAY,KAAK,cAAc;GAChC,CAAC;;CAGJ,MAAM,iBAAiB,QAA0C;AAC/D,QAAM,IAAI,MACR,sIAED"}
1
+ {"version":3,"file":"eloDistance.mjs","names":[],"sources":["../../../../src/core/navigators/filters/eloDistance.ts"],"sourcesContent":["import type { CourseDBInterface } from '../../interfaces/courseDB';\nimport type { UserDBInterface } from '../../interfaces/userDB';\nimport type { ContentNavigationStrategyData } from '../../types/contentNavigationStrategy';\nimport { ContentNavigator } from '../index';\nimport type { WeightedCard } from '../index';\nimport type { GeneratorResult } from '../generators/types';\nimport type { CardFilter, FilterContext, FilterKind } from './types';\nimport { COUNT_ONLY_SCORE, isCountOnlyTag, tagRole, type CourseElo } from '@vue-skuilder/common';\nimport { logger } from '../../../util/logger';\n\n// ============================================================================\n// ELO DISTANCE FILTER\n// ============================================================================\n//\n// Scales every candidate by how close its ELO is to the learner's, on a smooth\n// Gaussian (no discontinuities, never zero).\n//\n// The one place ELO distance counts. Generators retrieve (the ELO generator\n// pulls a window of cards near the learner's ELO) and score only on what's\n// specific to their source; a signal that applies to every card lives in one\n// heap-wide filter, so new cards and reviews are weighed on the same terms:\n// - reviews the learner has moved beyond fade, and may never surface over\n// higher-priority work;\n// - new cards far from the learner's level rank low (this used to live in the\n// ELO generator's own score, which double-counted alongside this filter).\n//\n// Tag-aware (opt-in, experimental): a card's difficulty for this learner is\n// read on the skills they share, not only on global ELO. Card and learner keep\n// paired ratings per tag (each graded response adjusts both), so a tag's gap\n// (card − learner) is as meaningful as the global one, and often more: a card\n// can sit at the learner's global level while testing their weakest skill.\n// See tagAwareGap for the combination. Global distance is the default; a course\n// opts in with `tagAware`, a browser with `window.skuilder.multiDimElo = true`\n// (see the toggle below), for side-by-side testing.\n//\n// Intro cards pass through untouched. They carry an `intro`-role tag, grade\n// nothing, and their ELO is a placeholder, so a distance on it means nothing.\n// Penalising them starves established learners of intros: a learner rated\n// well above the placeholder sees every intro at the curve's floor.\n//\n// A `signal`, not a gate: it expresses preference, not readiness. `liveOnly`:\n// forecasts and card-space scans start every card at 1.0 without a generator,\n// and never applied ELO distance, so they skip it.\n//\n// The assembler adds this filter (as \"ELO Distance (default)\") to every\n// pipeline whose strategy docs don't declare one. A course tunes it by\n// declaring its own `eloDistance` strategy doc with an EloDistanceConfig.\n//\n// ============================================================================\n\n/**\n * Configuration for the ELO distance curve:\n * `minMultiplier + (maxMultiplier − minMultiplier) · exp(−(distance / halfLife)²)`.\n */\nexport interface EloDistanceConfig {\n /**\n * The Gaussian's scale in ELO points (despite the name, not a half-life).\n * Default 300: distance 250 → ~0.5, as the ELO generator scored new cards.\n *\n * - distance 0: maxMultiplier\n * - distance = halfLife: ~0.4 (with the default floor)\n * - distance = 2 · halfLife: ~0.07\n */\n halfLife?: number;\n\n /**\n * Floor, so far-off cards keep a nonzero score (the pipeline drops zero\n * scores before hints, and a hint must be able to lift any card). Default 0.05.\n */\n minMultiplier?: number;\n\n /** Ceiling. Usually 1.0 (no boost for close cards). Default 1.0. */\n maxMultiplier?: number;\n\n /**\n * Measure distance on the tags the card and learner share (see\n * tagAwareGap), falling back to global ELO where they share none.\n * Default false. `window.skuilder.multiDimElo` turns it on in one browser.\n */\n tagAware?: boolean;\n\n /**\n * A learner's tag rating counts once it rests on at least this many graded\n * responses. Count-only (exposure) tags never count. Default 3.\n */\n minTagCount?: number;\n}\n\n/**\n * The default curve. The default strategy doc carries it as its config, so\n * the admin pipeline view shows what runs.\n */\nexport const DEFAULT_ELO_DISTANCE_CONFIG: Required<EloDistanceConfig> = {\n halfLife: 300,\n minMultiplier: 0.05,\n maxMultiplier: 1.0,\n tagAware: false,\n minTagCount: 3,\n};\n\n/**\n * Graded responses at which a tag's gap carries half its full weight. Thin\n * tag evidence leans on global ELO; well-practised tags dominate.\n */\nconst TAG_CONFIDENCE_HALF = 10;\n\n/** Whether the card is an intro: any `intro`-role tag. Its ELO is a placeholder. */\nfunction isIntroCard(card: WeightedCard): boolean {\n return (card.tags ?? []).some((t) => tagRole(t) === 'intro');\n}\n\n/** Fallback card ELO when a card has none recorded. */\nconst DEFAULT_CARD_ELO = 1000;\n\nfunction computeMultiplier(\n distance: number,\n halfLife: number,\n minMultiplier: number,\n maxMultiplier: number\n): number {\n const normalizedDistance = distance / halfLife;\n const decay = Math.exp(-(normalizedDistance * normalizedDistance));\n return minMultiplier + (maxMultiplier - minMultiplier) * decay;\n}\n\nfunction resolveConfig(config?: EloDistanceConfig): Required<EloDistanceConfig> {\n return { ...DEFAULT_ELO_DISTANCE_CONFIG, ...config };\n}\n\n// ----------------------------------------------------------------------------\n// Live toggle: window.skuilder.multiDimElo\n// ----------------------------------------------------------------------------\n//\n// `window.skuilder.multiDimElo = true` turns tag-aware distance on in this\n// browser, whatever the strategy config says; `false` returns it to the\n// config. Read on every run, so it takes effect at the next replan. Kept in\n// localStorage so it survives reloads across a testing stretch. Runs it shapes\n// say so in every card's ELO distance reason (\"tag-aware\").\n\nconst MULTI_DIM_ELO_KEY = 'skuilder:multiDimElo';\n\nlet multiDimElo = readMultiDimElo();\n\nfunction readMultiDimElo(): boolean {\n try {\n return typeof localStorage !== 'undefined' && localStorage.getItem(MULTI_DIM_ELO_KEY) === 'true';\n } catch {\n return false;\n }\n}\n\n/**\n * Mount the toggle on window.skuilder.multiDimElo.\n */\nexport function mountMultiDimEloToggle(): void {\n if (typeof window === 'undefined') return;\n\n const win = window as any;\n win.skuilder = win.skuilder || {};\n Object.defineProperty(win.skuilder, 'multiDimElo', {\n configurable: true,\n enumerable: true,\n get: () => multiDimElo,\n set: (on: unknown) => {\n multiDimElo = on === true;\n try {\n if (multiDimElo) localStorage.setItem(MULTI_DIM_ELO_KEY, 'true');\n else localStorage.removeItem(MULTI_DIM_ELO_KEY);\n } catch (e) {\n logger.warn(`[EloDistance] multiDimElo not persisted (localStorage unavailable): ${e}`);\n }\n logger.print(\n `[EloDistance] multiDimElo ${multiDimElo ? 'on: tag-aware' : 'off: per strategy config'}` +\n ' ELO distance from the next replan'\n );\n },\n });\n}\n\n// Auto-mount when module is loaded\nmountMultiDimEloToggle();\n\n/** One shared tag's contribution to a card's tag-aware gap. */\ninterface TagGap {\n tag: string;\n /** Card's tag rating minus the learner's: positive = harder than their level. */\n gap: number;\n weight: number;\n}\n\n/**\n * The card's difficulty for this learner, in ELO points (card − learner),\n * read on the tags they share.\n *\n * - Shared tags: the card's tags on which the learner has a real rating\n * (not a bookkeeping role, nor the count-only sentinel) resting on at least\n * `minTagCount` graded responses. A card with no rating of its own on a tag\n * uses its global, as the ELO update does when it first grades that tag.\n * - Each tag's gap is weighted by the learner's evidence on it,\n * n / (n + TAG_CONFIDENCE_HALF).\n * - The weighted mean of the tag gaps is blended with the global gap by the\n * total evidence W: λ = W / (W + 1). One thin tag barely moves it; several\n * practised tags dominate it.\n *\n * OPEN (draft, 2026-10-01). Shipped on by default in 0.2.29 by accident (it\n * rode along in the version-bump commit); off by default since, and live only\n * behind the toggle. On one LP learner's 09-30 dump the effect was modest: every touched card shared a rated tag\n * (median 4); mean multiplier ×0.70 → ×0.75 over 352 touched cards, ×0.84 →\n * ×0.88 over 42 due reviews. The biggest movers were old who-said-that cards:\n * ~400 below the learner globally, ~280 below on their own skills.\n *\n * 1. Compensatory or conjunctive. This averages: a weak skill is offset by\n * strong ones. For spelling a word, which needs every grapheme, the hardest\n * shared skill arguably sets the difficulty: take the largest gap instead.\n * The main design question.\n * 2. Which tags count. Broad tags (`concept:match:simple`, `ui:*`) sit on most\n * cards and act like a second global rating. The framework may want the\n * course to say which tags are skills (cf. LP's diagnostics interpreter\n * `isSkillTag`), e.g. as tag patterns in the strategy config.\n * The admin ELO viewer (in progress, 2026-10) answers the same question for\n * display with its own tag batches (role × namespace). Before tag-aware goes\n * on by default, make that one predicate:\n * - a serializable selector (roles, prefix patterns), beside `tagRoles.ts`\n * in common, so a strategy doc can carry it;\n * - an `EloDistanceConfig` field for it, read by `tagAwareGap`;\n * - `tagAwareGap` moved to a pure module (this file imports `core`, which\n * the diagnostics entry can't), so the viewer can show what the filter\n * would compute;\n * - the viewer's default batch read from the course's eloDistance config.\n * 3. New cards matter most, and that dump couldn't show them. An unseen\n * card's tag ratings fall back to its global, so for new cards this reads\n * \"card global vs the learner's rating on that skill\". Measuring it needs a\n * `--course all` dump.\n * 4. Cost. Tag-aware fetches full ratings for every candidate (~500 card docs\n * per run); global-only fetches only reviews'.\n * 5. Retrieval stays global. The ELO generator's window is the cards nearest\n * the learner's global ELO, so a card that's well matched on its skills but\n * far off globally may never be retrieved.\n * 6. Target. Distance 0 means ~50% expected success. Early learners may do\n * better aiming higher: a shift of the curve's centre, independent of this.\n */\nexport function tagAwareGap(\n cardTags: readonly string[],\n cardElo: CourseElo,\n userElo: CourseElo,\n minTagCount: number\n): { gap: number; globalGap: number; tags: TagGap[] } {\n const globalGap = cardElo.global.score - userElo.global.score;\n const tags: TagGap[] = [];\n for (const tag of cardTags) {\n const user = userElo.tags[tag];\n if (isCountOnlyTag(tag) || !user || user.score === COUNT_ONLY_SCORE || user.count < minTagCount) {\n continue;\n }\n const card = cardElo.tags[tag]?.score ?? cardElo.global.score;\n tags.push({\n tag,\n gap: card - user.score,\n weight: user.count / (user.count + TAG_CONFIDENCE_HALF),\n });\n }\n if (tags.length === 0) return { gap: globalGap, globalGap, tags };\n\n const total = tags.reduce((w, t) => w + t.weight, 0);\n const tagGap = tags.reduce((g, t) => g + t.weight * t.gap, 0) / total;\n const lambda = total / (total + 1);\n return { gap: lambda * tagGap + (1 - lambda) * globalGap, globalGap, tags };\n}\n\nfunction tagReason(tags: TagGap[], globalGap: number): string {\n const shown = [...tags]\n .sort((a, b) => Math.abs(b.gap) * b.weight - Math.abs(a.gap) * a.weight)\n .slice(0, 3)\n .map((t) => `${t.tag} ${t.gap >= 0 ? '+' : ''}${Math.round(t.gap)}`)\n .join(', ');\n const more = tags.length > 3 ? `, +${tags.length - 3} more` : '';\n return ` on ${tags.length} shared tag(s) [${shown}${more}] (global ${globalGap >= 0 ? '+' : ''}${Math.round(globalGap)})`;\n}\n\nasync function applyEloDistance(\n cards: WeightedCard[],\n context: FilterContext,\n config: Required<EloDistanceConfig>,\n source: { name: string; strategyId: string }\n): Promise<WeightedCard[]> {\n const { course, userElo, userCourseElo } = context;\n const { halfLife, minMultiplier, maxMultiplier } = config;\n const tagAware = (config.tagAware || multiDimElo) && userCourseElo !== undefined;\n\n // Tag-aware needs every card's full ratings; otherwise only the ELO of cards\n // that don't carry it (reviews). One batch either way.\n const missing = cards\n .filter((c) => !isIntroCard(c) && (tagAware || c.cardElo === undefined))\n .map((c) => c.cardId);\n const fetched = new Map<string, CourseElo>();\n if (missing.length > 0) {\n const elos = await course.getCardEloData(missing);\n missing.forEach((id, i) => {\n if (elos[i]) fetched.set(id, elos[i]);\n });\n }\n\n return cards.map((card) => {\n if (isIntroCard(card)) {\n return {\n ...card,\n provenance: [\n ...card.provenance,\n {\n strategy: 'eloDistance',\n strategyName: source.name,\n strategyId: source.strategyId,\n action: 'passed',\n score: card.score,\n reason: 'intro card: ELO is a placeholder, distance not applied → 1.00x',\n },\n ],\n };\n }\n\n const full = fetched.get(card.cardId);\n const cardElo = full?.global?.score ?? card.cardElo ?? DEFAULT_CARD_ELO;\n\n let distance = Math.abs(cardElo - userElo);\n let how = '';\n if (tagAware) {\n const t = full ? tagAwareGap(card.tags ?? [], full, userCourseElo!, config.minTagCount) : undefined;\n if (t) distance = Math.abs(t.gap);\n how = t?.tags.length\n ? `, tag-aware${tagReason(t.tags, t.globalGap)}`\n : ', tag-aware: global (no shared tags)';\n }\n\n const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);\n const newScore = card.score * multiplier;\n const action = multiplier < maxMultiplier - 0.01 ? 'penalized' : 'passed';\n\n return {\n ...card,\n cardElo,\n score: newScore,\n provenance: [\n ...card.provenance,\n {\n strategy: 'eloDistance',\n strategyName: source.name,\n strategyId: source.strategyId,\n action,\n score: newScore,\n reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)})${how} → ${multiplier.toFixed(2)}x`,\n },\n ],\n };\n });\n}\n\n/**\n * Create an ELO distance filter outside the strategy-doc path.\n *\n * @param config - Optional configuration for the curve\n */\nexport function createEloDistanceFilter(config?: EloDistanceConfig): CardFilter {\n const resolved = resolveConfig(config);\n const source = { name: 'ELO Distance Filter', strategyId: 'ELO_DISTANCE_FILTER' };\n return {\n name: source.name,\n kind: 'signal',\n liveOnly: true,\n transform: (cards, context) => applyEloDistance(cards, context, resolved, source),\n };\n}\n\n/**\n * The ELO distance filter as a strategy-doc navigator (`implementingClass:\n * 'eloDistance'`, serializedData: an EloDistanceConfig as JSON, or empty).\n */\nexport default class EloDistanceFilter extends ContentNavigator implements CardFilter {\n name: string;\n /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */\n static readonly kind: FilterKind = 'signal';\n readonly kind = EloDistanceFilter.kind;\n readonly liveOnly = true;\n private config: Required<EloDistanceConfig>;\n\n constructor(\n user: UserDBInterface,\n course: CourseDBInterface,\n strategyData: ContentNavigationStrategyData\n ) {\n super(user, course, strategyData);\n this.name = strategyData.name || 'ELO Distance';\n let parsed: EloDistanceConfig | undefined;\n try {\n parsed = strategyData.serializedData ? JSON.parse(strategyData.serializedData) : undefined;\n } catch {\n parsed = undefined;\n }\n this.config = resolveConfig(parsed);\n }\n\n transform(cards: WeightedCard[], context: FilterContext): Promise<WeightedCard[]> {\n return applyEloDistance(cards, context, this.config, {\n name: this.name,\n strategyId: this.strategyId || 'NAVIGATION_STRATEGY-eloDistance-default',\n });\n }\n\n async getWeightedCards(_limit: number): Promise<GeneratorResult> {\n throw new Error(\n 'EloDistanceFilter is a filter and should not be used as a generator. ' +\n 'Use Pipeline with a generator and this filter via transform().'\n );\n }\n}\n"],"mappings":";;;;;;;;;AA4FA,MAAa,8BAA2D;CACtE,UAAU;CACV,eAAe;CACf,eAAe;CACf,UAAU;CACV,aAAa;CACd;;;;;AAMD,MAAM,sBAAsB;;AAG5B,SAAS,YAAY,MAA6B;AAChD,SAAQ,KAAK,QAAQ,EAAE,EAAE,MAAM,MAAM,QAAQ,EAAE,KAAK,QAAQ;;;AAI9D,MAAM,mBAAmB;AAEzB,SAAS,kBACP,UACA,UACA,eACA,eACQ;CACR,MAAM,qBAAqB,WAAW;CACtC,MAAM,QAAQ,KAAK,IAAI,EAAE,qBAAqB,oBAAoB;AAClE,QAAO,iBAAiB,gBAAgB,iBAAiB;;AAG3D,SAAS,cAAc,QAAyD;AAC9E,QAAO;EAAE,GAAG;EAA6B,GAAG;EAAQ;;AAatD,MAAM,oBAAoB;AAE1B,IAAI,cAAc,iBAAiB;AAEnC,SAAS,kBAA2B;AAClC,KAAI;AACF,SAAO,OAAO,iBAAiB,eAAe,aAAa,QAAQ,kBAAkB,KAAK;SACpF;AACN,SAAO;;;;;;AAOX,SAAgB,yBAA+B;AAC7C,KAAI,OAAO,WAAW,YAAa;CAEnC,MAAM,MAAM;AACZ,KAAI,WAAW,IAAI,YAAY,EAAE;AACjC,QAAO,eAAe,IAAI,UAAU,eAAe;EACjD,cAAc;EACd,YAAY;EACZ,WAAW;EACX,MAAM,OAAgB;AACpB,iBAAc,OAAO;AACrB,OAAI;AACF,QAAI,YAAa,cAAa,QAAQ,mBAAmB,OAAO;QAC3D,cAAa,WAAW,kBAAkB;YACxC,GAAG;AACV,WAAO,KAAK,uEAAuE,IAAI;;AAEzF,UAAO,MACL,6BAA6B,cAAc,kBAAkB,2BAAA,oCAE9D;;EAEJ,CAAC;;AAIJ,wBAAwB;;;;;;;;;;;;;;;;;;;;;;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AM,SAAS,aAAa,gBAAgB,MAAO,cAAc;AAEjE,SAAO;GACL,GAAG;GACH;GACA,OAAO;GACP,YAAY,CACV,GAAG,KAAK,YACR;IACE,UAAU;IACV,cAAc,OAAO;IACrB,YAAY,OAAO;IACnB;IACA,OAAO;IACP,QAAQ,gBAAgB,KAAK,MAAM,SAAS,CAAC,UAAU,KAAK,MAAM,QAAQ,CAAC,UAAU,KAAK,MAAM,QAAQ,CAAC,GAAG,IAAI,KAAK,WAAW,QAAQ,EAAE,CAAC;IAC5I,CACF;GACF;GACD;;;;;;;AAQJ,SAAgB,wBAAwB,QAAwC;CAC9E,MAAM,WAAW,cAAc,OAAO;CACtC,MAAM,SAAS;EAAE,MAAM;EAAuB,YAAY;EAAuB;AACjF,QAAO;EACL,MAAM,OAAO;EACb,MAAM;EACN,UAAU;EACV,YAAY,OAAO,YAAY,iBAAiB,OAAO,SAAS,UAAU,OAAO;EAClF;;;;;;AAOH,IAAqB,oBAArB,MAAqB,0BAA0B,iBAAuC;CACpF;;CAEA,OAAgB,OAAmB;CACnC,OAAgB,kBAAkB;CAClC,WAAoB;CACpB;CAEA,YACE,MACA,QACA,cACA;AACA,QAAM,MAAM,QAAQ,aAAa;AACjC,OAAK,OAAO,aAAa,QAAQ;EACjC,IAAI;AACJ,MAAI;AACF,YAAS,aAAa,iBAAiB,KAAK,MAAM,aAAa,eAAe,GAAG,KAAA;UAC3E;AACN,YAAS,KAAA;;AAEX,OAAK,SAAS,cAAc,OAAO;;CAGrC,UAAU,OAAuB,SAAiD;AAChF,SAAO,iBAAiB,OAAO,SAAS,KAAK,QAAQ;GACnD,MAAM,KAAK;GACX,YAAY,KAAK,cAAc;GAChC,CAAC;;CAGJ,MAAM,iBAAiB,QAA0C;AAC/D,QAAM,IAAI,MACR,sIAED"}
@@ -0,0 +1,109 @@
1
+ import "../../../_virtual/_rolldown/runtime.mjs";
2
+ import { ContentNavigator } from "../index.mjs";
3
+ import { courseSecurity, skillNeed } from "@vue-skuilder/common";
4
+ //#region src/core/navigators/filters/skillPressure.ts
5
+ const DEFAULT_GAIN = .5;
6
+ const DEFAULT_SECURITY_WEIGHTS = {
7
+ shaky: .8,
8
+ unproven: .5
9
+ };
10
+ /** Pressure per skill tag for this learner; tags under no pressure are absent. */
11
+ function skillPressures(elo, config = {}) {
12
+ const out = /* @__PURE__ */ new Map();
13
+ const raise = (tag, pressure, why) => {
14
+ if (pressure <= 0) return;
15
+ const prev = out.get(tag);
16
+ if (!prev || pressure > prev.pressure) out.set(tag, {
17
+ pressure,
18
+ why
19
+ });
20
+ };
21
+ for (const s of skillNeed(elo, config).skills) raise(s.tag, s.need, `need ${s.need.toFixed(2)} (${Math.round(s.deficit)} below the skill median)`);
22
+ if (config.security !== false) {
23
+ const weights = {
24
+ ...DEFAULT_SECURITY_WEIGHTS,
25
+ ...config.security ?? {}
26
+ };
27
+ const { include, exclude, roles } = config;
28
+ const security = courseSecurity(elo, {
29
+ selector: {
30
+ include,
31
+ exclude,
32
+ roles
33
+ },
34
+ config: config.security ? config.security.config : void 0
35
+ });
36
+ for (const s of security.tags) {
37
+ if (s.status === "secure") continue;
38
+ const n = Math.min(s.attempts, 12);
39
+ raise(s.tag, weights[s.status], s.status === "shaky" ? `shaky (${s.right}/${n} right)` : `unproven (${s.attempts} recent attempts)`);
40
+ }
41
+ }
42
+ return out;
43
+ }
44
+ async function applySkillPressure(cards, context, config, source) {
45
+ if (!context.userCourseElo) return cards;
46
+ const pressures = skillPressures(context.userCourseElo, config);
47
+ if (pressures.size === 0) return cards;
48
+ const gain = config.gain ?? DEFAULT_GAIN;
49
+ return cards.map((card) => {
50
+ let top = null;
51
+ for (const tag of card.tags ?? []) {
52
+ const entry = pressures.get(tag);
53
+ if (entry && (!top || entry.pressure > top.entry.pressure)) top = {
54
+ tag,
55
+ entry
56
+ };
57
+ }
58
+ if (!top) return card;
59
+ const multiplier = 1 + gain * top.entry.pressure;
60
+ const score = card.score * multiplier;
61
+ return {
62
+ ...card,
63
+ score,
64
+ provenance: [...card.provenance, {
65
+ strategy: "skillPressure",
66
+ strategyName: source.name,
67
+ strategyId: source.strategyId,
68
+ action: "boosted",
69
+ score,
70
+ reason: `skill pressure: ${top.tag} ${top.entry.why} → ×${multiplier.toFixed(2)}`
71
+ }]
72
+ };
73
+ });
74
+ }
75
+ /**
76
+ * The skill pressure filter as a strategy-doc navigator (`implementingClass:
77
+ * 'skillPressure'`, serializedData: a SkillPressureConfig as JSON, or empty).
78
+ */
79
+ var SkillPressureFilter = class SkillPressureFilter extends ContentNavigator {
80
+ name;
81
+ /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
82
+ static kind = "signal";
83
+ kind = SkillPressureFilter.kind;
84
+ config;
85
+ constructor(user, course, strategyData) {
86
+ super(user, course, strategyData);
87
+ this.name = strategyData.name || "Skill Pressure";
88
+ let parsed = {};
89
+ try {
90
+ parsed = strategyData.serializedData ? JSON.parse(strategyData.serializedData) : {};
91
+ } catch {
92
+ parsed = {};
93
+ }
94
+ this.config = parsed;
95
+ }
96
+ transform(cards, context) {
97
+ return applySkillPressure(cards, context, this.config, {
98
+ name: this.name,
99
+ strategyId: this.strategyId || "NAVIGATION_STRATEGY-skillPressure"
100
+ });
101
+ }
102
+ async getWeightedCards(_limit) {
103
+ throw new Error("SkillPressureFilter is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform().");
104
+ }
105
+ };
106
+ //#endregion
107
+ export { SkillPressureFilter as default, skillPressures };
108
+
109
+ //# sourceMappingURL=skillPressure.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skillPressure.mjs","names":[],"sources":["../../../../src/core/navigators/filters/skillPressure.ts"],"sourcesContent":["import {\n courseSecurity,\n skillNeed,\n type CourseElo,\n type SkillNeedConfig,\n type TagSecurityConfig,\n type TagSecurityStatus,\n} from '@vue-skuilder/common';\nimport type { CourseDBInterface } from '../../interfaces/courseDB';\nimport type { UserDBInterface } from '../../interfaces/userDB';\nimport type { ContentNavigationStrategyData } from '../../types/contentNavigationStrategy';\nimport { ContentNavigator } from '../index';\nimport type { WeightedCard } from '../index';\nimport type { GeneratorResult } from '../generators/types';\nimport type { CardFilter, FilterContext, FilterKind } from './types';\n\n// ============================================================================\n// SKILL PRESSURE FILTER\n// ============================================================================\n//\n// Leans selection toward the learner's weakest skills: a card exercising a\n// skill under pressure gets a small, bounded boost. \"Which skill\", kept\n// separate from ELO distance's \"what difficulty\", so each is its own line in\n// a card's provenance.\n//\n// A skill's pressure (0–1) is the larger of:\n// - need (common/skillNeed): how far its rating sits below the median of the\n// learner's skills;\n// - insecurity (common/tagSecurity), when enabled: a fixed weight for a met\n// skill that is shaky (right too rarely lately) or unproven (too little\n// recent evidence). This is what works down the insecure count a course may\n// gate new material on; need alone misses skills rated near the median but\n// missed lately, and skills with too few responses to rate.\n//\n// multiplier = 1 + gain · (the card's highest skill pressure). The max over a\n// card's tags, never the product, so a card naming several weak skills isn't\n// boosted several times.\n//\n// Acts on the whole heap, reviews included: its first effect under a review\n// backlog is on *which* reviews are served. A boost can't bring a card that no\n// generator retrieved; retrieval of a weak skill's unseen cards is a\n// generator's job.\n//\n// A `signal`. Not added by default: it re-weights every candidate, so a course\n// opts in with a `skillPressure` strategy doc (serializedData: a\n// SkillPressureConfig as JSON, or empty for the defaults).\n//\n// ============================================================================\n\nexport interface SkillPressureConfig extends SkillNeedConfig {\n /** Boost at pressure 1: multiplier = 1 + gain · pressure. Default 0.5 (cap ×1.5). */\n gain?: number;\n /**\n * Insecurity as pressure. `false` turns it off (need only). Weights are\n * need-equivalents, 0–1. Default: shaky 0.8, unproven 0.5. Uses the same\n * tag selector as need.\n */\n security?:\n | false\n | {\n shaky?: number;\n unproven?: number;\n /** Thresholds for secure / shaky / unproven. Default: the framework's. */\n config?: TagSecurityConfig;\n };\n}\n\nconst DEFAULT_GAIN = 0.5;\nconst DEFAULT_SECURITY_WEIGHTS: Record<Exclude<TagSecurityStatus, 'secure'>, number> = {\n shaky: 0.8,\n unproven: 0.5,\n};\n\ninterface SkillPressureEntry {\n pressure: number;\n why: string;\n}\n\n/** Pressure per skill tag for this learner; tags under no pressure are absent. */\nexport function skillPressures(\n elo: CourseElo,\n config: SkillPressureConfig = {}\n): Map<string, SkillPressureEntry> {\n const out = new Map<string, SkillPressureEntry>();\n const raise = (tag: string, pressure: number, why: string): void => {\n if (pressure <= 0) return;\n const prev = out.get(tag);\n if (!prev || pressure > prev.pressure) out.set(tag, { pressure, why });\n };\n\n for (const s of skillNeed(elo, config).skills) {\n raise(s.tag, s.need, `need ${s.need.toFixed(2)} (${Math.round(s.deficit)} below the skill median)`);\n }\n\n if (config.security !== false) {\n const weights = { ...DEFAULT_SECURITY_WEIGHTS, ...(config.security ?? {}) };\n const { include, exclude, roles } = config;\n const security = courseSecurity(elo, {\n selector: { include, exclude, roles },\n config: config.security ? config.security.config : undefined,\n });\n for (const s of security.tags) {\n if (s.status === 'secure') continue;\n const n = Math.min(s.attempts, 12);\n raise(\n s.tag,\n weights[s.status],\n s.status === 'shaky' ? `shaky (${s.right}/${n} right)` : `unproven (${s.attempts} recent attempts)`\n );\n }\n }\n return out;\n}\n\nasync function applySkillPressure(\n cards: WeightedCard[],\n context: FilterContext,\n config: SkillPressureConfig,\n source: { name: string; strategyId: string }\n): Promise<WeightedCard[]> {\n if (!context.userCourseElo) return cards;\n const pressures = skillPressures(context.userCourseElo, config);\n if (pressures.size === 0) return cards;\n const gain = config.gain ?? DEFAULT_GAIN;\n\n return cards.map((card) => {\n let top: { tag: string; entry: SkillPressureEntry } | null = null;\n for (const tag of card.tags ?? []) {\n const entry = pressures.get(tag);\n if (entry && (!top || entry.pressure > top.entry.pressure)) top = { tag, entry };\n }\n if (!top) return card;\n\n const multiplier = 1 + gain * top.entry.pressure;\n const score = card.score * multiplier;\n return {\n ...card,\n score,\n provenance: [\n ...card.provenance,\n {\n strategy: 'skillPressure',\n strategyName: source.name,\n strategyId: source.strategyId,\n action: 'boosted',\n score,\n reason: `skill pressure: ${top.tag} ${top.entry.why} → ×${multiplier.toFixed(2)}`,\n },\n ],\n };\n });\n}\n\n/**\n * The skill pressure filter as a strategy-doc navigator (`implementingClass:\n * 'skillPressure'`, serializedData: a SkillPressureConfig as JSON, or empty).\n */\nexport default class SkillPressureFilter extends ContentNavigator implements CardFilter {\n name: string;\n /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */\n static readonly kind: FilterKind = 'signal';\n readonly kind = SkillPressureFilter.kind;\n private config: SkillPressureConfig;\n\n constructor(\n user: UserDBInterface,\n course: CourseDBInterface,\n strategyData: ContentNavigationStrategyData\n ) {\n super(user, course, strategyData);\n this.name = strategyData.name || 'Skill Pressure';\n let parsed: SkillPressureConfig = {};\n try {\n parsed = strategyData.serializedData ? JSON.parse(strategyData.serializedData) : {};\n } catch {\n parsed = {};\n }\n this.config = parsed;\n }\n\n transform(cards: WeightedCard[], context: FilterContext): Promise<WeightedCard[]> {\n return applySkillPressure(cards, context, this.config, {\n name: this.name,\n strategyId: this.strategyId || 'NAVIGATION_STRATEGY-skillPressure',\n });\n }\n\n async getWeightedCards(_limit: number): Promise<GeneratorResult> {\n throw new Error(\n 'SkillPressureFilter is a filter and should not be used as a generator. ' +\n 'Use Pipeline with a generator and this filter via transform().'\n );\n }\n}\n"],"mappings":";;;;AAmEA,MAAM,eAAe;AACrB,MAAM,2BAAiF;CACrF,OAAO;CACP,UAAU;CACX;;AAQD,SAAgB,eACd,KACA,SAA8B,EAAE,EACC;CACjC,MAAM,sBAAM,IAAI,KAAiC;CACjD,MAAM,SAAS,KAAa,UAAkB,QAAsB;AAClE,MAAI,YAAY,EAAG;EACnB,MAAM,OAAO,IAAI,IAAI,IAAI;AACzB,MAAI,CAAC,QAAQ,WAAW,KAAK,SAAU,KAAI,IAAI,KAAK;GAAE;GAAU;GAAK,CAAC;;AAGxE,MAAK,MAAM,KAAK,UAAU,KAAK,OAAO,CAAC,OACrC,OAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,EAAE,KAAK,QAAQ,EAAE,CAAC,IAA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