@vue-skuilder/db 0.2.23 → 0.2.25

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 (37) hide show
  1. package/dist/{contentSource-DT9NaX69.d.cts → contentSource-CrRnbjBx.d.cts} +63 -2
  2. package/dist/{contentSource-BvOpKUeU.d.ts → contentSource-kD35o65m.d.ts} +63 -2
  3. package/dist/core/index.d.cts +3 -3
  4. package/dist/core/index.d.ts +3 -3
  5. package/dist/core/index.js +2474 -481
  6. package/dist/core/index.js.map +1 -1
  7. package/dist/core/index.mjs +2464 -466
  8. package/dist/core/index.mjs.map +1 -1
  9. package/dist/{dataLayerProvider-CY2B2lyW.d.ts → dataLayerProvider-CtzddVdy.d.ts} +1 -1
  10. package/dist/{dataLayerProvider-wY6s_4x9.d.cts → dataLayerProvider-IecbidDO.d.cts} +1 -1
  11. package/dist/impl/couch/index.d.cts +2 -2
  12. package/dist/impl/couch/index.d.ts +2 -2
  13. package/dist/impl/couch/index.js +2237 -238
  14. package/dist/impl/couch/index.js.map +1 -1
  15. package/dist/impl/couch/index.mjs +2231 -227
  16. package/dist/impl/couch/index.mjs.map +1 -1
  17. package/dist/impl/static/index.d.cts +2 -2
  18. package/dist/impl/static/index.d.ts +2 -2
  19. package/dist/impl/static/index.js +2319 -320
  20. package/dist/impl/static/index.js.map +1 -1
  21. package/dist/impl/static/index.mjs +2309 -305
  22. package/dist/impl/static/index.mjs.map +1 -1
  23. package/dist/index.d.cts +32 -7
  24. package/dist/index.d.ts +32 -7
  25. package/dist/index.js +8194 -7868
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.mjs +8059 -7734
  28. package/dist/index.mjs.map +1 -1
  29. package/package.json +3 -3
  30. package/src/core/types/studySession.ts +42 -0
  31. package/src/impl/common/BaseUserDB.ts +13 -4
  32. package/src/study/SessionController.ts +24 -1
  33. package/src/study/SpacedRepetition.ts +11 -2
  34. package/src/study/services/EloService.ts +97 -5
  35. package/src/study/services/ResponseProcessor.ts +79 -27
  36. package/src/study/services/tagRecent.test.ts +101 -0
  37. package/src/study/services/tagRecent.ts +70 -0
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { U as UserDBInterface, s as CourseRegistrationDoc, S as StudySessionItem, W as WeightedCard, R as ReplanHints, h as StudyContentSource, t as SessionStateSnapshotProvider, G as GeneratorResult, C as CourseDBInterface } from './contentSource-DT9NaX69.cjs';
2
- export { L as ActivityRecord, A as AdminDBInterface, w as AssignedCard, g as AssignedContent, v as AssignedCourse, u as AssignedTag, ae as CardGenerator, ag as CardGeneratorFactory, c as ClassroomDBInterface, H as ClassroomRegistration, F as ClassroomRegistrationDesignation, I as ClassroomRegistrationDoc, e as ContentNavigationStrategyData, f as ContentNavigator, q as ContentSourceID, d as CourseInfo, M as CourseRegistration, b as CoursesDBInterface, ax as DocumentUpdater, ap as FilterImpact, af as GeneratorContext, ao as GeneratorSummary, _ as HYDRATION_MARKER_ID, $ as HydrationMarker, ar as LearnableWeight, a0 as NavigatorConstructor, aa as NavigatorRole, ab as NavigatorRoles, a9 as Navigators, as as OrchestrationContext, aq as PipelineForecaster, an as PipelineRunReport, j as ScheduledCard, Q as SessionStateSnapshot, J as SessionTrackingData, a7 as StrategyContribution, i as StudentClassroomDBInterface, O as StudySessionDoc, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, n as StudySessionNewItem, o as StudySessionReviewItem, P as StudySessionRunSummary, T as TeacherClassroomDBInterface, K as UserConfig, B as UserCourseSetting, z as UserCourseSettings, y as UserDBAuthenticator, a as UserDBReader, x as UserDBWriter, Y as UserHydrationState, Z as UserHydrationStatus, N as UserOutcomeRecord, E as UsrCrsDataInterface, at as computeDeviation, av as computeEffectiveWeight, au as computeSpread, aw as createOrchestrationContext, am as drainCapturedRuns, aj as getActivePipeline, a8 as getCardOrigin, a2 as getRegisteredNavigator, a5 as getRegisteredNavigatorNames, a4 as getRegisteredNavigatorRole, al as getRunsForSession, r as getStudySource, a3 as hasRegisteredNavigator, a6 as initializeNavigatorRegistry, ad as isFilter, ac as isGenerator, p as isReview, V as makeStudySessionId, ai as mountPipelineDebugger, ay as newInterval, X as newSessionId, ah as pipelineDebugAPI, a1 as registerNavigator, ak as setDebugSessionId } from './contentSource-DT9NaX69.cjs';
3
- import { D as DataLayerProvider } from './dataLayerProvider-wY6s_4x9.cjs';
1
+ import { U as UserDBInterface, s as CourseRegistrationDoc, t as SessionEloEvent, S as StudySessionItem, W as WeightedCard, R as ReplanHints, h as StudyContentSource, u as SessionStateSnapshotProvider, G as GeneratorResult, C as CourseDBInterface } from './contentSource-CrRnbjBx.cjs';
2
+ export { M as ActivityRecord, A as AdminDBInterface, x as AssignedCard, g as AssignedContent, w as AssignedCourse, v as AssignedTag, af as CardGenerator, ah as CardGeneratorFactory, c as ClassroomDBInterface, I as ClassroomRegistration, H as ClassroomRegistrationDesignation, J as ClassroomRegistrationDoc, e as ContentNavigationStrategyData, f as ContentNavigator, q as ContentSourceID, d as CourseInfo, N as CourseRegistration, b as CoursesDBInterface, ay as DocumentUpdater, aq as FilterImpact, ag as GeneratorContext, ap as GeneratorSummary, $ as HYDRATION_MARKER_ID, a0 as HydrationMarker, as as LearnableWeight, a1 as NavigatorConstructor, ab as NavigatorRole, ac as NavigatorRoles, aa as Navigators, at as OrchestrationContext, ar as PipelineForecaster, ao as PipelineRunReport, j as ScheduledCard, V as SessionStateSnapshot, K as SessionTrackingData, a8 as StrategyContribution, i as StudentClassroomDBInterface, P as StudySessionDoc, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, n as StudySessionNewItem, o as StudySessionReviewItem, Q as StudySessionRunSummary, T as TeacherClassroomDBInterface, L as UserConfig, E as UserCourseSetting, B as UserCourseSettings, z as UserDBAuthenticator, a as UserDBReader, y as UserDBWriter, Z as UserHydrationState, _ as UserHydrationStatus, O as UserOutcomeRecord, F as UsrCrsDataInterface, au as computeDeviation, aw as computeEffectiveWeight, av as computeSpread, ax as createOrchestrationContext, an as drainCapturedRuns, ak as getActivePipeline, a9 as getCardOrigin, aB as getLapses, a3 as getRegisteredNavigator, a6 as getRegisteredNavigatorNames, a5 as getRegisteredNavigatorRole, am as getRunsForSession, aA as getStreak, r as getStudySource, a4 as hasRegisteredNavigator, a7 as initializeNavigatorRegistry, ae as isFilter, ad as isGenerator, p as isReview, X as makeStudySessionId, aj as mountPipelineDebugger, az as newInterval, Y as newSessionId, ai as pipelineDebugAPI, a2 as registerNavigator, al as setDebugSessionId } from './contentSource-CrRnbjBx.cjs';
3
+ import { D as DataLayerProvider } from './dataLayerProvider-IecbidDO.cjs';
4
4
  import { C as CardHistory, b as CardRecord, c as QuestionRecord } from './types-legacy-CrwyZIvI.cjs';
5
5
  export { d as CardData, e as CourseListData, g as DataShapeData, f as DisplayableData, D as DocType, i as DocTypePrefixes, F as Field, G as GuestUsername, Q as QualifiedCardID, h as QuestionData, S as SkuilderCourseData, a as Tag, T as TagStub, l as log } from './types-legacy-CrwyZIvI.cjs';
6
6
  import { SrsBacklogDebug, StrategyPressureDebug, Loggable } from './core/index.cjs';
@@ -27,8 +27,10 @@ declare class EloService {
27
27
  * @param userCourseRegDoc User's course registration document (will be mutated)
28
28
  * @param currentCard Current card session record
29
29
  * @param k Optional K-factor for ELO calculation
30
+ * @returns The captured before→after exchange for session logging, or null
31
+ * if no update was applied (missing registration / unreadable ELO).
30
32
  */
31
- updateUserAndCardElo(userScore: number, course_id: string, card_id: string, userCourseRegDoc: CourseRegistrationDoc, currentCard: StudySessionRecord, k?: number): Promise<void>;
33
+ updateUserAndCardElo(userScore: number, course_id: string, card_id: string, userCourseRegDoc: CourseRegistrationDoc, currentCard: StudySessionRecord, k?: number): Promise<SessionEloEvent | null>;
32
34
  /**
33
35
  * Updates both user and card ELO ratings with per-tag granularity.
34
36
  * Tags in taggedPerformance but not on card will be created dynamically.
@@ -39,7 +41,7 @@ declare class EloService {
39
41
  * @param userCourseRegDoc User's course registration document (will be mutated)
40
42
  * @param currentCard Current card session record
41
43
  */
42
- updateUserAndCardEloPerTag(taggedPerformance: TaggedPerformance, course_id: string, card_id: string, userCourseRegDoc: CourseRegistrationDoc, currentCard: StudySessionRecord): Promise<void>;
44
+ updateUserAndCardEloPerTag(taggedPerformance: TaggedPerformance, course_id: string, card_id: string, userCourseRegDoc: CourseRegistrationDoc, currentCard: StudySessionRecord): Promise<SessionEloEvent | null>;
43
45
  }
44
46
 
45
47
  /**
@@ -69,13 +71,22 @@ declare class SrsService {
69
71
  declare class ResponseProcessor {
70
72
  private srsService;
71
73
  private eloService;
72
- constructor(srsService: SrsService, eloService: EloService);
74
+ /** Sink for resolved ELO exchanges, wired to the session's in-memory log. */
75
+ private onEloEvent?;
76
+ constructor(srsService: SrsService, eloService: EloService, onEloEvent?: (event: SessionEloEvent) => void);
73
77
  /**
74
78
  * ELO updates are fired without awaiting so response handling isn't blocked
75
79
  * on DB writes — but an unhandled rejection silently drops the update.
76
80
  * This produces a catch handler that surfaces the failure in logs.
77
81
  */
78
82
  private logEloFailure;
83
+ /**
84
+ * Fire an ELO update without blocking response handling, forwarding the
85
+ * resolved exchange to the session log (if any) and surfacing failures.
86
+ * Mirrors the previous `void update(...).catch(logEloFailure)` shape, with
87
+ * the added `.then` capturing the before→after event for diagnostics.
88
+ */
89
+ private trackElo;
79
90
  /**
80
91
  * Parses performance data into global score and optional per-tag scores.
81
92
  *
@@ -679,6 +690,13 @@ declare class SessionController<TView = unknown> extends Loggable {
679
690
  private _openDocPromise;
680
691
  private _runLog;
681
692
  private static readonly MAX_LOGGED_RUNS;
693
+ /**
694
+ * Per-response ELO exchanges as they resolve (see `SessionEloEvent`). Fed by
695
+ * the ResponseProcessor's `onEloEvent` sink; flushed to the session doc at
696
+ * close. Bounded so a runaway session can't grow it without limit.
697
+ */
698
+ private _eloLog;
699
+ private static readonly MAX_LOGGED_ELO_EVENTS;
682
700
  /** Guards `endSession()` against the several termination paths racing it. */
683
701
  private _sessionClosed;
684
702
  private startTime;
@@ -830,6 +848,13 @@ declare class SessionController<TView = unknown> extends Loggable {
830
848
  * skipped, never wedging the session. Keep observers cheap and `void` any
831
849
  * long work (e.g. a triggered replan) to avoid stalling the draw.
832
850
  */
851
+ /**
852
+ * Append a resolved ELO exchange to the in-memory log. Fires async (the ELO
853
+ * update is non-blocking), so an event can land after the response that
854
+ * produced it has returned — but well before close, which is when the log is
855
+ * persisted. Bounded to avoid unbounded growth.
856
+ */
857
+ private _recordEloEvent;
833
858
  private _notifyOutcomeObservers;
834
859
  /**
835
860
  * Run a replan, bypassing requestReplan()'s coalesce logic.
@@ -1560,4 +1585,4 @@ interface CouchDbUserDoc extends PouchDB.Authentication.User {
1560
1585
  entitlements: UserEntitlements;
1561
1586
  }
1562
1587
 
1563
- export { type ActiveSessionHandle, type AggregatedDocument, type AttachmentUploadResult, CardHistory, type CardPresentation, CardRecord, type CouchDbUserDoc, CourseDBInterface, CourseLookup, CourseRegistrationDoc, type CustomQuestionsData, DEFAULT_MIGRATION_OPTIONS, type DataLayerConfig, DataLayerProvider, type DocumentCounts, ENV, type Entitlement, FileSystemAdapter, GeneratorResult, Loggable, type MigrationOptions, type MigrationResult, type MixerCardInfo, type MixerRunReport, NOT_SET, type OutcomeObserver, type ProcessedDataShape, type ProcessedQuestionData, QuestionRecord, type QueueSnapshot, QuotaRoundRobinMixer, REVIEW_TIME_FORMAT, ReplanHints, type ReplanOptions, type ResponseResult, type RestoreProgress, type SessionAction, SessionController, type SessionControls, type SessionDebugSnapshot, type SessionDebugTarget, type SessionDrawnCardDebug, type SessionOutcome, type SessionQueueDebug, type SessionQueueItemDebug, type SessionRunReport, SessionStateSnapshotProvider, type SourceBatch, type SourceMixer, type SourceSelectionBreakdown, type SourceSummary, SrsBacklogDebug, StaticCourseManifest, type StaticCourseValidation, StaticToCouchDBMigrator, StrategyPressureDebug, StudyContentSource, StudySessionItem, type StudySessionRecord, TagFilteredContentSource, type UserAccountStatus, UserDBInterface, type UserEntitlements, type ValidationIssue, type ValidationResult, WeightedCard, _resetDataLayer, captureMixerRun, clearStaleSessionDebugState, endSessionTracking, ensureAppDataDirectory, getActiveController, getAppDataDirectory, getDataLayer, getDbPath, initializeDataDirectory, initializeDataLayer, isDataShapeRegistered, isDataShapeSchemaAvailable, isQuestionTypeRegistered, makeScheduledCardId, mixerDebugAPI, mountMixerDebugger, mountSessionDebugger, processCustomQuestionsData, recordCardPresentation, registerActiveController, registerBlanksCard, registerCustomQuestionTypes, registerDataShape, registerQuestionType, registerSeedData, removeCustomQuestionTypes, removeDataShape, removeQuestionType, sessionDebugAPI, snapshotQueues, startSessionTracking, toggleSessionOverlay, validateMigration, validateStaticCourse };
1588
+ export { type ActiveSessionHandle, type AggregatedDocument, type AttachmentUploadResult, CardHistory, type CardPresentation, CardRecord, type CouchDbUserDoc, CourseDBInterface, CourseLookup, CourseRegistrationDoc, type CustomQuestionsData, DEFAULT_MIGRATION_OPTIONS, type DataLayerConfig, DataLayerProvider, type DocumentCounts, ENV, type Entitlement, FileSystemAdapter, GeneratorResult, Loggable, type MigrationOptions, type MigrationResult, type MixerCardInfo, type MixerRunReport, NOT_SET, type OutcomeObserver, type ProcessedDataShape, type ProcessedQuestionData, QuestionRecord, type QueueSnapshot, QuotaRoundRobinMixer, REVIEW_TIME_FORMAT, ReplanHints, type ReplanOptions, type ResponseResult, type RestoreProgress, type SessionAction, SessionController, type SessionControls, type SessionDebugSnapshot, type SessionDebugTarget, type SessionDrawnCardDebug, SessionEloEvent, type SessionOutcome, type SessionQueueDebug, type SessionQueueItemDebug, type SessionRunReport, SessionStateSnapshotProvider, type SourceBatch, type SourceMixer, type SourceSelectionBreakdown, type SourceSummary, SrsBacklogDebug, StaticCourseManifest, type StaticCourseValidation, StaticToCouchDBMigrator, StrategyPressureDebug, StudyContentSource, StudySessionItem, type StudySessionRecord, TagFilteredContentSource, type UserAccountStatus, UserDBInterface, type UserEntitlements, type ValidationIssue, type ValidationResult, WeightedCard, _resetDataLayer, captureMixerRun, clearStaleSessionDebugState, endSessionTracking, ensureAppDataDirectory, getActiveController, getAppDataDirectory, getDataLayer, getDbPath, initializeDataDirectory, initializeDataLayer, isDataShapeRegistered, isDataShapeSchemaAvailable, isQuestionTypeRegistered, makeScheduledCardId, mixerDebugAPI, mountMixerDebugger, mountSessionDebugger, processCustomQuestionsData, recordCardPresentation, registerActiveController, registerBlanksCard, registerCustomQuestionTypes, registerDataShape, registerQuestionType, registerSeedData, removeCustomQuestionTypes, removeDataShape, removeQuestionType, sessionDebugAPI, snapshotQueues, startSessionTracking, toggleSessionOverlay, validateMigration, validateStaticCourse };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { U as UserDBInterface, s as CourseRegistrationDoc, S as StudySessionItem, W as WeightedCard, R as ReplanHints, h as StudyContentSource, t as SessionStateSnapshotProvider, G as GeneratorResult, C as CourseDBInterface } from './contentSource-BvOpKUeU.js';
2
- export { L as ActivityRecord, A as AdminDBInterface, w as AssignedCard, g as AssignedContent, v as AssignedCourse, u as AssignedTag, ae as CardGenerator, ag as CardGeneratorFactory, c as ClassroomDBInterface, H as ClassroomRegistration, F as ClassroomRegistrationDesignation, I as ClassroomRegistrationDoc, e as ContentNavigationStrategyData, f as ContentNavigator, q as ContentSourceID, d as CourseInfo, M as CourseRegistration, b as CoursesDBInterface, ax as DocumentUpdater, ap as FilterImpact, af as GeneratorContext, ao as GeneratorSummary, _ as HYDRATION_MARKER_ID, $ as HydrationMarker, ar as LearnableWeight, a0 as NavigatorConstructor, aa as NavigatorRole, ab as NavigatorRoles, a9 as Navigators, as as OrchestrationContext, aq as PipelineForecaster, an as PipelineRunReport, j as ScheduledCard, Q as SessionStateSnapshot, J as SessionTrackingData, a7 as StrategyContribution, i as StudentClassroomDBInterface, O as StudySessionDoc, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, n as StudySessionNewItem, o as StudySessionReviewItem, P as StudySessionRunSummary, T as TeacherClassroomDBInterface, K as UserConfig, B as UserCourseSetting, z as UserCourseSettings, y as UserDBAuthenticator, a as UserDBReader, x as UserDBWriter, Y as UserHydrationState, Z as UserHydrationStatus, N as UserOutcomeRecord, E as UsrCrsDataInterface, at as computeDeviation, av as computeEffectiveWeight, au as computeSpread, aw as createOrchestrationContext, am as drainCapturedRuns, aj as getActivePipeline, a8 as getCardOrigin, a2 as getRegisteredNavigator, a5 as getRegisteredNavigatorNames, a4 as getRegisteredNavigatorRole, al as getRunsForSession, r as getStudySource, a3 as hasRegisteredNavigator, a6 as initializeNavigatorRegistry, ad as isFilter, ac as isGenerator, p as isReview, V as makeStudySessionId, ai as mountPipelineDebugger, ay as newInterval, X as newSessionId, ah as pipelineDebugAPI, a1 as registerNavigator, ak as setDebugSessionId } from './contentSource-BvOpKUeU.js';
3
- import { D as DataLayerProvider } from './dataLayerProvider-CY2B2lyW.js';
1
+ import { U as UserDBInterface, s as CourseRegistrationDoc, t as SessionEloEvent, S as StudySessionItem, W as WeightedCard, R as ReplanHints, h as StudyContentSource, u as SessionStateSnapshotProvider, G as GeneratorResult, C as CourseDBInterface } from './contentSource-kD35o65m.js';
2
+ export { M as ActivityRecord, A as AdminDBInterface, x as AssignedCard, g as AssignedContent, w as AssignedCourse, v as AssignedTag, af as CardGenerator, ah as CardGeneratorFactory, c as ClassroomDBInterface, I as ClassroomRegistration, H as ClassroomRegistrationDesignation, J as ClassroomRegistrationDoc, e as ContentNavigationStrategyData, f as ContentNavigator, q as ContentSourceID, d as CourseInfo, N as CourseRegistration, b as CoursesDBInterface, ay as DocumentUpdater, aq as FilterImpact, ag as GeneratorContext, ap as GeneratorSummary, $ as HYDRATION_MARKER_ID, a0 as HydrationMarker, as as LearnableWeight, a1 as NavigatorConstructor, ab as NavigatorRole, ac as NavigatorRoles, aa as Navigators, at as OrchestrationContext, ar as PipelineForecaster, ao as PipelineRunReport, j as ScheduledCard, V as SessionStateSnapshot, K as SessionTrackingData, a8 as StrategyContribution, i as StudentClassroomDBInterface, P as StudySessionDoc, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, n as StudySessionNewItem, o as StudySessionReviewItem, Q as StudySessionRunSummary, T as TeacherClassroomDBInterface, L as UserConfig, E as UserCourseSetting, B as UserCourseSettings, z as UserDBAuthenticator, a as UserDBReader, y as UserDBWriter, Z as UserHydrationState, _ as UserHydrationStatus, O as UserOutcomeRecord, F as UsrCrsDataInterface, au as computeDeviation, aw as computeEffectiveWeight, av as computeSpread, ax as createOrchestrationContext, an as drainCapturedRuns, ak as getActivePipeline, a9 as getCardOrigin, aB as getLapses, a3 as getRegisteredNavigator, a6 as getRegisteredNavigatorNames, a5 as getRegisteredNavigatorRole, am as getRunsForSession, aA as getStreak, r as getStudySource, a4 as hasRegisteredNavigator, a7 as initializeNavigatorRegistry, ae as isFilter, ad as isGenerator, p as isReview, X as makeStudySessionId, aj as mountPipelineDebugger, az as newInterval, Y as newSessionId, ai as pipelineDebugAPI, a2 as registerNavigator, al as setDebugSessionId } from './contentSource-kD35o65m.js';
3
+ import { D as DataLayerProvider } from './dataLayerProvider-CtzddVdy.js';
4
4
  import { C as CardHistory, b as CardRecord, c as QuestionRecord } from './types-legacy-CrwyZIvI.js';
5
5
  export { d as CardData, e as CourseListData, g as DataShapeData, f as DisplayableData, D as DocType, i as DocTypePrefixes, F as Field, G as GuestUsername, Q as QualifiedCardID, h as QuestionData, S as SkuilderCourseData, a as Tag, T as TagStub, l as log } from './types-legacy-CrwyZIvI.js';
6
6
  import { SrsBacklogDebug, StrategyPressureDebug, Loggable } from './core/index.js';
@@ -27,8 +27,10 @@ declare class EloService {
27
27
  * @param userCourseRegDoc User's course registration document (will be mutated)
28
28
  * @param currentCard Current card session record
29
29
  * @param k Optional K-factor for ELO calculation
30
+ * @returns The captured before→after exchange for session logging, or null
31
+ * if no update was applied (missing registration / unreadable ELO).
30
32
  */
31
- updateUserAndCardElo(userScore: number, course_id: string, card_id: string, userCourseRegDoc: CourseRegistrationDoc, currentCard: StudySessionRecord, k?: number): Promise<void>;
33
+ updateUserAndCardElo(userScore: number, course_id: string, card_id: string, userCourseRegDoc: CourseRegistrationDoc, currentCard: StudySessionRecord, k?: number): Promise<SessionEloEvent | null>;
32
34
  /**
33
35
  * Updates both user and card ELO ratings with per-tag granularity.
34
36
  * Tags in taggedPerformance but not on card will be created dynamically.
@@ -39,7 +41,7 @@ declare class EloService {
39
41
  * @param userCourseRegDoc User's course registration document (will be mutated)
40
42
  * @param currentCard Current card session record
41
43
  */
42
- updateUserAndCardEloPerTag(taggedPerformance: TaggedPerformance, course_id: string, card_id: string, userCourseRegDoc: CourseRegistrationDoc, currentCard: StudySessionRecord): Promise<void>;
44
+ updateUserAndCardEloPerTag(taggedPerformance: TaggedPerformance, course_id: string, card_id: string, userCourseRegDoc: CourseRegistrationDoc, currentCard: StudySessionRecord): Promise<SessionEloEvent | null>;
43
45
  }
44
46
 
45
47
  /**
@@ -69,13 +71,22 @@ declare class SrsService {
69
71
  declare class ResponseProcessor {
70
72
  private srsService;
71
73
  private eloService;
72
- constructor(srsService: SrsService, eloService: EloService);
74
+ /** Sink for resolved ELO exchanges, wired to the session's in-memory log. */
75
+ private onEloEvent?;
76
+ constructor(srsService: SrsService, eloService: EloService, onEloEvent?: (event: SessionEloEvent) => void);
73
77
  /**
74
78
  * ELO updates are fired without awaiting so response handling isn't blocked
75
79
  * on DB writes — but an unhandled rejection silently drops the update.
76
80
  * This produces a catch handler that surfaces the failure in logs.
77
81
  */
78
82
  private logEloFailure;
83
+ /**
84
+ * Fire an ELO update without blocking response handling, forwarding the
85
+ * resolved exchange to the session log (if any) and surfacing failures.
86
+ * Mirrors the previous `void update(...).catch(logEloFailure)` shape, with
87
+ * the added `.then` capturing the before→after event for diagnostics.
88
+ */
89
+ private trackElo;
79
90
  /**
80
91
  * Parses performance data into global score and optional per-tag scores.
81
92
  *
@@ -679,6 +690,13 @@ declare class SessionController<TView = unknown> extends Loggable {
679
690
  private _openDocPromise;
680
691
  private _runLog;
681
692
  private static readonly MAX_LOGGED_RUNS;
693
+ /**
694
+ * Per-response ELO exchanges as they resolve (see `SessionEloEvent`). Fed by
695
+ * the ResponseProcessor's `onEloEvent` sink; flushed to the session doc at
696
+ * close. Bounded so a runaway session can't grow it without limit.
697
+ */
698
+ private _eloLog;
699
+ private static readonly MAX_LOGGED_ELO_EVENTS;
682
700
  /** Guards `endSession()` against the several termination paths racing it. */
683
701
  private _sessionClosed;
684
702
  private startTime;
@@ -830,6 +848,13 @@ declare class SessionController<TView = unknown> extends Loggable {
830
848
  * skipped, never wedging the session. Keep observers cheap and `void` any
831
849
  * long work (e.g. a triggered replan) to avoid stalling the draw.
832
850
  */
851
+ /**
852
+ * Append a resolved ELO exchange to the in-memory log. Fires async (the ELO
853
+ * update is non-blocking), so an event can land after the response that
854
+ * produced it has returned — but well before close, which is when the log is
855
+ * persisted. Bounded to avoid unbounded growth.
856
+ */
857
+ private _recordEloEvent;
833
858
  private _notifyOutcomeObservers;
834
859
  /**
835
860
  * Run a replan, bypassing requestReplan()'s coalesce logic.
@@ -1560,4 +1585,4 @@ interface CouchDbUserDoc extends PouchDB.Authentication.User {
1560
1585
  entitlements: UserEntitlements;
1561
1586
  }
1562
1587
 
1563
- export { type ActiveSessionHandle, type AggregatedDocument, type AttachmentUploadResult, CardHistory, type CardPresentation, CardRecord, type CouchDbUserDoc, CourseDBInterface, CourseLookup, CourseRegistrationDoc, type CustomQuestionsData, DEFAULT_MIGRATION_OPTIONS, type DataLayerConfig, DataLayerProvider, type DocumentCounts, ENV, type Entitlement, FileSystemAdapter, GeneratorResult, Loggable, type MigrationOptions, type MigrationResult, type MixerCardInfo, type MixerRunReport, NOT_SET, type OutcomeObserver, type ProcessedDataShape, type ProcessedQuestionData, QuestionRecord, type QueueSnapshot, QuotaRoundRobinMixer, REVIEW_TIME_FORMAT, ReplanHints, type ReplanOptions, type ResponseResult, type RestoreProgress, type SessionAction, SessionController, type SessionControls, type SessionDebugSnapshot, type SessionDebugTarget, type SessionDrawnCardDebug, type SessionOutcome, type SessionQueueDebug, type SessionQueueItemDebug, type SessionRunReport, SessionStateSnapshotProvider, type SourceBatch, type SourceMixer, type SourceSelectionBreakdown, type SourceSummary, SrsBacklogDebug, StaticCourseManifest, type StaticCourseValidation, StaticToCouchDBMigrator, StrategyPressureDebug, StudyContentSource, StudySessionItem, type StudySessionRecord, TagFilteredContentSource, type UserAccountStatus, UserDBInterface, type UserEntitlements, type ValidationIssue, type ValidationResult, WeightedCard, _resetDataLayer, captureMixerRun, clearStaleSessionDebugState, endSessionTracking, ensureAppDataDirectory, getActiveController, getAppDataDirectory, getDataLayer, getDbPath, initializeDataDirectory, initializeDataLayer, isDataShapeRegistered, isDataShapeSchemaAvailable, isQuestionTypeRegistered, makeScheduledCardId, mixerDebugAPI, mountMixerDebugger, mountSessionDebugger, processCustomQuestionsData, recordCardPresentation, registerActiveController, registerBlanksCard, registerCustomQuestionTypes, registerDataShape, registerQuestionType, registerSeedData, removeCustomQuestionTypes, removeDataShape, removeQuestionType, sessionDebugAPI, snapshotQueues, startSessionTracking, toggleSessionOverlay, validateMigration, validateStaticCourse };
1588
+ export { type ActiveSessionHandle, type AggregatedDocument, type AttachmentUploadResult, CardHistory, type CardPresentation, CardRecord, type CouchDbUserDoc, CourseDBInterface, CourseLookup, CourseRegistrationDoc, type CustomQuestionsData, DEFAULT_MIGRATION_OPTIONS, type DataLayerConfig, DataLayerProvider, type DocumentCounts, ENV, type Entitlement, FileSystemAdapter, GeneratorResult, Loggable, type MigrationOptions, type MigrationResult, type MixerCardInfo, type MixerRunReport, NOT_SET, type OutcomeObserver, type ProcessedDataShape, type ProcessedQuestionData, QuestionRecord, type QueueSnapshot, QuotaRoundRobinMixer, REVIEW_TIME_FORMAT, ReplanHints, type ReplanOptions, type ResponseResult, type RestoreProgress, type SessionAction, SessionController, type SessionControls, type SessionDebugSnapshot, type SessionDebugTarget, type SessionDrawnCardDebug, SessionEloEvent, type SessionOutcome, type SessionQueueDebug, type SessionQueueItemDebug, type SessionRunReport, SessionStateSnapshotProvider, type SourceBatch, type SourceMixer, type SourceSelectionBreakdown, type SourceSummary, SrsBacklogDebug, StaticCourseManifest, type StaticCourseValidation, StaticToCouchDBMigrator, StrategyPressureDebug, StudyContentSource, StudySessionItem, type StudySessionRecord, TagFilteredContentSource, type UserAccountStatus, UserDBInterface, type UserEntitlements, type ValidationIssue, type ValidationResult, WeightedCard, _resetDataLayer, captureMixerRun, clearStaleSessionDebugState, endSessionTracking, ensureAppDataDirectory, getActiveController, getAppDataDirectory, getDataLayer, getDbPath, initializeDataDirectory, initializeDataLayer, isDataShapeRegistered, isDataShapeSchemaAvailable, isQuestionTypeRegistered, makeScheduledCardId, mixerDebugAPI, mountMixerDebugger, mountSessionDebugger, processCustomQuestionsData, recordCardPresentation, registerActiveController, registerBlanksCard, registerCustomQuestionTypes, registerDataShape, registerQuestionType, registerSeedData, removeCustomQuestionTypes, removeDataShape, removeQuestionType, sessionDebugAPI, snapshotQueues, startSessionTracking, toggleSessionOverlay, validateMigration, validateStaticCourse };