@vue-skuilder/db 0.2.20 → 0.2.22

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 (49) hide show
  1. package/dist/{contentSource-BDRX_YYJ.d.ts → contentSource-B1pqryv6.d.ts} +87 -2
  2. package/dist/{contentSource-D-LQYFyx.d.cts → contentSource-CpTxVrFx.d.cts} +87 -2
  3. package/dist/core/index.d.cts +16 -6
  4. package/dist/core/index.d.ts +16 -6
  5. package/dist/core/index.js +79 -4
  6. package/dist/core/index.js.map +1 -1
  7. package/dist/core/index.mjs +74 -4
  8. package/dist/core/index.mjs.map +1 -1
  9. package/dist/{dataLayerProvider-Dpshuql4.d.ts → dataLayerProvider-BZqH27f4.d.ts} +1 -1
  10. package/dist/{dataLayerProvider-Dd2UcCif.d.cts → dataLayerProvider-D4c7iUc_.d.cts} +1 -1
  11. package/dist/impl/couch/index.d.cts +3 -3
  12. package/dist/impl/couch/index.d.ts +3 -3
  13. package/dist/impl/couch/index.js +63 -4
  14. package/dist/impl/couch/index.js.map +1 -1
  15. package/dist/impl/couch/index.mjs +63 -4
  16. package/dist/impl/couch/index.mjs.map +1 -1
  17. package/dist/impl/static/index.d.cts +4 -4
  18. package/dist/impl/static/index.d.ts +4 -4
  19. package/dist/impl/static/index.js +63 -4
  20. package/dist/impl/static/index.js.map +1 -1
  21. package/dist/impl/static/index.mjs +63 -4
  22. package/dist/impl/static/index.mjs.map +1 -1
  23. package/dist/{index-k9NFHpS1.d.cts → index-DGApnUZ-.d.cts} +1 -1
  24. package/dist/{index-BLLT5BYE.d.ts → index-rmNIwnkV.d.ts} +1 -1
  25. package/dist/index.d.cts +51 -14
  26. package/dist/index.d.ts +51 -14
  27. package/dist/index.js +231 -12
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +226 -12
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/{types-CHgpWQAY.d.ts → types-B-Y3aoi5.d.ts} +1 -1
  32. package/dist/{types-legacy-4tlwHnXo.d.cts → types-legacy-BytY5eAR.d.cts} +9 -1
  33. package/dist/{types-legacy-4tlwHnXo.d.ts → types-legacy-BytY5eAR.d.ts} +9 -1
  34. package/dist/{types-BFUa1pa3.d.cts → types-r6fyuWP2.d.cts} +1 -1
  35. package/dist/util/packer/index.d.cts +3 -3
  36. package/dist/util/packer/index.d.ts +3 -3
  37. package/package.json +3 -3
  38. package/src/core/index.ts +1 -0
  39. package/src/core/interfaces/userDB.ts +7 -0
  40. package/src/core/navigators/PipelineDebugger.ts +41 -1
  41. package/src/core/navigators/index.ts +3 -0
  42. package/src/core/types/studySession.ts +100 -0
  43. package/src/core/types/types-legacy.ts +8 -0
  44. package/src/core/types/user.ts +6 -1
  45. package/src/impl/common/BaseUserDB.ts +36 -0
  46. package/src/study/SessionController.ts +179 -2
  47. package/src/study/SessionDebugger.ts +4 -3
  48. package/src/study/SessionOverlay.ts +1 -0
  49. package/src/study/services/ResponseProcessor.ts +32 -4
@@ -1,6 +1,6 @@
1
1
  import { CourseConfig, ClassroomConfig, Status, SkuilderCourseData as SkuilderCourseData$1, CourseElo, DataShape, TagFilter } from '@vue-skuilder/common';
2
2
  import { Moment } from 'moment';
3
- import { S as SkuilderCourseData, b as DocTypePrefixes, D as DocType, Q as QualifiedCardID, T as TagStub, a as Tag, C as CardHistory, c as CardRecord } from './types-legacy-4tlwHnXo.js';
3
+ import { S as SkuilderCourseData, b as DocTypePrefixes, D as DocType, Q as QualifiedCardID, T as TagStub, a as Tag, C as CardHistory, c as CardRecord } from './types-legacy-BytY5eAR.js';
4
4
 
5
5
  /**
6
6
  * Admin functionality
@@ -310,6 +310,11 @@ interface UserConfig {
310
310
  darkMode: boolean;
311
311
  likesConfetti: boolean;
312
312
  sessionTimeLimit: number;
313
+ /**
314
+ * @deprecated Retired in favour of the _users-doc email (the single source of
315
+ * truth, written by /auth/send-verification and read by /auth/status). No
316
+ * live code writes or reads this field; it may linger on older CONFIG docs.
317
+ */
313
318
  email?: string;
314
319
  sessionTracking?: Record<string, SessionTrackingData>;
315
320
  }
@@ -418,6 +423,82 @@ interface UserOutcomeRecord {
418
423
  };
419
424
  }
420
425
 
426
+ /**
427
+ * Durable per-sitting record. Join target for `CardRecord.sessionId`.
428
+ *
429
+ * Written twice: `open` at `prepareSession()`, overwritten at termination.
430
+ */
431
+ interface StudySessionDoc {
432
+ /** `SESSION::{courseId}::{userId}::{sessionId}` */
433
+ _id: string;
434
+ _rev?: string;
435
+ docType: DocType.STUDY_SESSION;
436
+ sessionId: string;
437
+ courseId: string;
438
+ userId: string;
439
+ /** Session construction time, not first-card time. */
440
+ startTime: string;
441
+ endTime?: string;
442
+ /**
443
+ * `closed` — ran to natural termination.
444
+ * `abandoned` — host tore the study view down mid-session.
445
+ * `open` — never closed: tab closed, reload, crash. No tally or end state.
446
+ */
447
+ status: 'open' | 'closed' | 'abandoned';
448
+ plannedSeconds: number;
449
+ config: {
450
+ defaultBatchLimit: number;
451
+ sourceCount: number;
452
+ initHints?: ReplanHints | null;
453
+ };
454
+ /** Queue depths after the bootstrap run, before the first draw. */
455
+ initialQueues: {
456
+ supplyQ: number;
457
+ failedQ: number;
458
+ };
459
+ tally?: {
460
+ /** Distinct cards; a re-presented failed card counts once. */
461
+ cardsPresented: number;
462
+ /** Total responses, including repeat attempts on one card. */
463
+ responses: number;
464
+ correct: number;
465
+ incorrect: number;
466
+ failedQRemaining: number;
467
+ secondsRemaining: number;
468
+ };
469
+ /** Bootstrap run plus every replan, in execution order. */
470
+ runs?: StudySessionRunSummary[];
471
+ finalHints?: ReplanHints | null;
472
+ stateAtStart?: SessionStateSnapshot;
473
+ stateAtEnd?: SessionStateSnapshot;
474
+ }
475
+ interface StudySessionRunSummary {
476
+ /** Joins to `PipelineRunReport.runId` while that run is still in memory. */
477
+ runId: string;
478
+ at: string;
479
+ /** `'bootstrap'`, a replan's label, or `'(auto)'`. */
480
+ label: string;
481
+ mode?: string;
482
+ generatedCount: number;
483
+ finalCount: number;
484
+ reviewsSelected: number;
485
+ newSelected: number;
486
+ }
487
+ /**
488
+ * Host-defined learner state at a session boundary. Keep it thin — this is
489
+ * written on every session, and the deltas between consecutive snapshots are
490
+ * what it's read for.
491
+ */
492
+ type SessionStateSnapshot = Record<string, unknown>;
493
+ /**
494
+ * Invoked at session open and close. Errors and slow calls are absorbed by
495
+ * the controller.
496
+ */
497
+ type SessionStateSnapshotProvider = (phase: 'start' | 'end') => SessionStateSnapshot | Promise<SessionStateSnapshot>;
498
+ /** Stable across the open and close writes, unlike a timestamp-keyed id. */
499
+ declare function makeStudySessionId(courseId: string, userId: string, sessionId: string): string;
500
+ declare function newSessionId(): string;
501
+
421
502
  /**
422
503
  * User database hydration.
423
504
  *
@@ -563,6 +644,8 @@ interface UserDBReader {
563
644
  * Get user's pending reviews
564
645
  */
565
646
  getPendingReviews(courseId?: string): Promise<ScheduledCard[]>;
647
+ /** Study-session records for a course, newest session-start first. */
648
+ getStudySessions(courseId?: string): Promise<StudySessionDoc[]>;
566
649
  /**
567
650
  * Get all scheduled reviews due within the next `daysCount` days —
568
651
  * including ones not yet due. `getPendingReviews` is the `daysCount = 0`
@@ -681,6 +764,8 @@ interface UserDBWriter extends DocumentUpdater {
681
764
  * Record a user learning outcome for evolutionary orchestration.
682
765
  */
683
766
  putUserOutcome(record: UserOutcomeRecord): Promise<void>;
767
+ /** Write or overwrite a study-session record. */
768
+ putStudySession(doc: StudySessionDoc): Promise<void>;
684
769
  }
685
770
  /**
686
771
  * Authentication and account management operations
@@ -1344,4 +1429,4 @@ interface StudyContentSource {
1344
1429
  }
1345
1430
  declare function getStudySource(source: ContentSourceID, user: UserDBInterface): Promise<StudyContentSource>;
1346
1431
 
1347
- export { getRegisteredNavigatorNames as $, type AdminDBInterface as A, type UsrCrsDataInterface as B, type CourseDBInterface as C, type DataLayerResult as D, type ClassroomRegistrationDesignation as E, type ClassroomRegistration as F, type GeneratorResult as G, type ClassroomRegistrationDoc as H, type SessionTrackingData as I, type UserConfig as J, type ActivityRecord as K, type CourseRegistration as L, type UserOutcomeRecord as M, type UserHydrationState as N, type UserHydrationStatus as O, HYDRATION_MARKER_ID as P, type HydrationMarker as Q, type ReplanHints as R, type StudySessionItem as S, type TeacherClassroomDBInterface as T, type UserDBInterface as U, type NavigatorConstructor as V, type WeightedCard as W, registerNavigator as X, getRegisteredNavigator as Y, hasRegisteredNavigator as Z, getRegisteredNavigatorRole as _, type UserDBReader as a, initializeNavigatorRegistry as a0, type StrategyContribution as a1, getCardOrigin as a2, Navigators as a3, NavigatorRole as a4, NavigatorRoles as a5, isGenerator as a6, isFilter as a7, type CardGenerator as a8, type GeneratorContext as a9, type CardGeneratorFactory as aa, type LearnableWeight as ab, type OrchestrationContext as ac, computeDeviation as ad, computeSpread as ae, computeEffectiveWeight as af, createOrchestrationContext as ag, type DocumentUpdater as ah, newInterval as ai, type CoursesDBInterface as b, type ClassroomDBInterface as c, type CourseInfo as d, type ContentNavigationStrategyData as e, ContentNavigator as f, type AssignedContent as g, type StudyContentSource as h, type StudentClassroomDBInterface as i, type ScheduledCard as j, type StudySessionFailedItem as k, type StudySessionFailedNewItem as l, type StudySessionFailedReviewItem as m, type StudySessionNewItem as n, type StudySessionReviewItem as o, isReview as p, type ContentSourceID as q, getStudySource as r, type CourseRegistrationDoc as s, type AssignedTag as t, type AssignedCourse as u, type AssignedCard as v, type UserDBWriter as w, type UserDBAuthenticator as x, type UserCourseSettings as y, type UserCourseSetting as z };
1432
+ export { type HydrationMarker as $, type AdminDBInterface as A, type UserCourseSetting as B, type CourseDBInterface as C, type DataLayerResult as D, type UsrCrsDataInterface as E, type ClassroomRegistrationDesignation as F, type GeneratorResult as G, type ClassroomRegistration as H, type ClassroomRegistrationDoc as I, type SessionTrackingData as J, type UserConfig as K, type ActivityRecord as L, type CourseRegistration as M, type UserOutcomeRecord as N, type StudySessionDoc as O, type StudySessionRunSummary as P, type SessionStateSnapshot as Q, type ReplanHints as R, type StudySessionItem as S, type TeacherClassroomDBInterface as T, type UserDBInterface as U, makeStudySessionId as V, type WeightedCard as W, newSessionId as X, type UserHydrationState as Y, type UserHydrationStatus as Z, HYDRATION_MARKER_ID as _, type UserDBReader as a, type NavigatorConstructor as a0, registerNavigator as a1, getRegisteredNavigator as a2, hasRegisteredNavigator as a3, getRegisteredNavigatorRole as a4, getRegisteredNavigatorNames as a5, initializeNavigatorRegistry as a6, type StrategyContribution as a7, getCardOrigin as a8, Navigators as a9, NavigatorRole as aa, NavigatorRoles as ab, isGenerator as ac, isFilter as ad, type CardGenerator as ae, type GeneratorContext as af, type CardGeneratorFactory as ag, type LearnableWeight as ah, type OrchestrationContext as ai, computeDeviation as aj, computeSpread as ak, computeEffectiveWeight as al, createOrchestrationContext as am, type DocumentUpdater as an, newInterval as ao, type CoursesDBInterface as b, type ClassroomDBInterface as c, type CourseInfo as d, type ContentNavigationStrategyData as e, ContentNavigator as f, type AssignedContent as g, type StudyContentSource as h, type StudentClassroomDBInterface as i, type ScheduledCard as j, type StudySessionFailedItem as k, type StudySessionFailedNewItem as l, type StudySessionFailedReviewItem as m, type StudySessionNewItem as n, type StudySessionReviewItem as o, isReview as p, type ContentSourceID as q, getStudySource as r, type CourseRegistrationDoc as s, type SessionStateSnapshotProvider as t, type AssignedTag as u, type AssignedCourse as v, type AssignedCard as w, type UserDBWriter as x, type UserDBAuthenticator as y, type UserCourseSettings as z };
@@ -1,6 +1,6 @@
1
1
  import { CourseConfig, ClassroomConfig, Status, SkuilderCourseData as SkuilderCourseData$1, CourseElo, DataShape, TagFilter } from '@vue-skuilder/common';
2
2
  import { Moment } from 'moment';
3
- import { S as SkuilderCourseData, b as DocTypePrefixes, D as DocType, Q as QualifiedCardID, T as TagStub, a as Tag, C as CardHistory, c as CardRecord } from './types-legacy-4tlwHnXo.cjs';
3
+ import { S as SkuilderCourseData, b as DocTypePrefixes, D as DocType, Q as QualifiedCardID, T as TagStub, a as Tag, C as CardHistory, c as CardRecord } from './types-legacy-BytY5eAR.cjs';
4
4
 
5
5
  /**
6
6
  * Admin functionality
@@ -310,6 +310,11 @@ interface UserConfig {
310
310
  darkMode: boolean;
311
311
  likesConfetti: boolean;
312
312
  sessionTimeLimit: number;
313
+ /**
314
+ * @deprecated Retired in favour of the _users-doc email (the single source of
315
+ * truth, written by /auth/send-verification and read by /auth/status). No
316
+ * live code writes or reads this field; it may linger on older CONFIG docs.
317
+ */
313
318
  email?: string;
314
319
  sessionTracking?: Record<string, SessionTrackingData>;
315
320
  }
@@ -418,6 +423,82 @@ interface UserOutcomeRecord {
418
423
  };
419
424
  }
420
425
 
426
+ /**
427
+ * Durable per-sitting record. Join target for `CardRecord.sessionId`.
428
+ *
429
+ * Written twice: `open` at `prepareSession()`, overwritten at termination.
430
+ */
431
+ interface StudySessionDoc {
432
+ /** `SESSION::{courseId}::{userId}::{sessionId}` */
433
+ _id: string;
434
+ _rev?: string;
435
+ docType: DocType.STUDY_SESSION;
436
+ sessionId: string;
437
+ courseId: string;
438
+ userId: string;
439
+ /** Session construction time, not first-card time. */
440
+ startTime: string;
441
+ endTime?: string;
442
+ /**
443
+ * `closed` — ran to natural termination.
444
+ * `abandoned` — host tore the study view down mid-session.
445
+ * `open` — never closed: tab closed, reload, crash. No tally or end state.
446
+ */
447
+ status: 'open' | 'closed' | 'abandoned';
448
+ plannedSeconds: number;
449
+ config: {
450
+ defaultBatchLimit: number;
451
+ sourceCount: number;
452
+ initHints?: ReplanHints | null;
453
+ };
454
+ /** Queue depths after the bootstrap run, before the first draw. */
455
+ initialQueues: {
456
+ supplyQ: number;
457
+ failedQ: number;
458
+ };
459
+ tally?: {
460
+ /** Distinct cards; a re-presented failed card counts once. */
461
+ cardsPresented: number;
462
+ /** Total responses, including repeat attempts on one card. */
463
+ responses: number;
464
+ correct: number;
465
+ incorrect: number;
466
+ failedQRemaining: number;
467
+ secondsRemaining: number;
468
+ };
469
+ /** Bootstrap run plus every replan, in execution order. */
470
+ runs?: StudySessionRunSummary[];
471
+ finalHints?: ReplanHints | null;
472
+ stateAtStart?: SessionStateSnapshot;
473
+ stateAtEnd?: SessionStateSnapshot;
474
+ }
475
+ interface StudySessionRunSummary {
476
+ /** Joins to `PipelineRunReport.runId` while that run is still in memory. */
477
+ runId: string;
478
+ at: string;
479
+ /** `'bootstrap'`, a replan's label, or `'(auto)'`. */
480
+ label: string;
481
+ mode?: string;
482
+ generatedCount: number;
483
+ finalCount: number;
484
+ reviewsSelected: number;
485
+ newSelected: number;
486
+ }
487
+ /**
488
+ * Host-defined learner state at a session boundary. Keep it thin — this is
489
+ * written on every session, and the deltas between consecutive snapshots are
490
+ * what it's read for.
491
+ */
492
+ type SessionStateSnapshot = Record<string, unknown>;
493
+ /**
494
+ * Invoked at session open and close. Errors and slow calls are absorbed by
495
+ * the controller.
496
+ */
497
+ type SessionStateSnapshotProvider = (phase: 'start' | 'end') => SessionStateSnapshot | Promise<SessionStateSnapshot>;
498
+ /** Stable across the open and close writes, unlike a timestamp-keyed id. */
499
+ declare function makeStudySessionId(courseId: string, userId: string, sessionId: string): string;
500
+ declare function newSessionId(): string;
501
+
421
502
  /**
422
503
  * User database hydration.
423
504
  *
@@ -563,6 +644,8 @@ interface UserDBReader {
563
644
  * Get user's pending reviews
564
645
  */
565
646
  getPendingReviews(courseId?: string): Promise<ScheduledCard[]>;
647
+ /** Study-session records for a course, newest session-start first. */
648
+ getStudySessions(courseId?: string): Promise<StudySessionDoc[]>;
566
649
  /**
567
650
  * Get all scheduled reviews due within the next `daysCount` days —
568
651
  * including ones not yet due. `getPendingReviews` is the `daysCount = 0`
@@ -681,6 +764,8 @@ interface UserDBWriter extends DocumentUpdater {
681
764
  * Record a user learning outcome for evolutionary orchestration.
682
765
  */
683
766
  putUserOutcome(record: UserOutcomeRecord): Promise<void>;
767
+ /** Write or overwrite a study-session record. */
768
+ putStudySession(doc: StudySessionDoc): Promise<void>;
684
769
  }
685
770
  /**
686
771
  * Authentication and account management operations
@@ -1344,4 +1429,4 @@ interface StudyContentSource {
1344
1429
  }
1345
1430
  declare function getStudySource(source: ContentSourceID, user: UserDBInterface): Promise<StudyContentSource>;
1346
1431
 
1347
- export { getRegisteredNavigatorNames as $, type AdminDBInterface as A, type UsrCrsDataInterface as B, type CourseDBInterface as C, type DataLayerResult as D, type ClassroomRegistrationDesignation as E, type ClassroomRegistration as F, type GeneratorResult as G, type ClassroomRegistrationDoc as H, type SessionTrackingData as I, type UserConfig as J, type ActivityRecord as K, type CourseRegistration as L, type UserOutcomeRecord as M, type UserHydrationState as N, type UserHydrationStatus as O, HYDRATION_MARKER_ID as P, type HydrationMarker as Q, type ReplanHints as R, type StudySessionItem as S, type TeacherClassroomDBInterface as T, type UserDBInterface as U, type NavigatorConstructor as V, type WeightedCard as W, registerNavigator as X, getRegisteredNavigator as Y, hasRegisteredNavigator as Z, getRegisteredNavigatorRole as _, type UserDBReader as a, initializeNavigatorRegistry as a0, type StrategyContribution as a1, getCardOrigin as a2, Navigators as a3, NavigatorRole as a4, NavigatorRoles as a5, isGenerator as a6, isFilter as a7, type CardGenerator as a8, type GeneratorContext as a9, type CardGeneratorFactory as aa, type LearnableWeight as ab, type OrchestrationContext as ac, computeDeviation as ad, computeSpread as ae, computeEffectiveWeight as af, createOrchestrationContext as ag, type DocumentUpdater as ah, newInterval as ai, type CoursesDBInterface as b, type ClassroomDBInterface as c, type CourseInfo as d, type ContentNavigationStrategyData as e, ContentNavigator as f, type AssignedContent as g, type StudyContentSource as h, type StudentClassroomDBInterface as i, type ScheduledCard as j, type StudySessionFailedItem as k, type StudySessionFailedNewItem as l, type StudySessionFailedReviewItem as m, type StudySessionNewItem as n, type StudySessionReviewItem as o, isReview as p, type ContentSourceID as q, getStudySource as r, type CourseRegistrationDoc as s, type AssignedTag as t, type AssignedCourse as u, type AssignedCard as v, type UserDBWriter as w, type UserDBAuthenticator as x, type UserCourseSettings as y, type UserCourseSetting as z };
1432
+ export { type HydrationMarker as $, type AdminDBInterface as A, type UserCourseSetting as B, type CourseDBInterface as C, type DataLayerResult as D, type UsrCrsDataInterface as E, type ClassroomRegistrationDesignation as F, type GeneratorResult as G, type ClassroomRegistration as H, type ClassroomRegistrationDoc as I, type SessionTrackingData as J, type UserConfig as K, type ActivityRecord as L, type CourseRegistration as M, type UserOutcomeRecord as N, type StudySessionDoc as O, type StudySessionRunSummary as P, type SessionStateSnapshot as Q, type ReplanHints as R, type StudySessionItem as S, type TeacherClassroomDBInterface as T, type UserDBInterface as U, makeStudySessionId as V, type WeightedCard as W, newSessionId as X, type UserHydrationState as Y, type UserHydrationStatus as Z, HYDRATION_MARKER_ID as _, type UserDBReader as a, type NavigatorConstructor as a0, registerNavigator as a1, getRegisteredNavigator as a2, hasRegisteredNavigator as a3, getRegisteredNavigatorRole as a4, getRegisteredNavigatorNames as a5, initializeNavigatorRegistry as a6, type StrategyContribution as a7, getCardOrigin as a8, Navigators as a9, NavigatorRole as aa, NavigatorRoles as ab, isGenerator as ac, isFilter as ad, type CardGenerator as ae, type GeneratorContext as af, type CardGeneratorFactory as ag, type LearnableWeight as ah, type OrchestrationContext as ai, computeDeviation as aj, computeSpread as ak, computeEffectiveWeight as al, createOrchestrationContext as am, type DocumentUpdater as an, newInterval as ao, type CoursesDBInterface as b, type ClassroomDBInterface as c, type CourseInfo as d, type ContentNavigationStrategyData as e, ContentNavigator as f, type AssignedContent as g, type StudyContentSource as h, type StudentClassroomDBInterface as i, type ScheduledCard as j, type StudySessionFailedItem as k, type StudySessionFailedNewItem as l, type StudySessionFailedReviewItem as m, type StudySessionNewItem as n, type StudySessionReviewItem as o, isReview as p, type ContentSourceID as q, getStudySource as r, type CourseRegistrationDoc as s, type SessionStateSnapshotProvider as t, type AssignedTag as u, type AssignedCourse as v, type AssignedCard as w, type UserDBWriter as x, type UserDBAuthenticator as y, type UserCourseSettings as z };
@@ -1,8 +1,8 @@
1
- import { ab as LearnableWeight, M as UserOutcomeRecord, ac as OrchestrationContext, W as WeightedCard, U as UserDBInterface, C as CourseDBInterface, R as ReplanHints, a1 as StrategyContribution } from '../contentSource-D-LQYFyx.cjs';
2
- export { K as ActivityRecord, A as AdminDBInterface, v as AssignedCard, g as AssignedContent, u as AssignedCourse, t as AssignedTag, a8 as CardGenerator, aa as CardGeneratorFactory, c as ClassroomDBInterface, F as ClassroomRegistration, E as ClassroomRegistrationDesignation, H as ClassroomRegistrationDoc, e as ContentNavigationStrategyData, f as ContentNavigator, q as ContentSourceID, d as CourseInfo, L as CourseRegistration, s as CourseRegistrationDoc, b as CoursesDBInterface, a9 as GeneratorContext, G as GeneratorResult, P as HYDRATION_MARKER_ID, Q as HydrationMarker, V as NavigatorConstructor, a4 as NavigatorRole, a5 as NavigatorRoles, a3 as Navigators, j as ScheduledCard, I as SessionTrackingData, i as StudentClassroomDBInterface, h as StudyContentSource, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, S as StudySessionItem, n as StudySessionNewItem, o as StudySessionReviewItem, T as TeacherClassroomDBInterface, J as UserConfig, z as UserCourseSetting, y as UserCourseSettings, x as UserDBAuthenticator, a as UserDBReader, w as UserDBWriter, N as UserHydrationState, O as UserHydrationStatus, B as UsrCrsDataInterface, ad as computeDeviation, af as computeEffectiveWeight, ae as computeSpread, ag as createOrchestrationContext, a2 as getCardOrigin, Y as getRegisteredNavigator, $ as getRegisteredNavigatorNames, _ as getRegisteredNavigatorRole, r as getStudySource, Z as hasRegisteredNavigator, a0 as initializeNavigatorRegistry, a7 as isFilter, a6 as isGenerator, p as isReview, X as registerNavigator } from '../contentSource-D-LQYFyx.cjs';
3
- export { D as DataLayerProvider } from '../dataLayerProvider-Dd2UcCif.cjs';
4
- import { D as DocType, d as QuestionRecord, b as DocTypePrefixes, C as CardHistory, c as CardRecord } from '../types-legacy-4tlwHnXo.cjs';
5
- export { e as CardData, f as CourseListData, h as DataShapeData, g 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-4tlwHnXo.cjs';
1
+ import { ah as LearnableWeight, N as UserOutcomeRecord, ai as OrchestrationContext, W as WeightedCard, U as UserDBInterface, C as CourseDBInterface, R as ReplanHints, a7 as StrategyContribution } 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, s as CourseRegistrationDoc, b as CoursesDBInterface, af as GeneratorContext, G as GeneratorResult, _ as HYDRATION_MARKER_ID, $ as HydrationMarker, a0 as NavigatorConstructor, aa as NavigatorRole, ab as NavigatorRoles, a9 as Navigators, j as ScheduledCard, Q as SessionStateSnapshot, t as SessionStateSnapshotProvider, J as SessionTrackingData, i as StudentClassroomDBInterface, h as StudyContentSource, O as StudySessionDoc, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, S as StudySessionItem, 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, 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, X as newSessionId, a1 as registerNavigator } from '../contentSource-CpTxVrFx.cjs';
3
+ export { D as DataLayerProvider } from '../dataLayerProvider-D4c7iUc_.cjs';
4
+ import { D as DocType, d as QuestionRecord, b as DocTypePrefixes, C as CardHistory, c as CardRecord } from '../types-legacy-BytY5eAR.cjs';
5
+ export { e as CardData, f as CourseListData, h as DataShapeData, g 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-BytY5eAR.cjs';
6
6
  import { DataShape, ParsedCard } from '@vue-skuilder/common';
7
7
  import 'moment';
8
8
 
@@ -496,6 +496,8 @@ interface FilterImpact {
496
496
  */
497
497
  interface PipelineRunReport {
498
498
  runId: string;
499
+ /** Absent for runs fired outside a session (forecasts, editor probes). */
500
+ sessionId?: string;
499
501
  timestamp: Date;
500
502
  courseId: string;
501
503
  courseName?: string;
@@ -555,6 +557,14 @@ interface PipelineRunReport {
555
557
  note: string;
556
558
  };
557
559
  }
560
+ declare function setDebugSessionId(sessionId: string | undefined): void;
561
+ /** Take and clear the runs captured since the previous call, in execution order. */
562
+ declare function drainCapturedRuns(): PipelineRunReport[];
563
+ /**
564
+ * Runs for `sessionId`, oldest first. Bounded by {@link MAX_RUNS} — the
565
+ * complete record is `StudySessionDoc.runs`.
566
+ */
567
+ declare function getRunsForSession(sessionId: string): PipelineRunReport[];
558
568
  /**
559
569
  * Console API object exposed on window.skuilder.pipeline
560
570
  */
@@ -852,4 +862,4 @@ declare const userDBDebugAPI: {
852
862
  */
853
863
  declare function mountUserDBDebugger(): void;
854
864
 
855
- export { type BulkCardProcessorConfig, type CardFilter, type CardFilterFactory, CardHistory, CardRecord, CourseDBInterface, DIVERSITY_FLOOR, DIVERSITY_STRENGTH, type DiversityRerankOptions, DocType, DocTypePrefixes, type FilterContext, type FilterImpact, type GeneratorSummary, type GradientObservation, type GradientResult, type ImportResult, LearnableWeight, Loggable, OrchestrationContext, type PeriodUpdateInput, type PeriodUpdateResult, type PipelineForecaster, type PipelineRunReport, type PressureGaugeDebug, QuestionRecord, ReplanHints, type SignalConfig, type SrsBacklogDebug, StrategyContribution, type StrategyLearningState, type StrategyPressureDebug, type StrategyStateDoc, type StrategyStateId, UserDBInterface, UserOutcomeRecord, WeightedCard, aggregateOutcomesForGradient, areQuestionRecords, buildStrategyStateId, captureStrategyPressure, clearSrsBacklogDebug, clearStrategyPressureDebug, computeOutcomeSignal, computeStrategyGradient, diversityRerank, docIsDeleted, getActivePipeline, getCardHistoryID, getDefaultLearnableWeight, getSrsBacklogDebug, getStrategyPressureDebug, importParsedCards, isQuestionRecord, mountPipelineDebugger, mountUserDBDebugger, parseCardHistoryID, pipelineDebugAPI, recordUserOutcome, runPeriodUpdate, scoreAccuracyInZone, updateLearningState, updateStrategyWeight, userDBDebugAPI, validateProcessorConfig };
865
+ export { type BulkCardProcessorConfig, type CardFilter, type CardFilterFactory, CardHistory, CardRecord, CourseDBInterface, DIVERSITY_FLOOR, DIVERSITY_STRENGTH, type DiversityRerankOptions, DocType, DocTypePrefixes, type FilterContext, type FilterImpact, type GeneratorSummary, type GradientObservation, type GradientResult, type ImportResult, LearnableWeight, Loggable, OrchestrationContext, type PeriodUpdateInput, type PeriodUpdateResult, type PipelineForecaster, type PipelineRunReport, type PressureGaugeDebug, QuestionRecord, ReplanHints, type SignalConfig, type SrsBacklogDebug, StrategyContribution, type StrategyLearningState, type StrategyPressureDebug, type StrategyStateDoc, type StrategyStateId, UserDBInterface, UserOutcomeRecord, WeightedCard, 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 };
@@ -1,8 +1,8 @@
1
- import { ab as LearnableWeight, M as UserOutcomeRecord, ac as OrchestrationContext, W as WeightedCard, U as UserDBInterface, C as CourseDBInterface, R as ReplanHints, a1 as StrategyContribution } from '../contentSource-BDRX_YYJ.js';
2
- export { K as ActivityRecord, A as AdminDBInterface, v as AssignedCard, g as AssignedContent, u as AssignedCourse, t as AssignedTag, a8 as CardGenerator, aa as CardGeneratorFactory, c as ClassroomDBInterface, F as ClassroomRegistration, E as ClassroomRegistrationDesignation, H as ClassroomRegistrationDoc, e as ContentNavigationStrategyData, f as ContentNavigator, q as ContentSourceID, d as CourseInfo, L as CourseRegistration, s as CourseRegistrationDoc, b as CoursesDBInterface, a9 as GeneratorContext, G as GeneratorResult, P as HYDRATION_MARKER_ID, Q as HydrationMarker, V as NavigatorConstructor, a4 as NavigatorRole, a5 as NavigatorRoles, a3 as Navigators, j as ScheduledCard, I as SessionTrackingData, i as StudentClassroomDBInterface, h as StudyContentSource, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, S as StudySessionItem, n as StudySessionNewItem, o as StudySessionReviewItem, T as TeacherClassroomDBInterface, J as UserConfig, z as UserCourseSetting, y as UserCourseSettings, x as UserDBAuthenticator, a as UserDBReader, w as UserDBWriter, N as UserHydrationState, O as UserHydrationStatus, B as UsrCrsDataInterface, ad as computeDeviation, af as computeEffectiveWeight, ae as computeSpread, ag as createOrchestrationContext, a2 as getCardOrigin, Y as getRegisteredNavigator, $ as getRegisteredNavigatorNames, _ as getRegisteredNavigatorRole, r as getStudySource, Z as hasRegisteredNavigator, a0 as initializeNavigatorRegistry, a7 as isFilter, a6 as isGenerator, p as isReview, X as registerNavigator } from '../contentSource-BDRX_YYJ.js';
3
- export { D as DataLayerProvider } from '../dataLayerProvider-Dpshuql4.js';
4
- import { D as DocType, d as QuestionRecord, b as DocTypePrefixes, C as CardHistory, c as CardRecord } from '../types-legacy-4tlwHnXo.js';
5
- export { e as CardData, f as CourseListData, h as DataShapeData, g 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-4tlwHnXo.js';
1
+ import { ah as LearnableWeight, N as UserOutcomeRecord, ai as OrchestrationContext, W as WeightedCard, U as UserDBInterface, C as CourseDBInterface, R as ReplanHints, a7 as StrategyContribution } 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, s as CourseRegistrationDoc, b as CoursesDBInterface, af as GeneratorContext, G as GeneratorResult, _ as HYDRATION_MARKER_ID, $ as HydrationMarker, a0 as NavigatorConstructor, aa as NavigatorRole, ab as NavigatorRoles, a9 as Navigators, j as ScheduledCard, Q as SessionStateSnapshot, t as SessionStateSnapshotProvider, J as SessionTrackingData, i as StudentClassroomDBInterface, h as StudyContentSource, O as StudySessionDoc, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, S as StudySessionItem, 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, 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, X as newSessionId, a1 as registerNavigator } from '../contentSource-B1pqryv6.js';
3
+ export { D as DataLayerProvider } from '../dataLayerProvider-BZqH27f4.js';
4
+ import { D as DocType, d as QuestionRecord, b as DocTypePrefixes, C as CardHistory, c as CardRecord } from '../types-legacy-BytY5eAR.js';
5
+ export { e as CardData, f as CourseListData, h as DataShapeData, g 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-BytY5eAR.js';
6
6
  import { DataShape, ParsedCard } from '@vue-skuilder/common';
7
7
  import 'moment';
8
8
 
@@ -496,6 +496,8 @@ interface FilterImpact {
496
496
  */
497
497
  interface PipelineRunReport {
498
498
  runId: string;
499
+ /** Absent for runs fired outside a session (forecasts, editor probes). */
500
+ sessionId?: string;
499
501
  timestamp: Date;
500
502
  courseId: string;
501
503
  courseName?: string;
@@ -555,6 +557,14 @@ interface PipelineRunReport {
555
557
  note: string;
556
558
  };
557
559
  }
560
+ declare function setDebugSessionId(sessionId: string | undefined): void;
561
+ /** Take and clear the runs captured since the previous call, in execution order. */
562
+ declare function drainCapturedRuns(): PipelineRunReport[];
563
+ /**
564
+ * Runs for `sessionId`, oldest first. Bounded by {@link MAX_RUNS} — the
565
+ * complete record is `StudySessionDoc.runs`.
566
+ */
567
+ declare function getRunsForSession(sessionId: string): PipelineRunReport[];
558
568
  /**
559
569
  * Console API object exposed on window.skuilder.pipeline
560
570
  */
@@ -852,4 +862,4 @@ declare const userDBDebugAPI: {
852
862
  */
853
863
  declare function mountUserDBDebugger(): void;
854
864
 
855
- export { type BulkCardProcessorConfig, type CardFilter, type CardFilterFactory, CardHistory, CardRecord, CourseDBInterface, DIVERSITY_FLOOR, DIVERSITY_STRENGTH, type DiversityRerankOptions, DocType, DocTypePrefixes, type FilterContext, type FilterImpact, type GeneratorSummary, type GradientObservation, type GradientResult, type ImportResult, LearnableWeight, Loggable, OrchestrationContext, type PeriodUpdateInput, type PeriodUpdateResult, type PipelineForecaster, type PipelineRunReport, type PressureGaugeDebug, QuestionRecord, ReplanHints, type SignalConfig, type SrsBacklogDebug, StrategyContribution, type StrategyLearningState, type StrategyPressureDebug, type StrategyStateDoc, type StrategyStateId, UserDBInterface, UserOutcomeRecord, WeightedCard, aggregateOutcomesForGradient, areQuestionRecords, buildStrategyStateId, captureStrategyPressure, clearSrsBacklogDebug, clearStrategyPressureDebug, computeOutcomeSignal, computeStrategyGradient, diversityRerank, docIsDeleted, getActivePipeline, getCardHistoryID, getDefaultLearnableWeight, getSrsBacklogDebug, getStrategyPressureDebug, importParsedCards, isQuestionRecord, mountPipelineDebugger, mountUserDBDebugger, parseCardHistoryID, pipelineDebugAPI, recordUserOutcome, runPeriodUpdate, scoreAccuracyInZone, updateLearningState, updateStrategyWeight, userDBDebugAPI, validateProcessorConfig };
865
+ export { type BulkCardProcessorConfig, type CardFilter, type CardFilterFactory, CardHistory, CardRecord, CourseDBInterface, DIVERSITY_FLOOR, DIVERSITY_STRENGTH, type DiversityRerankOptions, DocType, DocTypePrefixes, type FilterContext, type FilterImpact, type GeneratorSummary, type GradientObservation, type GradientResult, type ImportResult, LearnableWeight, Loggable, OrchestrationContext, type PeriodUpdateInput, type PeriodUpdateResult, type PipelineForecaster, type PipelineRunReport, type PressureGaugeDebug, QuestionRecord, ReplanHints, type SignalConfig, type SrsBacklogDebug, StrategyContribution, type StrategyLearningState, type StrategyPressureDebug, type StrategyStateDoc, type StrategyStateId, UserDBInterface, UserOutcomeRecord, WeightedCard, 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 };
@@ -125,6 +125,7 @@ var init_types_legacy = __esm({
125
125
  DocType2["STRATEGY_STATE"] = "STRATEGY_STATE";
126
126
  DocType2["USER_OUTCOME"] = "USER_OUTCOME";
127
127
  DocType2["STRATEGY_LEARNING_STATE"] = "STRATEGY_LEARNING_STATE";
128
+ DocType2["STUDY_SESSION"] = "STUDY_SESSION";
128
129
  return DocType2;
129
130
  })(DocType || {});
130
131
  DocTypePrefixes = {
@@ -141,7 +142,8 @@ var init_types_legacy = __esm({
141
142
  ["NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */]: "NAVIGATION_STRATEGY",
142
143
  ["STRATEGY_STATE" /* STRATEGY_STATE */]: "STRATEGY_STATE",
143
144
  ["USER_OUTCOME" /* USER_OUTCOME */]: "USER_OUTCOME",
144
- ["STRATEGY_LEARNING_STATE" /* STRATEGY_LEARNING_STATE */]: "STRATEGY_LEARNING_STATE"
145
+ ["STRATEGY_LEARNING_STATE" /* STRATEGY_LEARNING_STATE */]: "STRATEGY_LEARNING_STATE",
146
+ ["STUDY_SESSION" /* STUDY_SESSION */]: "SESSION"
145
147
  };
146
148
  }
147
149
  });
@@ -817,10 +819,13 @@ __export(PipelineDebugger_exports, {
817
819
  buildRunReport: () => buildRunReport,
818
820
  captureRun: () => captureRun,
819
821
  clearRunHistory: () => clearRunHistory,
822
+ drainCapturedRuns: () => drainCapturedRuns,
820
823
  getActivePipeline: () => getActivePipeline,
824
+ getRunsForSession: () => getRunsForSession,
821
825
  mountPipelineDebugger: () => mountPipelineDebugger,
822
826
  pipelineDebugAPI: () => pipelineDebugAPI,
823
- registerPipelineForDebug: () => registerPipelineForDebug
827
+ registerPipelineForDebug: () => registerPipelineForDebug,
828
+ setDebugSessionId: () => setDebugSessionId
824
829
  });
825
830
  function registerPipelineForDebug(pipeline) {
826
831
  _activePipeline = pipeline;
@@ -828,8 +833,20 @@ function registerPipelineForDebug(pipeline) {
828
833
  function getActivePipeline() {
829
834
  return _activePipeline;
830
835
  }
836
+ function setDebugSessionId(sessionId) {
837
+ _currentSessionId = sessionId;
838
+ }
839
+ function drainCapturedRuns() {
840
+ const drained = _pendingRuns;
841
+ _pendingRuns = [];
842
+ return drained;
843
+ }
844
+ function getRunsForSession(sessionId) {
845
+ return runHistory.filter((r) => r.sessionId === sessionId).reverse();
846
+ }
831
847
  function clearRunHistory() {
832
848
  runHistory.length = 0;
849
+ _pendingRuns = [];
833
850
  }
834
851
  function getOrigin(card) {
835
852
  const firstEntry = card.provenance[0];
@@ -844,12 +861,15 @@ function captureRun(report) {
844
861
  const fullReport = {
845
862
  ...report,
846
863
  runId: `run-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
864
+ sessionId: _currentSessionId,
847
865
  timestamp: /* @__PURE__ */ new Date()
848
866
  };
849
867
  runHistory.unshift(fullReport);
850
868
  if (runHistory.length > MAX_RUNS) {
851
869
  runHistory.pop();
852
870
  }
871
+ _pendingRuns.push(fullReport);
872
+ return fullReport;
853
873
  }
854
874
  function parseCardElo(provenance) {
855
875
  const eloEntry = provenance.find((p) => p.strategy === "elo");
@@ -1177,7 +1197,7 @@ function mountPipelineDebugger() {
1177
1197
  win.skuilder = win.skuilder || {};
1178
1198
  win.skuilder.pipeline = pipelineDebugAPI;
1179
1199
  }
1180
- var _activePipeline, MAX_RUNS, runHistory, DISCARDED_KEEP_TOP, _uiContainer, _selectedRunIndex, _cardSearchQuery, pipelineDebugAPI;
1200
+ var _activePipeline, MAX_RUNS, runHistory, _currentSessionId, _pendingRuns, DISCARDED_KEEP_TOP, _uiContainer, _selectedRunIndex, _cardSearchQuery, pipelineDebugAPI;
1181
1201
  var init_PipelineDebugger = __esm({
1182
1202
  "src/core/navigators/PipelineDebugger.ts"() {
1183
1203
  "use strict";
@@ -1186,6 +1206,7 @@ var init_PipelineDebugger = __esm({
1186
1206
  _activePipeline = null;
1187
1207
  MAX_RUNS = 10;
1188
1208
  runHistory = [];
1209
+ _pendingRuns = [];
1189
1210
  DISCARDED_KEEP_TOP = 25;
1190
1211
  _uiContainer = null;
1191
1212
  _selectedRunIndex = null;
@@ -5409,11 +5430,13 @@ __export(navigators_exports, {
5409
5430
  clearSrsBacklogDebug: () => clearSrsBacklogDebug,
5410
5431
  clearStrategyPressureDebug: () => clearStrategyPressureDebug,
5411
5432
  diversityRerank: () => diversityRerank,
5433
+ drainCapturedRuns: () => drainCapturedRuns,
5412
5434
  getActivePipeline: () => getActivePipeline,
5413
5435
  getCardOrigin: () => getCardOrigin,
5414
5436
  getRegisteredNavigator: () => getRegisteredNavigator,
5415
5437
  getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
5416
5438
  getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
5439
+ getRunsForSession: () => getRunsForSession,
5417
5440
  getSrsBacklogDebug: () => getSrsBacklogDebug,
5418
5441
  getStrategyPressureDebug: () => getStrategyPressureDebug,
5419
5442
  hasRegisteredNavigator: () => hasRegisteredNavigator,
@@ -5422,7 +5445,8 @@ __export(navigators_exports, {
5422
5445
  isGenerator: () => isGenerator,
5423
5446
  mountPipelineDebugger: () => mountPipelineDebugger,
5424
5447
  pipelineDebugAPI: () => pipelineDebugAPI,
5425
- registerNavigator: () => registerNavigator
5448
+ registerNavigator: () => registerNavigator,
5449
+ setDebugSessionId: () => setDebugSessionId
5426
5450
  });
5427
5451
  function registerNavigator(implementingClass, constructor, role) {
5428
5452
  navigatorRegistry.set(implementingClass, { constructor, role });
@@ -7880,6 +7904,32 @@ Currently logged-in as ${this._username}.`
7880
7904
  };
7881
7905
  await this.localDB.put(doc);
7882
7906
  }
7907
+ /**
7908
+ * Open and close write the same `_id`, so the 409 path is the expected
7909
+ * route for the second write, not an error case.
7910
+ */
7911
+ async putStudySession(doc) {
7912
+ try {
7913
+ await this.localDB.put(doc);
7914
+ } catch (err) {
7915
+ if (err.status === 409) {
7916
+ const existing = await this.localDB.get(doc._id);
7917
+ await this.localDB.put({ ...doc, _rev: existing._rev });
7918
+ } else {
7919
+ throw err;
7920
+ }
7921
+ }
7922
+ }
7923
+ async getStudySessions(courseId) {
7924
+ const prefix = courseId ? `${DocTypePrefixes["STUDY_SESSION" /* STUDY_SESSION */]}::${courseId}::` : `${DocTypePrefixes["STUDY_SESSION" /* STUDY_SESSION */]}::`;
7925
+ const keys = getStartAndEndKeys(prefix);
7926
+ const res = await this.localDB.allDocs({
7927
+ startkey: keys.startkey,
7928
+ endkey: keys.endkey,
7929
+ include_docs: true
7930
+ });
7931
+ return res.rows.map((r) => r.doc).filter((d) => !!d).sort((a, b) => b.startTime.localeCompare(a.startTime));
7932
+ }
7883
7933
  async putUserOutcome(record) {
7884
7934
  try {
7885
7935
  await this.localDB.put(record);
@@ -8200,6 +8250,20 @@ var init_userOutcome = __esm({
8200
8250
  }
8201
8251
  });
8202
8252
 
8253
+ // src/core/types/studySession.ts
8254
+ function makeStudySessionId(courseId, userId, sessionId) {
8255
+ return `${DocTypePrefixes["STUDY_SESSION" /* STUDY_SESSION */]}::${courseId}::${userId}::${sessionId}`;
8256
+ }
8257
+ function newSessionId() {
8258
+ return `session-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
8259
+ }
8260
+ var init_studySession = __esm({
8261
+ "src/core/types/studySession.ts"() {
8262
+ "use strict";
8263
+ init_types_legacy();
8264
+ }
8265
+ });
8266
+
8203
8267
  // src/core/types/hydration.ts
8204
8268
  var HYDRATION_MARKER_ID;
8205
8269
  var init_hydration = __esm({
@@ -8708,6 +8772,7 @@ __export(core_exports, {
8708
8772
  createOrchestrationContext: () => createOrchestrationContext,
8709
8773
  diversityRerank: () => diversityRerank,
8710
8774
  docIsDeleted: () => docIsDeleted,
8775
+ drainCapturedRuns: () => drainCapturedRuns,
8711
8776
  getActivePipeline: () => getActivePipeline,
8712
8777
  getCardHistoryID: () => getCardHistoryID,
8713
8778
  getCardOrigin: () => getCardOrigin,
@@ -8715,6 +8780,7 @@ __export(core_exports, {
8715
8780
  getRegisteredNavigator: () => getRegisteredNavigator,
8716
8781
  getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
8717
8782
  getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
8783
+ getRunsForSession: () => getRunsForSession,
8718
8784
  getSrsBacklogDebug: () => getSrsBacklogDebug,
8719
8785
  getStrategyPressureDebug: () => getStrategyPressureDebug,
8720
8786
  getStudySource: () => getStudySource,
@@ -8726,14 +8792,17 @@ __export(core_exports, {
8726
8792
  isQuestionRecord: () => isQuestionRecord,
8727
8793
  isReview: () => isReview,
8728
8794
  log: () => log,
8795
+ makeStudySessionId: () => makeStudySessionId,
8729
8796
  mountPipelineDebugger: () => mountPipelineDebugger,
8730
8797
  mountUserDBDebugger: () => mountUserDBDebugger,
8798
+ newSessionId: () => newSessionId,
8731
8799
  parseCardHistoryID: () => parseCardHistoryID,
8732
8800
  pipelineDebugAPI: () => pipelineDebugAPI,
8733
8801
  recordUserOutcome: () => recordUserOutcome,
8734
8802
  registerNavigator: () => registerNavigator,
8735
8803
  runPeriodUpdate: () => runPeriodUpdate,
8736
8804
  scoreAccuracyInZone: () => scoreAccuracyInZone,
8805
+ setDebugSessionId: () => setDebugSessionId,
8737
8806
  updateLearningState: () => updateLearningState,
8738
8807
  updateStrategyWeight: () => updateStrategyWeight,
8739
8808
  userDBDebugAPI: () => userDBDebugAPI,
@@ -8747,6 +8816,7 @@ var init_core = __esm({
8747
8816
  init_user();
8748
8817
  init_strategyState();
8749
8818
  init_userOutcome();
8819
+ init_studySession();
8750
8820
  init_hydration();
8751
8821
  init_Loggable();
8752
8822
  init_util();
@@ -8784,6 +8854,7 @@ init_core();
8784
8854
  createOrchestrationContext,
8785
8855
  diversityRerank,
8786
8856
  docIsDeleted,
8857
+ drainCapturedRuns,
8787
8858
  getActivePipeline,
8788
8859
  getCardHistoryID,
8789
8860
  getCardOrigin,
@@ -8791,6 +8862,7 @@ init_core();
8791
8862
  getRegisteredNavigator,
8792
8863
  getRegisteredNavigatorNames,
8793
8864
  getRegisteredNavigatorRole,
8865
+ getRunsForSession,
8794
8866
  getSrsBacklogDebug,
8795
8867
  getStrategyPressureDebug,
8796
8868
  getStudySource,
@@ -8802,14 +8874,17 @@ init_core();
8802
8874
  isQuestionRecord,
8803
8875
  isReview,
8804
8876
  log,
8877
+ makeStudySessionId,
8805
8878
  mountPipelineDebugger,
8806
8879
  mountUserDBDebugger,
8880
+ newSessionId,
8807
8881
  parseCardHistoryID,
8808
8882
  pipelineDebugAPI,
8809
8883
  recordUserOutcome,
8810
8884
  registerNavigator,
8811
8885
  runPeriodUpdate,
8812
8886
  scoreAccuracyInZone,
8887
+ setDebugSessionId,
8813
8888
  updateLearningState,
8814
8889
  updateStrategyWeight,
8815
8890
  userDBDebugAPI,