@vue-skuilder/db 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -308,6 +308,49 @@ declare class QuotaRoundRobinMixer implements SourceMixer {
308
308
  mix(batches: SourceBatch[], limit: number): WeightedCard[];
309
309
  }
310
310
 
311
+ /** Per-queue debug view: total length, cumulative draws, and head-first cardIDs. */
312
+ interface SessionQueueDebug {
313
+ length: number;
314
+ dequeueCount: number;
315
+ /** cardIDs in queue order, head (next draw) first. */
316
+ cards: string[];
317
+ }
318
+ /**
319
+ * A card the learner has interacted with this session (one entry per card in
320
+ * the session record, regardless of which queue — if any — still holds it).
321
+ */
322
+ interface SessionDrawnCardDebug {
323
+ cardID: string;
324
+ /** Queue status at draw time: 'new' | 'review' | 'failed-new' | 'failed-review'. */
325
+ status: string;
326
+ /** Number of CardRecords logged for this card this session (≥1). */
327
+ attempts: number;
328
+ /** Latest record's correctness; null for non-question (info) records. */
329
+ correct: boolean | null;
330
+ /** Total time spent across all of this card's records, in ms. */
331
+ timeSpentMs: number;
332
+ }
333
+ /** Live snapshot of the controller, read fresh on each overlay tick. */
334
+ interface SessionDebugSnapshot {
335
+ secondsRemaining: number;
336
+ hasCardGuarantee: boolean;
337
+ minCardsGuarantee: number;
338
+ wellIndicatedRemaining: number;
339
+ /** cardID of the card currently in front of the learner, if any. */
340
+ currentCard: string | null;
341
+ /** Session-durable hints re-merged into every pipeline run this session. */
342
+ sessionHints: ReplanHints | null;
343
+ /** True while a replan is executing (in-flight). */
344
+ replanActive: boolean;
345
+ /** Reason for the in-flight replan (caller label, or '(auto)'); may be stale when idle. */
346
+ replanLabel: string | null;
347
+ reviewQ: SessionQueueDebug;
348
+ newQ: SessionQueueDebug;
349
+ failedQ: SessionQueueDebug;
350
+ /** Every card the learner has interacted with this session, draw order. */
351
+ drawnCards: SessionDrawnCardDebug[];
352
+ }
353
+
311
354
  /**
312
355
  * Options for requesting a mid-session replan.
313
356
  *
@@ -340,6 +383,21 @@ interface ReplanOptions {
340
383
  * multiply, require/exclude lists concatenate).
341
384
  */
342
385
  sessionHints?: ReplanHints;
386
+ /**
387
+ * Like `sessionHints`, but *merged* into the existing session-durable hints
388
+ * (via `mergeHints`) instead of replacing them. Use when emphasis should
389
+ * *accumulate* across replans rather than clobber — e.g. introducing a second
390
+ * concept mid-session must not wipe the first concept's boost, nor any
391
+ * `difficultyBooster`/`conceptBackoff` state on other concepts.
392
+ *
393
+ * Merge semantics (see `mergeHints`): boosts MULTIPLY, require/exclude lists
394
+ * concat-dedup. Re-emphasising the *same* tag therefore compounds — callers
395
+ * boosting a tag they may have already boosted should clamp at the call site.
396
+ *
397
+ * If both `sessionHints` and `mergeSessionHints` are supplied, the replace is
398
+ * applied first, then the merge — but they are normally mutually exclusive.
399
+ */
400
+ mergeSessionHints?: ReplanHints;
343
401
  /**
344
402
  * Maximum number of new cards to return from the pipeline.
345
403
  * Default: 20 (the standard session batch size).
@@ -482,6 +540,13 @@ declare class SessionController<TView = unknown> extends Loggable {
482
540
  * Used by nextCard() to await completion before drawing from queues.
483
541
  */
484
542
  private _replanPromise;
543
+ /**
544
+ * Reason for the replan currently executing in `_runReplan`, surfaced by the
545
+ * debug overlay's spinner. The caller's `opts.label` when present, else
546
+ * `'(auto)'`. Only meaningful while `_replanPromise` is non-null; cleared
547
+ * when the in-flight chain settles.
548
+ */
549
+ private _activeReplanLabel;
485
550
  /**
486
551
  * Number of well-indicated new cards remaining before the queue
487
552
  * degrades to poorly-indicated content. Decremented on each newQ
@@ -516,6 +581,21 @@ declare class SessionController<TView = unknown> extends Loggable {
516
581
  * recomputed per-run in `_runReplan` and would otherwise go stale.
517
582
  */
518
583
  private _sessionHints;
584
+ /**
585
+ * Card IDs that have been *served* (drawn/consumed) this session. Populated
586
+ * at the single consumption choke-point (removeItemFromQueue), so it reflects
587
+ * a draw the instant it happens — earlier than `_sessionRecord`, which only
588
+ * lands once the card is *responded to*.
589
+ *
590
+ * Used to keep already-served cards out of newQ on every (re)plan: a `new`
591
+ * card shown once must never re-enter newQ this session. This is the general
592
+ * guard against re-presentation — including the case where a replan in flight
593
+ * captured a now-drawn card (e.g. a +INF require-injected follow-up the
594
+ * depletion prefetch grabbed just before it was drawn). Reviews/failed cards
595
+ * legitimately recur and are tracked by their own queues, so this only gates
596
+ * `new`-origin candidates.
597
+ */
598
+ private _servedCardIds;
519
599
  /**
520
600
  * Consumer-supplied hooks invoked after each question response is processed.
521
601
  * Seeded from constructor options (threaded from
@@ -637,6 +717,13 @@ declare class SessionController<TView = unknown> extends Loggable {
637
717
  * e.g. an outcome observer that clamps a compounding boost).
638
718
  */
639
719
  getSessionHints(): ReplanHints | null;
720
+ /**
721
+ * Live state snapshot for the debug overlay (window.skuilder.session
722
+ * .dbgOverlay()). Reads directly from the private queues and hints, so it
723
+ * always reflects the current moment — unlike the passive SessionDebugger
724
+ * snapshots, which only capture what was explicitly pushed to them.
725
+ */
726
+ getDebugSnapshot(): SessionDebugSnapshot;
640
727
  /**
641
728
  * Merge `hints` into the durable session hints via the pipeline's
642
729
  * `mergeHints` (boosts multiply, require/exclude lists concat-dedup).
@@ -823,6 +910,17 @@ declare class SessionController<TView = unknown> extends Loggable {
823
910
  * Remove an item from its source queue after consumption by nextCard().
824
911
  */
825
912
  private removeItemFromQueue;
913
+ /**
914
+ * Remove a satisfied card ID from the durable session-hint `requireCards`
915
+ * list. Called when a card is consumed (see removeItemFromQueue). No-op if
916
+ * the card was not a durable requirement.
917
+ *
918
+ * Matches literal IDs only: a glob/pattern requirement (which may stand for
919
+ * several cards) is NOT considered satisfied by a single draw and is left in
920
+ * place — durable patterns are the caller's responsibility, one-shot `hints`
921
+ * remain the right tool for them.
922
+ */
923
+ private _clearDurableRequirement;
826
924
  /**
827
925
  * End the session and record learning outcomes.
828
926
  *
@@ -1060,6 +1158,11 @@ declare const sessionDebugAPI: {
1060
1158
  * Show current queue state.
1061
1159
  */
1062
1160
  showQueue(): void;
1161
+ /**
1162
+ * Toggle the pinned, live-updating DOM overlay for the active controller
1163
+ * (queues, session hints, timer). No-ops in non-browser hosts.
1164
+ */
1165
+ dbgOverlay(): void;
1063
1166
  /**
1064
1167
  * Show presentation history for current or past session.
1065
1168
  */
package/dist/index.d.ts CHANGED
@@ -308,6 +308,49 @@ declare class QuotaRoundRobinMixer implements SourceMixer {
308
308
  mix(batches: SourceBatch[], limit: number): WeightedCard[];
309
309
  }
310
310
 
311
+ /** Per-queue debug view: total length, cumulative draws, and head-first cardIDs. */
312
+ interface SessionQueueDebug {
313
+ length: number;
314
+ dequeueCount: number;
315
+ /** cardIDs in queue order, head (next draw) first. */
316
+ cards: string[];
317
+ }
318
+ /**
319
+ * A card the learner has interacted with this session (one entry per card in
320
+ * the session record, regardless of which queue — if any — still holds it).
321
+ */
322
+ interface SessionDrawnCardDebug {
323
+ cardID: string;
324
+ /** Queue status at draw time: 'new' | 'review' | 'failed-new' | 'failed-review'. */
325
+ status: string;
326
+ /** Number of CardRecords logged for this card this session (≥1). */
327
+ attempts: number;
328
+ /** Latest record's correctness; null for non-question (info) records. */
329
+ correct: boolean | null;
330
+ /** Total time spent across all of this card's records, in ms. */
331
+ timeSpentMs: number;
332
+ }
333
+ /** Live snapshot of the controller, read fresh on each overlay tick. */
334
+ interface SessionDebugSnapshot {
335
+ secondsRemaining: number;
336
+ hasCardGuarantee: boolean;
337
+ minCardsGuarantee: number;
338
+ wellIndicatedRemaining: number;
339
+ /** cardID of the card currently in front of the learner, if any. */
340
+ currentCard: string | null;
341
+ /** Session-durable hints re-merged into every pipeline run this session. */
342
+ sessionHints: ReplanHints | null;
343
+ /** True while a replan is executing (in-flight). */
344
+ replanActive: boolean;
345
+ /** Reason for the in-flight replan (caller label, or '(auto)'); may be stale when idle. */
346
+ replanLabel: string | null;
347
+ reviewQ: SessionQueueDebug;
348
+ newQ: SessionQueueDebug;
349
+ failedQ: SessionQueueDebug;
350
+ /** Every card the learner has interacted with this session, draw order. */
351
+ drawnCards: SessionDrawnCardDebug[];
352
+ }
353
+
311
354
  /**
312
355
  * Options for requesting a mid-session replan.
313
356
  *
@@ -340,6 +383,21 @@ interface ReplanOptions {
340
383
  * multiply, require/exclude lists concatenate).
341
384
  */
342
385
  sessionHints?: ReplanHints;
386
+ /**
387
+ * Like `sessionHints`, but *merged* into the existing session-durable hints
388
+ * (via `mergeHints`) instead of replacing them. Use when emphasis should
389
+ * *accumulate* across replans rather than clobber — e.g. introducing a second
390
+ * concept mid-session must not wipe the first concept's boost, nor any
391
+ * `difficultyBooster`/`conceptBackoff` state on other concepts.
392
+ *
393
+ * Merge semantics (see `mergeHints`): boosts MULTIPLY, require/exclude lists
394
+ * concat-dedup. Re-emphasising the *same* tag therefore compounds — callers
395
+ * boosting a tag they may have already boosted should clamp at the call site.
396
+ *
397
+ * If both `sessionHints` and `mergeSessionHints` are supplied, the replace is
398
+ * applied first, then the merge — but they are normally mutually exclusive.
399
+ */
400
+ mergeSessionHints?: ReplanHints;
343
401
  /**
344
402
  * Maximum number of new cards to return from the pipeline.
345
403
  * Default: 20 (the standard session batch size).
@@ -482,6 +540,13 @@ declare class SessionController<TView = unknown> extends Loggable {
482
540
  * Used by nextCard() to await completion before drawing from queues.
483
541
  */
484
542
  private _replanPromise;
543
+ /**
544
+ * Reason for the replan currently executing in `_runReplan`, surfaced by the
545
+ * debug overlay's spinner. The caller's `opts.label` when present, else
546
+ * `'(auto)'`. Only meaningful while `_replanPromise` is non-null; cleared
547
+ * when the in-flight chain settles.
548
+ */
549
+ private _activeReplanLabel;
485
550
  /**
486
551
  * Number of well-indicated new cards remaining before the queue
487
552
  * degrades to poorly-indicated content. Decremented on each newQ
@@ -516,6 +581,21 @@ declare class SessionController<TView = unknown> extends Loggable {
516
581
  * recomputed per-run in `_runReplan` and would otherwise go stale.
517
582
  */
518
583
  private _sessionHints;
584
+ /**
585
+ * Card IDs that have been *served* (drawn/consumed) this session. Populated
586
+ * at the single consumption choke-point (removeItemFromQueue), so it reflects
587
+ * a draw the instant it happens — earlier than `_sessionRecord`, which only
588
+ * lands once the card is *responded to*.
589
+ *
590
+ * Used to keep already-served cards out of newQ on every (re)plan: a `new`
591
+ * card shown once must never re-enter newQ this session. This is the general
592
+ * guard against re-presentation — including the case where a replan in flight
593
+ * captured a now-drawn card (e.g. a +INF require-injected follow-up the
594
+ * depletion prefetch grabbed just before it was drawn). Reviews/failed cards
595
+ * legitimately recur and are tracked by their own queues, so this only gates
596
+ * `new`-origin candidates.
597
+ */
598
+ private _servedCardIds;
519
599
  /**
520
600
  * Consumer-supplied hooks invoked after each question response is processed.
521
601
  * Seeded from constructor options (threaded from
@@ -637,6 +717,13 @@ declare class SessionController<TView = unknown> extends Loggable {
637
717
  * e.g. an outcome observer that clamps a compounding boost).
638
718
  */
639
719
  getSessionHints(): ReplanHints | null;
720
+ /**
721
+ * Live state snapshot for the debug overlay (window.skuilder.session
722
+ * .dbgOverlay()). Reads directly from the private queues and hints, so it
723
+ * always reflects the current moment — unlike the passive SessionDebugger
724
+ * snapshots, which only capture what was explicitly pushed to them.
725
+ */
726
+ getDebugSnapshot(): SessionDebugSnapshot;
640
727
  /**
641
728
  * Merge `hints` into the durable session hints via the pipeline's
642
729
  * `mergeHints` (boosts multiply, require/exclude lists concat-dedup).
@@ -823,6 +910,17 @@ declare class SessionController<TView = unknown> extends Loggable {
823
910
  * Remove an item from its source queue after consumption by nextCard().
824
911
  */
825
912
  private removeItemFromQueue;
913
+ /**
914
+ * Remove a satisfied card ID from the durable session-hint `requireCards`
915
+ * list. Called when a card is consumed (see removeItemFromQueue). No-op if
916
+ * the card was not a durable requirement.
917
+ *
918
+ * Matches literal IDs only: a glob/pattern requirement (which may stand for
919
+ * several cards) is NOT considered satisfied by a single draw and is left in
920
+ * place — durable patterns are the caller's responsibility, one-shot `hints`
921
+ * remain the right tool for them.
922
+ */
923
+ private _clearDurableRequirement;
826
924
  /**
827
925
  * End the session and record learning outcomes.
828
926
  *
@@ -1060,6 +1158,11 @@ declare const sessionDebugAPI: {
1060
1158
  * Show current queue state.
1061
1159
  */
1062
1160
  showQueue(): void;
1161
+ /**
1162
+ * Toggle the pinned, live-updating DOM overlay for the active controller
1163
+ * (queues, session hints, timer). No-ops in non-browser hosts.
1164
+ */
1165
+ dbgOverlay(): void;
1063
1166
  /**
1064
1167
  * Show presentation history for current or past session.
1065
1168
  */