@vue-skuilder/db 0.2.30 → 0.2.32

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 (51) hide show
  1. package/dist/{contentSource-B6FrSihy.d.cts → contentSource-CTQ4kWhR.d.cts} +41 -4
  2. package/dist/{contentSource-CqJmbOZN.d.ts → contentSource-JmWYu8IK.d.ts} +41 -4
  3. package/dist/core/index.d.cts +3 -3
  4. package/dist/core/index.d.ts +3 -3
  5. package/dist/core/index.js +138 -79
  6. package/dist/core/index.js.map +1 -1
  7. package/dist/core/index.mjs +90 -30
  8. package/dist/core/index.mjs.map +1 -1
  9. package/dist/{dataLayerProvider-DUxDqMtZ.d.cts → dataLayerProvider-DfI_KYAe.d.cts} +1 -1
  10. package/dist/{dataLayerProvider-B9_UCvkR.d.ts → dataLayerProvider-rlLE2Mf-.d.ts} +1 -1
  11. package/dist/diagnostics/index.d.cts +18 -3
  12. package/dist/diagnostics/index.d.ts +18 -3
  13. package/dist/diagnostics/index.js +171 -135
  14. package/dist/diagnostics/index.js.map +1 -1
  15. package/dist/diagnostics/index.mjs +168 -135
  16. package/dist/diagnostics/index.mjs.map +1 -1
  17. package/dist/impl/couch/index.d.cts +8 -2
  18. package/dist/impl/couch/index.d.ts +8 -2
  19. package/dist/impl/couch/index.js +142 -83
  20. package/dist/impl/couch/index.js.map +1 -1
  21. package/dist/impl/couch/index.mjs +90 -30
  22. package/dist/impl/couch/index.mjs.map +1 -1
  23. package/dist/impl/static/index.d.cts +2 -2
  24. package/dist/impl/static/index.d.ts +2 -2
  25. package/dist/impl/static/index.js +129 -70
  26. package/dist/impl/static/index.js.map +1 -1
  27. package/dist/impl/static/index.mjs +90 -30
  28. package/dist/impl/static/index.mjs.map +1 -1
  29. package/dist/index.d.cts +5 -3
  30. package/dist/index.d.ts +5 -3
  31. package/dist/index.js +204 -114
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.mjs +128 -37
  34. package/dist/index.mjs.map +1 -1
  35. package/package.json +3 -3
  36. package/src/core/navigators/Pipeline.ts +13 -2
  37. package/src/core/navigators/PipelineAssembler.ts +2 -0
  38. package/src/core/navigators/PipelineDebugger.ts +54 -23
  39. package/src/core/navigators/defaults.ts +4 -1
  40. package/src/core/navigators/filters/eloDistance.ts +7 -8
  41. package/src/core/navigators/generators/elo.ts +8 -2
  42. package/src/core/navigators/generators/prescribed.ts +7 -5
  43. package/src/core/types/studySession.ts +23 -2
  44. package/src/core/versionStamps.ts +66 -0
  45. package/src/diagnostics/derive.ts +5 -2
  46. package/src/diagnostics/pipeline.ts +28 -0
  47. package/src/diagnostics/text.ts +24 -4
  48. package/src/factory.ts +6 -0
  49. package/src/study/SessionController.ts +6 -1
  50. package/src/study/services/EloService.ts +33 -6
  51. package/tsup.config.ts +5 -0
@@ -1,4 +1,4 @@
1
- import { U as UserDBInterface, C as CourseDBInterface, a as CoursesDBInterface } from './contentSource-B6FrSihy.cjs';
1
+ import { U as UserDBInterface, C as CourseDBInterface, a as CoursesDBInterface } from './contentSource-CTQ4kWhR.cjs';
2
2
  import { C as ClassroomDBInterface, A as AdminDBInterface } from './classroomDB-DLTtLZct.cjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { U as UserDBInterface, C as CourseDBInterface, a as CoursesDBInterface } from './contentSource-CqJmbOZN.js';
1
+ import { U as UserDBInterface, C as CourseDBInterface, a as CoursesDBInterface } from './contentSource-JmWYu8IK.js';
2
2
  import { C as ClassroomDBInterface, A as AdminDBInterface } from './classroomDB-DLTtLZct.js';
3
3
 
4
4
  /**
@@ -1,6 +1,6 @@
1
1
  import { C as CardData, a as DisplayableData, T as Tag, b as CardRecord, Q as QuestionRecord, c as CardHistory } from '../types-legacy-BkOYOR6U.cjs';
2
- import { b as ContentNavigationStrategyData, S as StudySessionDoc, c as ScheduledCard, d as CourseRegistrationDoc, e as SessionStateSnapshot, f as StudySessionRunSummary, R as RegulatorReading, F as FilterKind, g as RegulatorName } from '../contentSource-B6FrSihy.cjs';
3
- export { h as SessionEloEvent, i as StudySessionRunCard, j as StudySessionRunCardTrail } from '../contentSource-B6FrSihy.cjs';
2
+ import { b as ContentNavigationStrategyData, S as StudySessionDoc, c as ScheduledCard, d as CourseRegistrationDoc, e as SessionStateSnapshot, f as StudySessionRunSummary, R as RegulatorReading, g as StudySessionRunCard, F as FilterKind, h as RegulatorName } from '../contentSource-CTQ4kWhR.cjs';
3
+ export { i as SessionEloEvent, j as StudySessionRunCardTrail } from '../contentSource-CTQ4kWhR.cjs';
4
4
  import '@vue-skuilder/common';
5
5
  import 'moment';
6
6
 
@@ -362,6 +362,8 @@ declare function fmtDelta(d: number | null): string;
362
362
  /** 45s, 3m20s, 1.5h. */
363
363
  declare function fmtDuration(seconds: number): string;
364
364
  declare function fmtAnswer(a: unknown, max?: number): string;
365
+ /** Two decimals, or one significant figure when tiny; `∞` for a required card's score (persisted as null). */
366
+ declare function fmtScore(n: number | null): string;
365
367
  /** One regulator reading as a line: its urgency, inputs, and multiplier. */
366
368
  declare function regulatorText(r: RegulatorReading): string;
367
369
  /** One run as a compact text block. */
@@ -377,6 +379,19 @@ declare function sessionText(username: string, detail: SessionDetail, extras?: {
377
379
  eloLedger?: EloLedger | null;
378
380
  }, interp?: DiagnosticsInterpreters): string;
379
381
 
382
+ /**
383
+ * What put a run's card in the queue: the hint that required it, else the
384
+ * generator that produced it. Its `origin` says what it is (review or new).
385
+ */
386
+ declare function runCardSource(card: Pick<StudySessionRunCard, 'generator' | 'required'>): string;
387
+ /**
388
+ * A run's selected cards counted by source, most first. Empty for runs that
389
+ * don't persist their cards (before 0.2.28).
390
+ */
391
+ declare function selectedBySource(run: Pick<StudySessionRunSummary, 'cards'>): Array<{
392
+ source: string;
393
+ count: number;
394
+ }>;
380
395
  /** One generator across persisted runs. */
381
396
  interface GeneratorRunStat {
382
397
  /** The name runs report it under (its strategy doc's name). */
@@ -440,4 +455,4 @@ declare function pipelineRunStats(ds: LearnerDataset, opts?: {
440
455
  since?: string;
441
456
  }): PipelineRunStats;
442
457
 
443
- export { type CardDossier, type CardSummary, type CouchAuth, type CourseSlice, type DatasetCardHistory, type DatasetRecord, type DiagnosticsInterpreters, type EloLedger, type FetchLearnerDumpOptions, FilterKind, type FilterRunStat, type GeneratorRunStat, type LearnerDataset, type LearnerDump, type PipelineRunStats, RegulatorName, RegulatorReading, type RegulatorRunStat, type ResponseEloDelta, SESSION_FLAGS, SESSION_FLAG_THRESHOLDS, type ServedTagStat, type SessionDetail, type SessionFlag, type SessionStateRow, SessionStateSnapshot, type SessionSummary, StudySessionDoc, StudySessionRunSummary, type TimelineEntry, type TimelineResponse, type TimelineRun, cardDossiers, dumpFileName, eloLedger, fetchLearnerDump, fmtAnswer, fmtDelta, fmtDuration, fromDump, isSkillTag, parseLearnerDump, pipelineRunStats, recordPerformance, regulatorText, runText, scoredTagDeltas, servedTags, sessionDetail, sessionText, shortTag, summarizeSession, summarizeSessions, toIsoTimestamp, userDbName };
458
+ export { type CardDossier, type CardSummary, type CouchAuth, type CourseSlice, type DatasetCardHistory, type DatasetRecord, type DiagnosticsInterpreters, type EloLedger, type FetchLearnerDumpOptions, FilterKind, type FilterRunStat, type GeneratorRunStat, type LearnerDataset, type LearnerDump, type PipelineRunStats, RegulatorName, RegulatorReading, type RegulatorRunStat, type ResponseEloDelta, SESSION_FLAGS, SESSION_FLAG_THRESHOLDS, type ServedTagStat, type SessionDetail, type SessionFlag, type SessionStateRow, SessionStateSnapshot, type SessionSummary, StudySessionDoc, StudySessionRunCard, StudySessionRunSummary, type TimelineEntry, type TimelineResponse, type TimelineRun, cardDossiers, dumpFileName, eloLedger, fetchLearnerDump, fmtAnswer, fmtDelta, fmtDuration, fmtScore, fromDump, isSkillTag, parseLearnerDump, pipelineRunStats, recordPerformance, regulatorText, runCardSource, runText, scoredTagDeltas, selectedBySource, servedTags, sessionDetail, sessionText, shortTag, summarizeSession, summarizeSessions, toIsoTimestamp, userDbName };
@@ -1,6 +1,6 @@
1
1
  import { C as CardData, a as DisplayableData, T as Tag, b as CardRecord, Q as QuestionRecord, c as CardHistory } from '../types-legacy-BkOYOR6U.js';
2
- import { b as ContentNavigationStrategyData, S as StudySessionDoc, c as ScheduledCard, d as CourseRegistrationDoc, e as SessionStateSnapshot, f as StudySessionRunSummary, R as RegulatorReading, F as FilterKind, g as RegulatorName } from '../contentSource-CqJmbOZN.js';
3
- export { h as SessionEloEvent, i as StudySessionRunCard, j as StudySessionRunCardTrail } from '../contentSource-CqJmbOZN.js';
2
+ import { b as ContentNavigationStrategyData, S as StudySessionDoc, c as ScheduledCard, d as CourseRegistrationDoc, e as SessionStateSnapshot, f as StudySessionRunSummary, R as RegulatorReading, g as StudySessionRunCard, F as FilterKind, h as RegulatorName } from '../contentSource-JmWYu8IK.js';
3
+ export { i as SessionEloEvent, j as StudySessionRunCardTrail } from '../contentSource-JmWYu8IK.js';
4
4
  import '@vue-skuilder/common';
5
5
  import 'moment';
6
6
 
@@ -362,6 +362,8 @@ declare function fmtDelta(d: number | null): string;
362
362
  /** 45s, 3m20s, 1.5h. */
363
363
  declare function fmtDuration(seconds: number): string;
364
364
  declare function fmtAnswer(a: unknown, max?: number): string;
365
+ /** Two decimals, or one significant figure when tiny; `∞` for a required card's score (persisted as null). */
366
+ declare function fmtScore(n: number | null): string;
365
367
  /** One regulator reading as a line: its urgency, inputs, and multiplier. */
366
368
  declare function regulatorText(r: RegulatorReading): string;
367
369
  /** One run as a compact text block. */
@@ -377,6 +379,19 @@ declare function sessionText(username: string, detail: SessionDetail, extras?: {
377
379
  eloLedger?: EloLedger | null;
378
380
  }, interp?: DiagnosticsInterpreters): string;
379
381
 
382
+ /**
383
+ * What put a run's card in the queue: the hint that required it, else the
384
+ * generator that produced it. Its `origin` says what it is (review or new).
385
+ */
386
+ declare function runCardSource(card: Pick<StudySessionRunCard, 'generator' | 'required'>): string;
387
+ /**
388
+ * A run's selected cards counted by source, most first. Empty for runs that
389
+ * don't persist their cards (before 0.2.28).
390
+ */
391
+ declare function selectedBySource(run: Pick<StudySessionRunSummary, 'cards'>): Array<{
392
+ source: string;
393
+ count: number;
394
+ }>;
380
395
  /** One generator across persisted runs. */
381
396
  interface GeneratorRunStat {
382
397
  /** The name runs report it under (its strategy doc's name). */
@@ -440,4 +455,4 @@ declare function pipelineRunStats(ds: LearnerDataset, opts?: {
440
455
  since?: string;
441
456
  }): PipelineRunStats;
442
457
 
443
- export { type CardDossier, type CardSummary, type CouchAuth, type CourseSlice, type DatasetCardHistory, type DatasetRecord, type DiagnosticsInterpreters, type EloLedger, type FetchLearnerDumpOptions, FilterKind, type FilterRunStat, type GeneratorRunStat, type LearnerDataset, type LearnerDump, type PipelineRunStats, RegulatorName, RegulatorReading, type RegulatorRunStat, type ResponseEloDelta, SESSION_FLAGS, SESSION_FLAG_THRESHOLDS, type ServedTagStat, type SessionDetail, type SessionFlag, type SessionStateRow, SessionStateSnapshot, type SessionSummary, StudySessionDoc, StudySessionRunSummary, type TimelineEntry, type TimelineResponse, type TimelineRun, cardDossiers, dumpFileName, eloLedger, fetchLearnerDump, fmtAnswer, fmtDelta, fmtDuration, fromDump, isSkillTag, parseLearnerDump, pipelineRunStats, recordPerformance, regulatorText, runText, scoredTagDeltas, servedTags, sessionDetail, sessionText, shortTag, summarizeSession, summarizeSessions, toIsoTimestamp, userDbName };
458
+ export { type CardDossier, type CardSummary, type CouchAuth, type CourseSlice, type DatasetCardHistory, type DatasetRecord, type DiagnosticsInterpreters, type EloLedger, type FetchLearnerDumpOptions, FilterKind, type FilterRunStat, type GeneratorRunStat, type LearnerDataset, type LearnerDump, type PipelineRunStats, RegulatorName, RegulatorReading, type RegulatorRunStat, type ResponseEloDelta, SESSION_FLAGS, SESSION_FLAG_THRESHOLDS, type ServedTagStat, type SessionDetail, type SessionFlag, type SessionStateRow, SessionStateSnapshot, type SessionSummary, StudySessionDoc, StudySessionRunCard, StudySessionRunSummary, type TimelineEntry, type TimelineResponse, type TimelineRun, cardDossiers, dumpFileName, eloLedger, fetchLearnerDump, fmtAnswer, fmtDelta, fmtDuration, fmtScore, fromDump, isSkillTag, parseLearnerDump, pipelineRunStats, recordPerformance, regulatorText, runCardSource, runText, scoredTagDeltas, selectedBySource, servedTags, sessionDetail, sessionText, shortTag, summarizeSession, summarizeSessions, toIsoTimestamp, userDbName };
@@ -29,14 +29,17 @@ __export(diagnostics_exports, {
29
29
  fmtAnswer: () => fmtAnswer,
30
30
  fmtDelta: () => fmtDelta,
31
31
  fmtDuration: () => fmtDuration,
32
+ fmtScore: () => fmtScore,
32
33
  fromDump: () => fromDump,
33
34
  isSkillTag: () => isSkillTag,
34
35
  parseLearnerDump: () => parseLearnerDump,
35
36
  pipelineRunStats: () => pipelineRunStats,
36
37
  recordPerformance: () => recordPerformance,
37
38
  regulatorText: () => regulatorText,
39
+ runCardSource: () => runCardSource,
38
40
  runText: () => runText,
39
41
  scoredTagDeltas: () => scoredTagDeltas,
42
+ selectedBySource: () => selectedBySource,
40
43
  servedTags: () => servedTags,
41
44
  sessionDetail: () => sessionDetail,
42
45
  sessionText: () => sessionText,
@@ -429,7 +432,7 @@ function attachEloEvents(responses, events, interp) {
429
432
  let bestGap = Infinity;
430
433
  responses.forEach((r, i) => {
431
434
  if (used.has(i) || r.cardId !== ev.cardId) return;
432
- const gap = Math.abs(Date.parse(r.at) - evT);
435
+ const gap = Math.abs(Date.parse(r.at) + r.timeSpentMs - evT);
433
436
  if (gap < bestGap) {
434
437
  bestGap = gap;
435
438
  best = i;
@@ -576,6 +579,150 @@ function recordPerformance(r) {
576
579
  return null;
577
580
  }
578
581
 
582
+ // src/diagnostics/pipeline.ts
583
+ function runCardSource(card) {
584
+ if (card.required) return `required: ${card.required}`;
585
+ return card.generator ?? "unknown";
586
+ }
587
+ function selectedBySource(run) {
588
+ const counts = /* @__PURE__ */ new Map();
589
+ for (const c of run.cards ?? []) {
590
+ if (!c.selected) continue;
591
+ const source = runCardSource(c);
592
+ counts.set(source, (counts.get(source) ?? 0) + 1);
593
+ }
594
+ return [...counts].map(([source, count]) => ({ source, count })).sort((a, b) => b.count - a.count);
595
+ }
596
+ function pipelineRunStats(ds, opts = {}) {
597
+ const sessions = ds.sessions.filter((s) => !opts.since || s.startTime >= opts.since);
598
+ const recordsBySession = /* @__PURE__ */ new Map();
599
+ for (const h of ds.cardHistories) {
600
+ for (const record of h.records) {
601
+ if (!record.sessionId) continue;
602
+ const list = recordsBySession.get(record.sessionId) ?? [];
603
+ list.push({ cardId: h.cardID, record });
604
+ recordsBySession.set(record.sessionId, list);
605
+ }
606
+ }
607
+ const gens = /* @__PURE__ */ new Map();
608
+ const gen = (name) => {
609
+ let g = gens.get(name);
610
+ if (!g) {
611
+ g = {
612
+ name,
613
+ runs: 0,
614
+ cards: 0,
615
+ newCards: 0,
616
+ reviewCards: 0,
617
+ topScoreMax: 0,
618
+ topScoreLast: 0,
619
+ selected: 0,
620
+ firstAttempts: 0,
621
+ firstAttemptsCorrect: 0
622
+ };
623
+ gens.set(name, g);
624
+ }
625
+ return g;
626
+ };
627
+ const filters = /* @__PURE__ */ new Map();
628
+ const regulators = /* @__PURE__ */ new Map();
629
+ let runs = 0;
630
+ let runsWithSelection = 0;
631
+ let selectedUnattributed = 0;
632
+ let firstRunAt;
633
+ let lastRunAt;
634
+ for (const session of sessions) {
635
+ const originBySelectedCard = /* @__PURE__ */ new Map();
636
+ for (const run of session.runs ?? []) {
637
+ runs++;
638
+ if (!firstRunAt || run.at < firstRunAt) firstRunAt = run.at;
639
+ if (!lastRunAt || run.at > lastRunAt) lastRunAt = run.at;
640
+ for (const s of run.generators ?? []) {
641
+ const g = gen(s.name);
642
+ g.runs++;
643
+ g.cards += s.cardCount;
644
+ g.newCards += s.newCount;
645
+ g.reviewCards += s.reviewCount;
646
+ g.topScoreMax = Math.max(g.topScoreMax, s.topScore);
647
+ g.topScoreLast = s.topScore;
648
+ }
649
+ for (const f of run.filters ?? []) {
650
+ const acc = filters.get(f.name) ?? {
651
+ name: f.name,
652
+ runs: 0,
653
+ boosted: 0,
654
+ penalized: 0,
655
+ passed: 0,
656
+ removed: 0
657
+ };
658
+ acc.runs++;
659
+ if (f.kind) acc.kind = f.kind;
660
+ acc.boosted += f.boosted;
661
+ acc.penalized += f.penalized;
662
+ acc.passed += f.passed;
663
+ acc.removed += f.removed;
664
+ filters.set(f.name, acc);
665
+ }
666
+ for (const r of run.regulators ?? []) {
667
+ const acc = regulators.get(r.name) ?? {
668
+ name: r.name,
669
+ class: r.class,
670
+ runs: 0,
671
+ meanMultiplier: 0,
672
+ maxMultiplier: 0,
673
+ runsActive: 0,
674
+ last: r,
675
+ sumMultiplier: 0
676
+ };
677
+ acc.runs++;
678
+ acc.sumMultiplier += r.multiplier;
679
+ acc.maxMultiplier = Math.max(acc.maxMultiplier, r.multiplier);
680
+ if (r.multiplier > 1) acc.runsActive++;
681
+ acc.last = r;
682
+ regulators.set(r.name, acc);
683
+ }
684
+ if (run.cards) {
685
+ runsWithSelection++;
686
+ for (const c of run.cards) {
687
+ if (!c.selected) continue;
688
+ if (!c.generator) {
689
+ selectedUnattributed++;
690
+ continue;
691
+ }
692
+ gen(c.generator).selected++;
693
+ if (!originBySelectedCard.has(c.cardId)) originBySelectedCard.set(c.cardId, c.generator);
694
+ }
695
+ }
696
+ }
697
+ for (const { cardId, record } of recordsBySession.get(session.sessionId) ?? []) {
698
+ const origin = originBySelectedCard.get(cardId);
699
+ if (!origin || record.priorAttemps !== 0) continue;
700
+ const g = gen(origin);
701
+ g.firstAttempts++;
702
+ if (record.isCorrect === true) g.firstAttemptsCorrect++;
703
+ }
704
+ }
705
+ return {
706
+ sessions: sessions.length,
707
+ runs,
708
+ runsWithSelection,
709
+ firstRunAt,
710
+ lastRunAt,
711
+ generators: [...gens.values()].map(({ cards, newCards, reviewCards, ...g }) => ({
712
+ ...g,
713
+ meanCards: g.runs ? cards / g.runs : 0,
714
+ meanNew: g.runs ? newCards / g.runs : 0,
715
+ meanReview: g.runs ? reviewCards / g.runs : 0
716
+ })).sort((a, b) => b.runs - a.runs || a.name.localeCompare(b.name)),
717
+ filters: [...filters.values()].sort((a, b) => a.name.localeCompare(b.name)),
718
+ regulators: [...regulators.values()].map(({ sumMultiplier, ...r }) => ({
719
+ ...r,
720
+ meanMultiplier: r.runs ? sumMultiplier / r.runs : 0
721
+ })),
722
+ selectedUnattributed
723
+ };
724
+ }
725
+
579
726
  // src/diagnostics/text.ts
580
727
  function fmtDelta(d) {
581
728
  if (d === null) return "\u2014";
@@ -601,11 +748,12 @@ function fmtAnswer(a, max = 40) {
601
748
  }
602
749
  }
603
750
  function fmtScore(n) {
751
+ if (n === null || !Number.isFinite(n)) return "\u221E";
604
752
  return Math.abs(n) >= 0.01 || n === 0 ? n.toFixed(2) : n.toExponential(1);
605
753
  }
606
754
  function trailText(label, t) {
607
755
  const lines = [
608
- ` ${label}: ${t.cardId} (${t.origin}, ${t.generator ?? "?"}) final ${fmtScore(t.score)}`
756
+ ` ${label}: ${t.cardId} (${t.origin}, ${runCardSource(t)}) final ${fmtScore(t.score)}`
609
757
  ];
610
758
  for (const p of t.trail) {
611
759
  lines.push(` ${p.action} ${p.strategyName} \u2192 ${fmtScore(p.score)}: ${p.reason}`);
@@ -626,6 +774,11 @@ function runText(run) {
626
774
  `RUN ${run.label}${run.mode ? ` [${run.mode}]` : ""} @ ${run.at} \u2014 generated ${run.generatedCount} \u2192 selected ${run.finalCount} (${run.newSelected} new, ${run.reviewsSelected} review)` + (run.generatedCount > 0 && run.finalCount === 0 ? " \u26A0 nothing survived" : "")
627
775
  );
628
776
  if (typeof run.userElo === "number") L.push(` userElo: ${Math.round(run.userElo)}`);
777
+ if (run.versions) {
778
+ L.push(
779
+ ` versions: strategies ${run.versions.strategies ?? "\u2014"} \xB7 content ${run.versions.content ?? "\u2014"}`
780
+ );
781
+ }
629
782
  if (run.generators?.length) {
630
783
  L.push(" generators:");
631
784
  for (const g of run.generators) {
@@ -648,10 +801,12 @@ function runText(run) {
648
801
  }
649
802
  if (run.hints) L.push(` hints: ${JSON.stringify(run.hints)}`);
650
803
  if (run.cards?.length) {
804
+ const sources = selectedBySource(run).map((s) => `${s.source} ${s.count}`);
805
+ if (sources.length) L.push(` selected by source: ${sources.join(" \xB7 ")}`);
651
806
  L.push(" selection (\u2713 selected, \xB7 runner-up):");
652
807
  for (const c of run.cards) {
653
808
  L.push(
654
- ` ${c.selected ? "\u2713" : "\xB7"} ${c.cardId} (${c.origin}, ${c.generator ?? "?"}) ${fmtScore(c.score)}`
809
+ ` ${c.selected ? "\u2713" : "\xB7"} ${c.cardId} (${c.origin}, ${runCardSource(c)}) ${fmtScore(c.score)}`
655
810
  );
656
811
  }
657
812
  }
@@ -699,9 +854,13 @@ function sessionText(username, detail, extras = {}, interp) {
699
854
  L.push(" (gate: not ready yet; signal: preference). regulators: the pressure on each class,");
700
855
  L.push(" review mass (due reviews by value) and intake (hours since a new card).");
701
856
  L.push(" hints: the ReplanHints the navigator was told (_label = replan reason).");
857
+ L.push(" versions: the strategy docs' hash and the content version the run ran on; the");
858
+ L.push(" headline's are the framework and app versions. A change between runs marks a deploy.");
702
859
  L.push(' selection: the chosen cards and top runners-up. "next new in line" / "top-generated');
703
860
  L.push(' new (sunk)": the unselected new cards worth explaining, with each score change.');
704
- L.push(' Prescribed and hint-required cards count as origin "unknown" (known miscount).');
861
+ L.push(" Each card reads (origin, source). origin: review = a scheduled review, new = anything");
862
+ L.push(' else. source: the generator that produced it, or "required: <hint>" when a hint forced');
863
+ L.push(' it. Older runs show origin "unknown" for prescribed and hint-required cards.');
705
864
  L.push(`- RESP "\u2713/\u2717 type <cardId> [tags] Ts (attempt k) 'answer'": one presentation and`);
706
865
  L.push(' its outcome. A trailing "ELO g:before\u2192after (\u0394) | tag:\u0394 \u2026" is the exchange it');
707
866
  L.push(" produced. Only first attempts move ELO.");
@@ -709,6 +868,11 @@ function sessionText(username, detail, extras = {}, interp) {
709
868
  L.push("## Headline");
710
869
  L.push(`- status: ${doc.status}`);
711
870
  L.push(`- start: ${doc.startTime}${doc.endTime ? ` \xB7 end: ${doc.endTime}` : ""}`);
871
+ if (doc.versions) {
872
+ L.push(
873
+ `- versions: framework ${doc.versions.framework}` + (doc.versions.app ? ` \xB7 app ${doc.versions.app}` : "")
874
+ );
875
+ }
712
876
  L.push(
713
877
  `- clock: ${s.durationSeconds ?? "\u2014"}s of ${doc.plannedSeconds}s planned` + (doc.tally ? ` \xB7 ${doc.tally.secondsRemaining}s remaining` : "")
714
878
  );
@@ -770,137 +934,6 @@ function sessionText(username, detail, extras = {}, interp) {
770
934
  }
771
935
  return L.join("\n");
772
936
  }
773
-
774
- // src/diagnostics/pipeline.ts
775
- function pipelineRunStats(ds, opts = {}) {
776
- const sessions = ds.sessions.filter((s) => !opts.since || s.startTime >= opts.since);
777
- const recordsBySession = /* @__PURE__ */ new Map();
778
- for (const h of ds.cardHistories) {
779
- for (const record of h.records) {
780
- if (!record.sessionId) continue;
781
- const list = recordsBySession.get(record.sessionId) ?? [];
782
- list.push({ cardId: h.cardID, record });
783
- recordsBySession.set(record.sessionId, list);
784
- }
785
- }
786
- const gens = /* @__PURE__ */ new Map();
787
- const gen = (name) => {
788
- let g = gens.get(name);
789
- if (!g) {
790
- g = {
791
- name,
792
- runs: 0,
793
- cards: 0,
794
- newCards: 0,
795
- reviewCards: 0,
796
- topScoreMax: 0,
797
- topScoreLast: 0,
798
- selected: 0,
799
- firstAttempts: 0,
800
- firstAttemptsCorrect: 0
801
- };
802
- gens.set(name, g);
803
- }
804
- return g;
805
- };
806
- const filters = /* @__PURE__ */ new Map();
807
- const regulators = /* @__PURE__ */ new Map();
808
- let runs = 0;
809
- let runsWithSelection = 0;
810
- let selectedUnattributed = 0;
811
- let firstRunAt;
812
- let lastRunAt;
813
- for (const session of sessions) {
814
- const originBySelectedCard = /* @__PURE__ */ new Map();
815
- for (const run of session.runs ?? []) {
816
- runs++;
817
- if (!firstRunAt || run.at < firstRunAt) firstRunAt = run.at;
818
- if (!lastRunAt || run.at > lastRunAt) lastRunAt = run.at;
819
- for (const s of run.generators ?? []) {
820
- const g = gen(s.name);
821
- g.runs++;
822
- g.cards += s.cardCount;
823
- g.newCards += s.newCount;
824
- g.reviewCards += s.reviewCount;
825
- g.topScoreMax = Math.max(g.topScoreMax, s.topScore);
826
- g.topScoreLast = s.topScore;
827
- }
828
- for (const f of run.filters ?? []) {
829
- const acc = filters.get(f.name) ?? {
830
- name: f.name,
831
- runs: 0,
832
- boosted: 0,
833
- penalized: 0,
834
- passed: 0,
835
- removed: 0
836
- };
837
- acc.runs++;
838
- if (f.kind) acc.kind = f.kind;
839
- acc.boosted += f.boosted;
840
- acc.penalized += f.penalized;
841
- acc.passed += f.passed;
842
- acc.removed += f.removed;
843
- filters.set(f.name, acc);
844
- }
845
- for (const r of run.regulators ?? []) {
846
- const acc = regulators.get(r.name) ?? {
847
- name: r.name,
848
- class: r.class,
849
- runs: 0,
850
- meanMultiplier: 0,
851
- maxMultiplier: 0,
852
- runsActive: 0,
853
- last: r,
854
- sumMultiplier: 0
855
- };
856
- acc.runs++;
857
- acc.sumMultiplier += r.multiplier;
858
- acc.maxMultiplier = Math.max(acc.maxMultiplier, r.multiplier);
859
- if (r.multiplier > 1) acc.runsActive++;
860
- acc.last = r;
861
- regulators.set(r.name, acc);
862
- }
863
- if (run.cards) {
864
- runsWithSelection++;
865
- for (const c of run.cards) {
866
- if (!c.selected) continue;
867
- if (!c.generator) {
868
- selectedUnattributed++;
869
- continue;
870
- }
871
- gen(c.generator).selected++;
872
- if (!originBySelectedCard.has(c.cardId)) originBySelectedCard.set(c.cardId, c.generator);
873
- }
874
- }
875
- }
876
- for (const { cardId, record } of recordsBySession.get(session.sessionId) ?? []) {
877
- const origin = originBySelectedCard.get(cardId);
878
- if (!origin || record.priorAttemps !== 0) continue;
879
- const g = gen(origin);
880
- g.firstAttempts++;
881
- if (record.isCorrect === true) g.firstAttemptsCorrect++;
882
- }
883
- }
884
- return {
885
- sessions: sessions.length,
886
- runs,
887
- runsWithSelection,
888
- firstRunAt,
889
- lastRunAt,
890
- generators: [...gens.values()].map(({ cards, newCards, reviewCards, ...g }) => ({
891
- ...g,
892
- meanCards: g.runs ? cards / g.runs : 0,
893
- meanNew: g.runs ? newCards / g.runs : 0,
894
- meanReview: g.runs ? reviewCards / g.runs : 0
895
- })).sort((a, b) => b.runs - a.runs || a.name.localeCompare(b.name)),
896
- filters: [...filters.values()].sort((a, b) => a.name.localeCompare(b.name)),
897
- regulators: [...regulators.values()].map(({ sumMultiplier, ...r }) => ({
898
- ...r,
899
- meanMultiplier: r.runs ? sumMultiplier / r.runs : 0
900
- })),
901
- selectedUnattributed
902
- };
903
- }
904
937
  // Annotate the CommonJS export names for ESM import in node:
905
938
  0 && (module.exports = {
906
939
  SESSION_FLAGS,
@@ -912,14 +945,17 @@ function pipelineRunStats(ds, opts = {}) {
912
945
  fmtAnswer,
913
946
  fmtDelta,
914
947
  fmtDuration,
948
+ fmtScore,
915
949
  fromDump,
916
950
  isSkillTag,
917
951
  parseLearnerDump,
918
952
  pipelineRunStats,
919
953
  recordPerformance,
920
954
  regulatorText,
955
+ runCardSource,
921
956
  runText,
922
957
  scoredTagDeltas,
958
+ selectedBySource,
923
959
  servedTags,
924
960
  sessionDetail,
925
961
  sessionText,