@vue-skuilder/db 0.2.22 → 0.2.24

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 (35) hide show
  1. package/dist/{contentSource-B1pqryv6.d.ts → contentSource-Z9lQOuu5.d.ts} +412 -79
  2. package/dist/{contentSource-CpTxVrFx.d.cts → contentSource-jBskhS2Y.d.cts} +412 -79
  3. package/dist/core/index.d.cts +84 -352
  4. package/dist/core/index.d.ts +84 -352
  5. package/dist/core/index.js.map +1 -1
  6. package/dist/core/index.mjs.map +1 -1
  7. package/dist/{dataLayerProvider-BZqH27f4.d.ts → dataLayerProvider-CvSh3KW-.d.ts} +1 -1
  8. package/dist/{dataLayerProvider-D4c7iUc_.d.cts → dataLayerProvider-DbA3d_Pd.d.cts} +1 -1
  9. package/dist/impl/couch/index.d.cts +3 -3
  10. package/dist/impl/couch/index.d.ts +3 -3
  11. package/dist/impl/couch/index.js.map +1 -1
  12. package/dist/impl/couch/index.mjs.map +1 -1
  13. package/dist/impl/static/index.d.cts +4 -4
  14. package/dist/impl/static/index.d.ts +4 -4
  15. package/dist/impl/static/index.js.map +1 -1
  16. package/dist/impl/static/index.mjs.map +1 -1
  17. package/dist/{index-rmNIwnkV.d.ts → index-BkBJlGDX.d.ts} +1 -1
  18. package/dist/{index-DGApnUZ-.d.cts → index-D7WdMDAs.d.cts} +1 -1
  19. package/dist/index.d.cts +39 -14
  20. package/dist/index.d.ts +39 -14
  21. package/dist/index.js +179 -44
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +179 -44
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/{types-r6fyuWP2.d.cts → types-DjiFOZxJ.d.cts} +1 -1
  26. package/dist/{types-legacy-BytY5eAR.d.cts → types-legacy-CrwyZIvI.d.cts} +1 -1
  27. package/dist/{types-legacy-BytY5eAR.d.ts → types-legacy-CrwyZIvI.d.ts} +1 -1
  28. package/dist/{types-B-Y3aoi5.d.ts → types-uJ2Xn3_X.d.ts} +1 -1
  29. package/dist/util/packer/index.d.cts +3 -3
  30. package/dist/util/packer/index.d.ts +3 -3
  31. package/package.json +3 -3
  32. package/src/core/types/studySession.ts +67 -0
  33. package/src/study/SessionController.ts +33 -1
  34. package/src/study/services/EloService.ts +78 -5
  35. package/src/study/services/ResponseProcessor.ts +79 -27
@@ -1,4 +1,4 @@
1
- import { P as PackerConfig, a as PackedCourseData, S as StaticCourseManifest } from './types-B-Y3aoi5.js';
1
+ import { P as PackerConfig, a as PackedCourseData, S as StaticCourseManifest } from './types-uJ2Xn3_X.js';
2
2
 
3
3
  /**
4
4
  * Abstraction for file system operations needed by the migrator.
@@ -1,4 +1,4 @@
1
- import { P as PackerConfig, a as PackedCourseData, S as StaticCourseManifest } from './types-r6fyuWP2.cjs';
1
+ import { P as PackerConfig, a as PackedCourseData, S as StaticCourseManifest } from './types-DjiFOZxJ.cjs';
2
2
 
3
3
  /**
4
4
  * Abstraction for file system operations needed by the migrator.
package/dist/index.d.cts CHANGED
@@ -1,15 +1,15 @@
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-CpTxVrFx.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, an as DocumentUpdater, af as GeneratorContext, _ as HYDRATION_MARKER_ID, $ as HydrationMarker, ah as LearnableWeight, a0 as NavigatorConstructor, aa as NavigatorRole, ab as NavigatorRoles, a9 as Navigators, ai as OrchestrationContext, 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, aj as computeDeviation, al as computeEffectiveWeight, ak as computeSpread, am as createOrchestrationContext, a8 as getCardOrigin, a2 as getRegisteredNavigator, a5 as getRegisteredNavigatorNames, a4 as getRegisteredNavigatorRole, r as getStudySource, a3 as hasRegisteredNavigator, a6 as initializeNavigatorRegistry, ad as isFilter, ac as isGenerator, p as isReview, V as makeStudySessionId, ao as newInterval, X as newSessionId, a1 as registerNavigator } from './contentSource-CpTxVrFx.cjs';
3
- import { D as DataLayerProvider } from './dataLayerProvider-D4c7iUc_.cjs';
4
- import { C as CardHistory, c as CardRecord, d as QuestionRecord } from './types-legacy-BytY5eAR.cjs';
5
- export { e as CardData, f as CourseListData, h as DataShapeData, g as DisplayableData, D as DocType, b as DocTypePrefixes, 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-BytY5eAR.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-jBskhS2Y.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, a3 as getRegisteredNavigator, a6 as getRegisteredNavigatorNames, a5 as getRegisteredNavigatorRole, am as getRunsForSession, 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-jBskhS2Y.cjs';
3
+ import { D as DataLayerProvider } from './dataLayerProvider-DbA3d_Pd.cjs';
4
+ import { C as CardHistory, b as CardRecord, c as QuestionRecord } from './types-legacy-CrwyZIvI.cjs';
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';
7
- export { BulkCardProcessorConfig, CardFilter, CardFilterFactory, DIVERSITY_FLOOR, DIVERSITY_STRENGTH, DiversityRerankOptions, FilterContext, FilterImpact, GeneratorSummary, GradientObservation, GradientResult, ImportResult, PeriodUpdateInput, PeriodUpdateResult, PipelineForecaster, PipelineRunReport, PressureGaugeDebug, SignalConfig, StrategyLearningState, StrategyStateDoc, StrategyStateId, aggregateOutcomesForGradient, areQuestionRecords, buildStrategyStateId, captureStrategyPressure, clearSrsBacklogDebug, clearStrategyPressureDebug, computeOutcomeSignal, computeStrategyGradient, diversityRerank, docIsDeleted, drainCapturedRuns, getActivePipeline, getCardHistoryID, getDefaultLearnableWeight, getRunsForSession, getSrsBacklogDebug, getStrategyPressureDebug, importParsedCards, isQuestionRecord, mountPipelineDebugger, mountUserDBDebugger, parseCardHistoryID, pipelineDebugAPI, recordUserOutcome, runPeriodUpdate, scoreAccuracyInZone, setDebugSessionId, updateLearningState, updateStrategyWeight, userDBDebugAPI, validateProcessorConfig } from './core/index.cjs';
7
+ export { BulkCardProcessorConfig, CardFilter, CardFilterFactory, DIVERSITY_FLOOR, DIVERSITY_STRENGTH, DiversityRerankOptions, FilterContext, GradientObservation, GradientResult, ImportResult, PeriodUpdateInput, PeriodUpdateResult, PressureGaugeDebug, SignalConfig, StrategyLearningState, StrategyStateDoc, StrategyStateId, aggregateOutcomesForGradient, areQuestionRecords, buildStrategyStateId, captureStrategyPressure, clearSrsBacklogDebug, clearStrategyPressureDebug, computeOutcomeSignal, computeStrategyGradient, diversityRerank, docIsDeleted, getCardHistoryID, getDefaultLearnableWeight, getSrsBacklogDebug, getStrategyPressureDebug, importParsedCards, isQuestionRecord, mountUserDBDebugger, parseCardHistoryID, recordUserOutcome, runPeriodUpdate, scoreAccuracyInZone, updateLearningState, updateStrategyWeight, userDBDebugAPI, validateProcessorConfig } from './core/index.cjs';
8
8
  import { TaggedPerformance, TagFilter, DataShape, CourseConfig } from '@vue-skuilder/common';
9
- import { S as StaticCourseManifest } from './types-r6fyuWP2.cjs';
10
- export { A as AttachmentData, C as ChunkMetadata, D as DesignDocument, I as IndexMetadata, a as PackedCourseData, P as PackerConfig } from './types-r6fyuWP2.cjs';
11
- import { F as FileSystemAdapter } from './index-DGApnUZ-.cjs';
12
- export { C as CouchDBToStaticPacker, a as FileStats, b as FileSystemError } from './index-DGApnUZ-.cjs';
9
+ import { S as StaticCourseManifest } from './types-DjiFOZxJ.cjs';
10
+ export { A as AttachmentData, C as ChunkMetadata, D as DesignDocument, I as IndexMetadata, a as PackedCourseData, P as PackerConfig } from './types-DjiFOZxJ.cjs';
11
+ import { F as FileSystemAdapter } from './index-D7WdMDAs.cjs';
12
+ export { C as CouchDBToStaticPacker, a as FileStats, b as FileSystemError } from './index-D7WdMDAs.cjs';
13
13
  import moment from 'moment';
14
14
 
15
15
  /**
@@ -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,15 +1,15 @@
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-B1pqryv6.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, an as DocumentUpdater, af as GeneratorContext, _ as HYDRATION_MARKER_ID, $ as HydrationMarker, ah as LearnableWeight, a0 as NavigatorConstructor, aa as NavigatorRole, ab as NavigatorRoles, a9 as Navigators, ai as OrchestrationContext, 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, aj as computeDeviation, al as computeEffectiveWeight, ak as computeSpread, am as createOrchestrationContext, a8 as getCardOrigin, a2 as getRegisteredNavigator, a5 as getRegisteredNavigatorNames, a4 as getRegisteredNavigatorRole, r as getStudySource, a3 as hasRegisteredNavigator, a6 as initializeNavigatorRegistry, ad as isFilter, ac as isGenerator, p as isReview, V as makeStudySessionId, ao as newInterval, X as newSessionId, a1 as registerNavigator } from './contentSource-B1pqryv6.js';
3
- import { D as DataLayerProvider } from './dataLayerProvider-BZqH27f4.js';
4
- import { C as CardHistory, c as CardRecord, d as QuestionRecord } from './types-legacy-BytY5eAR.js';
5
- export { e as CardData, f as CourseListData, h as DataShapeData, g as DisplayableData, D as DocType, b as DocTypePrefixes, 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-BytY5eAR.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-Z9lQOuu5.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, a3 as getRegisteredNavigator, a6 as getRegisteredNavigatorNames, a5 as getRegisteredNavigatorRole, am as getRunsForSession, 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-Z9lQOuu5.js';
3
+ import { D as DataLayerProvider } from './dataLayerProvider-CvSh3KW-.js';
4
+ import { C as CardHistory, b as CardRecord, c as QuestionRecord } from './types-legacy-CrwyZIvI.js';
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';
7
- export { BulkCardProcessorConfig, CardFilter, CardFilterFactory, DIVERSITY_FLOOR, DIVERSITY_STRENGTH, DiversityRerankOptions, FilterContext, FilterImpact, GeneratorSummary, GradientObservation, GradientResult, ImportResult, PeriodUpdateInput, PeriodUpdateResult, PipelineForecaster, PipelineRunReport, PressureGaugeDebug, SignalConfig, StrategyLearningState, StrategyStateDoc, StrategyStateId, aggregateOutcomesForGradient, areQuestionRecords, buildStrategyStateId, captureStrategyPressure, clearSrsBacklogDebug, clearStrategyPressureDebug, computeOutcomeSignal, computeStrategyGradient, diversityRerank, docIsDeleted, drainCapturedRuns, getActivePipeline, getCardHistoryID, getDefaultLearnableWeight, getRunsForSession, getSrsBacklogDebug, getStrategyPressureDebug, importParsedCards, isQuestionRecord, mountPipelineDebugger, mountUserDBDebugger, parseCardHistoryID, pipelineDebugAPI, recordUserOutcome, runPeriodUpdate, scoreAccuracyInZone, setDebugSessionId, updateLearningState, updateStrategyWeight, userDBDebugAPI, validateProcessorConfig } from './core/index.js';
7
+ export { BulkCardProcessorConfig, CardFilter, CardFilterFactory, DIVERSITY_FLOOR, DIVERSITY_STRENGTH, DiversityRerankOptions, FilterContext, GradientObservation, GradientResult, ImportResult, PeriodUpdateInput, PeriodUpdateResult, PressureGaugeDebug, SignalConfig, StrategyLearningState, StrategyStateDoc, StrategyStateId, aggregateOutcomesForGradient, areQuestionRecords, buildStrategyStateId, captureStrategyPressure, clearSrsBacklogDebug, clearStrategyPressureDebug, computeOutcomeSignal, computeStrategyGradient, diversityRerank, docIsDeleted, getCardHistoryID, getDefaultLearnableWeight, getSrsBacklogDebug, getStrategyPressureDebug, importParsedCards, isQuestionRecord, mountUserDBDebugger, parseCardHistoryID, recordUserOutcome, runPeriodUpdate, scoreAccuracyInZone, updateLearningState, updateStrategyWeight, userDBDebugAPI, validateProcessorConfig } from './core/index.js';
8
8
  import { TaggedPerformance, TagFilter, DataShape, CourseConfig } from '@vue-skuilder/common';
9
- import { S as StaticCourseManifest } from './types-B-Y3aoi5.js';
10
- export { A as AttachmentData, C as ChunkMetadata, D as DesignDocument, I as IndexMetadata, a as PackedCourseData, P as PackerConfig } from './types-B-Y3aoi5.js';
11
- import { F as FileSystemAdapter } from './index-rmNIwnkV.js';
12
- export { C as CouchDBToStaticPacker, a as FileStats, b as FileSystemError } from './index-rmNIwnkV.js';
9
+ import { S as StaticCourseManifest } from './types-uJ2Xn3_X.js';
10
+ export { A as AttachmentData, C as ChunkMetadata, D as DesignDocument, I as IndexMetadata, a as PackedCourseData, P as PackerConfig } from './types-uJ2Xn3_X.js';
11
+ import { F as FileSystemAdapter } from './index-BkBJlGDX.js';
12
+ export { C as CouchDBToStaticPacker, a as FileStats, b as FileSystemError } from './index-BkBJlGDX.js';
13
13
  import moment from 'moment';
14
14
 
15
15
  /**
@@ -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.js CHANGED
@@ -11529,6 +11529,8 @@ var EloService = class {
11529
11529
  * @param userCourseRegDoc User's course registration document (will be mutated)
11530
11530
  * @param currentCard Current card session record
11531
11531
  * @param k Optional K-factor for ELO calculation
11532
+ * @returns The captured before→after exchange for session logging, or null
11533
+ * if no update was applied (missing registration / unreadable ELO).
11532
11534
  */
11533
11535
  async updateUserAndCardElo(userScore, course_id, card_id, userCourseRegDoc, currentCard, k) {
11534
11536
  if (k) {
@@ -11540,13 +11542,36 @@ var EloService = class {
11540
11542
  logger.error(
11541
11543
  `[EloService] No registration for course ${course_id} on user's registration doc \u2014 skipping ELO update for card ${card_id}. (Is the user registered for this course?)`
11542
11544
  );
11543
- return;
11545
+ return null;
11544
11546
  }
11545
11547
  const userElo = (0, import_common23.toCourseElo)(courseReg.elo);
11546
11548
  const cardElo = (await courseDB.getCardEloData([currentCard.card.card_id]))[0];
11547
11549
  if (cardElo && userElo) {
11550
+ const beforeUserGlobal = userElo.global.score;
11551
+ const beforeCardGlobal = cardElo.global.score;
11552
+ const cardTagKeys = Object.keys(cardElo.tags);
11553
+ const beforeUserTag = {};
11554
+ for (const tag of cardTagKeys) {
11555
+ beforeUserTag[tag] = userElo.tags[tag]?.score ?? userElo.global.score;
11556
+ }
11548
11557
  const eloUpdate = (0, import_common23.adjustCourseScores)(userElo, cardElo, userScore);
11549
11558
  courseReg.elo = eloUpdate.userElo;
11559
+ const tags = {};
11560
+ for (const tag of cardTagKeys) {
11561
+ tags[tag] = {
11562
+ before: beforeUserTag[tag],
11563
+ after: eloUpdate.userElo.tags[tag].score,
11564
+ score: userScore
11565
+ };
11566
+ }
11567
+ const event = {
11568
+ cardId: card_id,
11569
+ at: (/* @__PURE__ */ new Date()).toISOString(),
11570
+ userScore,
11571
+ global: { before: beforeUserGlobal, after: eloUpdate.userElo.global.score },
11572
+ card: { before: beforeCardGlobal, after: eloUpdate.cardElo.global.score },
11573
+ ...cardTagKeys.length ? { tags } : {}
11574
+ };
11550
11575
  const results = await Promise.allSettled([
11551
11576
  this.user.updateUserElo(course_id, eloUpdate.userElo),
11552
11577
  courseDB.updateCardElo(card_id, eloUpdate.cardElo)
@@ -11577,7 +11602,9 @@ var EloService = class {
11577
11602
  logger.error("[EloService] Card ELO update error:", results[1].reason);
11578
11603
  }
11579
11604
  }
11605
+ return event;
11580
11606
  }
11607
+ return null;
11581
11608
  }
11582
11609
  /**
11583
11610
  * Updates both user and card ELO ratings with per-tag granularity.
@@ -11596,7 +11623,7 @@ var EloService = class {
11596
11623
  logger.error(
11597
11624
  `[EloService] No registration for course ${course_id} on user's registration doc \u2014 skipping per-tag ELO update for card ${card_id}. (Is the user registered for this course?)`
11598
11625
  );
11599
- return;
11626
+ return null;
11600
11627
  }
11601
11628
  const userElo = (0, import_common23.toCourseElo)(courseReg.elo);
11602
11629
  const [cardEloResults, cardTagsMap] = await Promise.all([
@@ -11613,8 +11640,29 @@ var EloService = class {
11613
11640
  }
11614
11641
  }
11615
11642
  if (cardElo && userElo) {
11643
+ const beforeUserGlobal = userElo.global.score;
11644
+ const beforeCardGlobal = cardElo.global.score;
11645
+ const touchedTags = Object.keys(enriched).filter((key) => key !== "_global");
11646
+ const beforeUserTag = {};
11647
+ for (const tag of touchedTags) {
11648
+ beforeUserTag[tag] = userElo.tags[tag]?.score ?? userElo.global.score;
11649
+ }
11616
11650
  const eloUpdate = (0, import_common23.adjustCourseScoresPerTag)(userElo, cardElo, enriched);
11617
11651
  courseReg.elo = eloUpdate.userElo;
11652
+ const tags = {};
11653
+ for (const tag of touchedTags) {
11654
+ const score = enriched[tag];
11655
+ const after = score === null ? beforeUserTag[tag] : eloUpdate.userElo.tags[tag]?.score ?? beforeUserTag[tag];
11656
+ tags[tag] = { before: beforeUserTag[tag], after, score };
11657
+ }
11658
+ const event = {
11659
+ cardId: card_id,
11660
+ at: (/* @__PURE__ */ new Date()).toISOString(),
11661
+ userScore: globalScore,
11662
+ global: { before: beforeUserGlobal, after: eloUpdate.userElo.global.score },
11663
+ card: { before: beforeCardGlobal, after: eloUpdate.cardElo.global.score },
11664
+ ...touchedTags.length ? { tags } : {}
11665
+ };
11618
11666
  const results = await Promise.allSettled([
11619
11667
  this.user.updateUserElo(course_id, eloUpdate.userElo),
11620
11668
  courseDB.updateCardElo(card_id, eloUpdate.cardElo)
@@ -11646,7 +11694,9 @@ var EloService = class {
11646
11694
  logger.error("[EloService] Card ELO update error:", results[1].reason);
11647
11695
  }
11648
11696
  }
11697
+ return event;
11649
11698
  }
11699
+ return null;
11650
11700
  }
11651
11701
  };
11652
11702
 
@@ -11657,9 +11707,12 @@ var import_common24 = require("@vue-skuilder/common");
11657
11707
  var ResponseProcessor = class {
11658
11708
  srsService;
11659
11709
  eloService;
11660
- constructor(srsService, eloService) {
11710
+ /** Sink for resolved ELO exchanges, wired to the session's in-memory log. */
11711
+ onEloEvent;
11712
+ constructor(srsService, eloService, onEloEvent) {
11661
11713
  this.srsService = srsService;
11662
11714
  this.eloService = eloService;
11715
+ this.onEloEvent = onEloEvent;
11663
11716
  }
11664
11717
  /**
11665
11718
  * ELO updates are fired without awaiting so response handling isn't blocked
@@ -11669,6 +11722,17 @@ var ResponseProcessor = class {
11669
11722
  logEloFailure(context, cardId) {
11670
11723
  return (e) => logger.error(`[ResponseProcessor] ELO update failed (${context}) for ${cardId}:`, e);
11671
11724
  }
11725
+ /**
11726
+ * Fire an ELO update without blocking response handling, forwarding the
11727
+ * resolved exchange to the session log (if any) and surfacing failures.
11728
+ * Mirrors the previous `void update(...).catch(logEloFailure)` shape, with
11729
+ * the added `.then` capturing the before→after event for diagnostics.
11730
+ */
11731
+ trackElo(update, context, cardId) {
11732
+ void update.then((event) => {
11733
+ if (event) this.onEloEvent?.(event);
11734
+ }).catch(this.logEloFailure(context, cardId));
11735
+ }
11672
11736
  /**
11673
11737
  * Parses performance data into global score and optional per-tag scores.
11674
11738
  *
@@ -11782,27 +11846,45 @@ var ResponseProcessor = class {
11782
11846
  logger.info(
11783
11847
  `[FirstContactElo] correct first-attempt per-tag ELO update for ${cardId} (historyLen=${history.records.length}, priorAttemps=${cardRecord.priorAttemps}): scored=[${scoredTags.join(", ")}] count-only=[${nullTags.join(", ")}]`
11784
11848
  );
11785
- void this.eloService.updateUserAndCardEloPerTag(
11786
- taggedPerformance,
11787
- courseId,
11788
- cardId,
11789
- courseRegistrationDoc,
11790
- currentCard
11791
- ).catch(this.logEloFailure("correct per-tag", cardId));
11849
+ this.trackElo(
11850
+ this.eloService.updateUserAndCardEloPerTag(
11851
+ taggedPerformance,
11852
+ courseId,
11853
+ cardId,
11854
+ courseRegistrationDoc,
11855
+ currentCard
11856
+ ),
11857
+ "correct per-tag",
11858
+ cardId
11859
+ );
11792
11860
  } else {
11793
11861
  const userScore = 0.5 + globalScore / 2;
11794
11862
  if (history.records.length === 1) {
11795
- void this.eloService.updateUserAndCardElo(userScore, courseId, cardId, courseRegistrationDoc, currentCard).catch(this.logEloFailure("correct", cardId));
11863
+ this.trackElo(
11864
+ this.eloService.updateUserAndCardElo(
11865
+ userScore,
11866
+ courseId,
11867
+ cardId,
11868
+ courseRegistrationDoc,
11869
+ currentCard
11870
+ ),
11871
+ "correct",
11872
+ cardId
11873
+ );
11796
11874
  } else {
11797
11875
  const k = Math.ceil(32 / history.records.length);
11798
- void this.eloService.updateUserAndCardElo(
11799
- userScore,
11800
- courseId,
11801
- cardId,
11802
- courseRegistrationDoc,
11803
- currentCard,
11804
- k
11805
- ).catch(this.logEloFailure("correct repeat-view", cardId));
11876
+ this.trackElo(
11877
+ this.eloService.updateUserAndCardElo(
11878
+ userScore,
11879
+ courseId,
11880
+ cardId,
11881
+ courseRegistrationDoc,
11882
+ currentCard,
11883
+ k
11884
+ ),
11885
+ "correct repeat-view",
11886
+ cardId
11887
+ );
11806
11888
  }
11807
11889
  logger.info(
11808
11890
  `[FirstContactElo] correct first-attempt ELO update (score=${userScore.toFixed(3)}) for ${cardId} (historyLen=${history.records.length}, priorAttemps=${cardRecord.priorAttemps})`
@@ -11841,25 +11923,33 @@ var ResponseProcessor = class {
11841
11923
  let eloUpdated = false;
11842
11924
  if (cardRecord.priorAttemps === 0) {
11843
11925
  if (taggedPerformance) {
11844
- void this.eloService.updateUserAndCardEloPerTag(
11845
- taggedPerformance,
11846
- courseId,
11847
- cardId,
11848
- courseRegistrationDoc,
11849
- currentCard
11850
- ).catch(this.logEloFailure("incorrect per-tag", cardId));
11926
+ this.trackElo(
11927
+ this.eloService.updateUserAndCardEloPerTag(
11928
+ taggedPerformance,
11929
+ courseId,
11930
+ cardId,
11931
+ courseRegistrationDoc,
11932
+ currentCard
11933
+ ),
11934
+ "incorrect per-tag",
11935
+ cardId
11936
+ );
11851
11937
  logger.info(
11852
11938
  `[FirstContactElo] incorrect first-attempt per-tag ELO update for ${cardId} (historyLen=${history.records.length}, priorAttemps=${cardRecord.priorAttemps}, tags=${Object.keys(taggedPerformance).length - 1})`
11853
11939
  );
11854
11940
  } else {
11855
- void this.eloService.updateUserAndCardElo(
11856
- 0,
11857
- // Failed response = 0 score
11858
- courseId,
11859
- cardId,
11860
- courseRegistrationDoc,
11861
- currentCard
11862
- ).catch(this.logEloFailure("incorrect", cardId));
11941
+ this.trackElo(
11942
+ this.eloService.updateUserAndCardElo(
11943
+ 0,
11944
+ // Failed response = 0 score
11945
+ courseId,
11946
+ cardId,
11947
+ courseRegistrationDoc,
11948
+ currentCard
11949
+ ),
11950
+ "incorrect",
11951
+ cardId
11952
+ );
11863
11953
  logger.info(
11864
11954
  `[FirstContactElo] incorrect first-attempt ELO update (score=0) for ${cardId} (historyLen=${history.records.length}, priorAttemps=${cardRecord.priorAttemps})`
11865
11955
  );
@@ -11874,15 +11964,29 @@ var ResponseProcessor = class {
11874
11964
  if (sessionViews >= maxSessionViews) {
11875
11965
  if (!eloUpdated) {
11876
11966
  if (taggedPerformance) {
11877
- void this.eloService.updateUserAndCardEloPerTag(
11878
- taggedPerformance,
11879
- courseId,
11880
- cardId,
11881
- courseRegistrationDoc,
11882
- currentCard
11883
- ).catch(this.logEloFailure("dismiss-failed per-tag", cardId));
11967
+ this.trackElo(
11968
+ this.eloService.updateUserAndCardEloPerTag(
11969
+ taggedPerformance,
11970
+ courseId,
11971
+ cardId,
11972
+ courseRegistrationDoc,
11973
+ currentCard
11974
+ ),
11975
+ "dismiss-failed per-tag",
11976
+ cardId
11977
+ );
11884
11978
  } else {
11885
- void this.eloService.updateUserAndCardElo(0, courseId, cardId, courseRegistrationDoc, currentCard).catch(this.logEloFailure("dismiss-failed", cardId));
11979
+ this.trackElo(
11980
+ this.eloService.updateUserAndCardElo(
11981
+ 0,
11982
+ courseId,
11983
+ cardId,
11984
+ courseRegistrationDoc,
11985
+ currentCard
11986
+ ),
11987
+ "dismiss-failed",
11988
+ cardId
11989
+ );
11886
11990
  }
11887
11991
  logger.info(
11888
11992
  `[FirstContactElo] dismiss-failed final ELO penalty for ${cardId} (historyLen=${history.records.length}, sessionViews=${sessionViews})`
@@ -14802,6 +14906,13 @@ var SessionController = class _SessionController extends Loggable {
14802
14906
  _openDocPromise = null;
14803
14907
  _runLog = [];
14804
14908
  static MAX_LOGGED_RUNS = 100;
14909
+ /**
14910
+ * Per-response ELO exchanges as they resolve (see `SessionEloEvent`). Fed by
14911
+ * the ResponseProcessor's `onEloEvent` sink; flushed to the session doc at
14912
+ * close. Bounded so a runaway session can't grow it without limit.
14913
+ */
14914
+ _eloLog = [];
14915
+ static MAX_LOGGED_ELO_EVENTS = 2e3;
14805
14916
  /** Guards `endSession()` against the several termination paths racing it. */
14806
14917
  _sessionClosed = false;
14807
14918
  startTime;
@@ -14849,7 +14960,11 @@ var SessionController = class _SessionController extends Loggable {
14849
14960
  () => this._getItemsToHydrate()
14850
14961
  );
14851
14962
  this.services = {
14852
- response: new ResponseProcessor(this.srsService, this.eloService)
14963
+ response: new ResponseProcessor(
14964
+ this.srsService,
14965
+ this.eloService,
14966
+ (event) => this._recordEloEvent(event)
14967
+ )
14853
14968
  };
14854
14969
  this.sources = sources;
14855
14970
  this.startTime = /* @__PURE__ */ new Date();
@@ -14935,7 +15050,16 @@ var SessionController = class _SessionController extends Loggable {
14935
15050
  generatedCount: run.generatedCount,
14936
15051
  finalCount: run.finalCount,
14937
15052
  reviewsSelected: run.reviewsSelected,
14938
- newSelected: run.newSelected
15053
+ newSelected: run.newSelected,
15054
+ // Compact detail projected off the full report so a persisted run is
15055
+ // self-explanatory once the in-memory ring buffer has rolled over.
15056
+ // Per-card provenance (`run.cards`) is intentionally left out — it's
15057
+ // the dominant memory cost and not worth persisting per run.
15058
+ ...typeof run.userElo === "number" ? { userElo: run.userElo } : {},
15059
+ ...run.generators ? { generators: run.generators } : {},
15060
+ ...run.filters ? { filters: run.filters } : {},
15061
+ ...run.hints ? { hints: run.hints } : {},
15062
+ ...run.discardedTail ? { discardedTail: run.discardedTail } : {}
14939
15063
  });
14940
15064
  }
14941
15065
  }
@@ -15229,6 +15353,16 @@ var SessionController = class _SessionController extends Loggable {
15229
15353
  * skipped, never wedging the session. Keep observers cheap and `void` any
15230
15354
  * long work (e.g. a triggered replan) to avoid stalling the draw.
15231
15355
  */
15356
+ /**
15357
+ * Append a resolved ELO exchange to the in-memory log. Fires async (the ELO
15358
+ * update is non-blocking), so an event can land after the response that
15359
+ * produced it has returned — but well before close, which is when the log is
15360
+ * persisted. Bounded to avoid unbounded growth.
15361
+ */
15362
+ _recordEloEvent(event) {
15363
+ if (this._eloLog.length >= _SessionController.MAX_LOGGED_ELO_EVENTS) return;
15364
+ this._eloLog.push(event);
15365
+ }
15232
15366
  async _notifyOutcomeObservers(record, currentCard, result) {
15233
15367
  if (this._outcomeObservers.length === 0) return;
15234
15368
  if (!isQuestionRecord(record)) return;
@@ -15881,6 +16015,7 @@ var SessionController = class _SessionController extends Loggable {
15881
16015
  secondsRemaining: Math.max(0, this._secondsRemaining)
15882
16016
  },
15883
16017
  runs: [...this._runLog],
16018
+ eloEvents: [...this._eloLog],
15884
16019
  finalHints: this._sessionHints,
15885
16020
  stateAtEnd: await this._captureState("end")
15886
16021
  };