@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
@@ -379,7 +379,7 @@ function attachEloEvents(responses, events, interp) {
379
379
  let bestGap = Infinity;
380
380
  responses.forEach((r, i) => {
381
381
  if (used.has(i) || r.cardId !== ev.cardId) return;
382
- const gap = Math.abs(Date.parse(r.at) - evT);
382
+ const gap = Math.abs(Date.parse(r.at) + r.timeSpentMs - evT);
383
383
  if (gap < bestGap) {
384
384
  bestGap = gap;
385
385
  best = i;
@@ -526,6 +526,150 @@ function recordPerformance(r) {
526
526
  return null;
527
527
  }
528
528
 
529
+ // src/diagnostics/pipeline.ts
530
+ function runCardSource(card) {
531
+ if (card.required) return `required: ${card.required}`;
532
+ return card.generator ?? "unknown";
533
+ }
534
+ function selectedBySource(run) {
535
+ const counts = /* @__PURE__ */ new Map();
536
+ for (const c of run.cards ?? []) {
537
+ if (!c.selected) continue;
538
+ const source = runCardSource(c);
539
+ counts.set(source, (counts.get(source) ?? 0) + 1);
540
+ }
541
+ return [...counts].map(([source, count]) => ({ source, count })).sort((a, b) => b.count - a.count);
542
+ }
543
+ function pipelineRunStats(ds, opts = {}) {
544
+ const sessions = ds.sessions.filter((s) => !opts.since || s.startTime >= opts.since);
545
+ const recordsBySession = /* @__PURE__ */ new Map();
546
+ for (const h of ds.cardHistories) {
547
+ for (const record of h.records) {
548
+ if (!record.sessionId) continue;
549
+ const list = recordsBySession.get(record.sessionId) ?? [];
550
+ list.push({ cardId: h.cardID, record });
551
+ recordsBySession.set(record.sessionId, list);
552
+ }
553
+ }
554
+ const gens = /* @__PURE__ */ new Map();
555
+ const gen = (name) => {
556
+ let g = gens.get(name);
557
+ if (!g) {
558
+ g = {
559
+ name,
560
+ runs: 0,
561
+ cards: 0,
562
+ newCards: 0,
563
+ reviewCards: 0,
564
+ topScoreMax: 0,
565
+ topScoreLast: 0,
566
+ selected: 0,
567
+ firstAttempts: 0,
568
+ firstAttemptsCorrect: 0
569
+ };
570
+ gens.set(name, g);
571
+ }
572
+ return g;
573
+ };
574
+ const filters = /* @__PURE__ */ new Map();
575
+ const regulators = /* @__PURE__ */ new Map();
576
+ let runs = 0;
577
+ let runsWithSelection = 0;
578
+ let selectedUnattributed = 0;
579
+ let firstRunAt;
580
+ let lastRunAt;
581
+ for (const session of sessions) {
582
+ const originBySelectedCard = /* @__PURE__ */ new Map();
583
+ for (const run of session.runs ?? []) {
584
+ runs++;
585
+ if (!firstRunAt || run.at < firstRunAt) firstRunAt = run.at;
586
+ if (!lastRunAt || run.at > lastRunAt) lastRunAt = run.at;
587
+ for (const s of run.generators ?? []) {
588
+ const g = gen(s.name);
589
+ g.runs++;
590
+ g.cards += s.cardCount;
591
+ g.newCards += s.newCount;
592
+ g.reviewCards += s.reviewCount;
593
+ g.topScoreMax = Math.max(g.topScoreMax, s.topScore);
594
+ g.topScoreLast = s.topScore;
595
+ }
596
+ for (const f of run.filters ?? []) {
597
+ const acc = filters.get(f.name) ?? {
598
+ name: f.name,
599
+ runs: 0,
600
+ boosted: 0,
601
+ penalized: 0,
602
+ passed: 0,
603
+ removed: 0
604
+ };
605
+ acc.runs++;
606
+ if (f.kind) acc.kind = f.kind;
607
+ acc.boosted += f.boosted;
608
+ acc.penalized += f.penalized;
609
+ acc.passed += f.passed;
610
+ acc.removed += f.removed;
611
+ filters.set(f.name, acc);
612
+ }
613
+ for (const r of run.regulators ?? []) {
614
+ const acc = regulators.get(r.name) ?? {
615
+ name: r.name,
616
+ class: r.class,
617
+ runs: 0,
618
+ meanMultiplier: 0,
619
+ maxMultiplier: 0,
620
+ runsActive: 0,
621
+ last: r,
622
+ sumMultiplier: 0
623
+ };
624
+ acc.runs++;
625
+ acc.sumMultiplier += r.multiplier;
626
+ acc.maxMultiplier = Math.max(acc.maxMultiplier, r.multiplier);
627
+ if (r.multiplier > 1) acc.runsActive++;
628
+ acc.last = r;
629
+ regulators.set(r.name, acc);
630
+ }
631
+ if (run.cards) {
632
+ runsWithSelection++;
633
+ for (const c of run.cards) {
634
+ if (!c.selected) continue;
635
+ if (!c.generator) {
636
+ selectedUnattributed++;
637
+ continue;
638
+ }
639
+ gen(c.generator).selected++;
640
+ if (!originBySelectedCard.has(c.cardId)) originBySelectedCard.set(c.cardId, c.generator);
641
+ }
642
+ }
643
+ }
644
+ for (const { cardId, record } of recordsBySession.get(session.sessionId) ?? []) {
645
+ const origin = originBySelectedCard.get(cardId);
646
+ if (!origin || record.priorAttemps !== 0) continue;
647
+ const g = gen(origin);
648
+ g.firstAttempts++;
649
+ if (record.isCorrect === true) g.firstAttemptsCorrect++;
650
+ }
651
+ }
652
+ return {
653
+ sessions: sessions.length,
654
+ runs,
655
+ runsWithSelection,
656
+ firstRunAt,
657
+ lastRunAt,
658
+ generators: [...gens.values()].map(({ cards, newCards, reviewCards, ...g }) => ({
659
+ ...g,
660
+ meanCards: g.runs ? cards / g.runs : 0,
661
+ meanNew: g.runs ? newCards / g.runs : 0,
662
+ meanReview: g.runs ? reviewCards / g.runs : 0
663
+ })).sort((a, b) => b.runs - a.runs || a.name.localeCompare(b.name)),
664
+ filters: [...filters.values()].sort((a, b) => a.name.localeCompare(b.name)),
665
+ regulators: [...regulators.values()].map(({ sumMultiplier, ...r }) => ({
666
+ ...r,
667
+ meanMultiplier: r.runs ? sumMultiplier / r.runs : 0
668
+ })),
669
+ selectedUnattributed
670
+ };
671
+ }
672
+
529
673
  // src/diagnostics/text.ts
530
674
  function fmtDelta(d) {
531
675
  if (d === null) return "\u2014";
@@ -551,11 +695,12 @@ function fmtAnswer(a, max = 40) {
551
695
  }
552
696
  }
553
697
  function fmtScore(n) {
698
+ if (n === null || !Number.isFinite(n)) return "\u221E";
554
699
  return Math.abs(n) >= 0.01 || n === 0 ? n.toFixed(2) : n.toExponential(1);
555
700
  }
556
701
  function trailText(label, t) {
557
702
  const lines = [
558
- ` ${label}: ${t.cardId} (${t.origin}, ${t.generator ?? "?"}) final ${fmtScore(t.score)}`
703
+ ` ${label}: ${t.cardId} (${t.origin}, ${runCardSource(t)}) final ${fmtScore(t.score)}`
559
704
  ];
560
705
  for (const p of t.trail) {
561
706
  lines.push(` ${p.action} ${p.strategyName} \u2192 ${fmtScore(p.score)}: ${p.reason}`);
@@ -576,6 +721,11 @@ function runText(run) {
576
721
  `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" : "")
577
722
  );
578
723
  if (typeof run.userElo === "number") L.push(` userElo: ${Math.round(run.userElo)}`);
724
+ if (run.versions) {
725
+ L.push(
726
+ ` versions: strategies ${run.versions.strategies ?? "\u2014"} \xB7 content ${run.versions.content ?? "\u2014"}`
727
+ );
728
+ }
579
729
  if (run.generators?.length) {
580
730
  L.push(" generators:");
581
731
  for (const g of run.generators) {
@@ -598,10 +748,12 @@ function runText(run) {
598
748
  }
599
749
  if (run.hints) L.push(` hints: ${JSON.stringify(run.hints)}`);
600
750
  if (run.cards?.length) {
751
+ const sources = selectedBySource(run).map((s) => `${s.source} ${s.count}`);
752
+ if (sources.length) L.push(` selected by source: ${sources.join(" \xB7 ")}`);
601
753
  L.push(" selection (\u2713 selected, \xB7 runner-up):");
602
754
  for (const c of run.cards) {
603
755
  L.push(
604
- ` ${c.selected ? "\u2713" : "\xB7"} ${c.cardId} (${c.origin}, ${c.generator ?? "?"}) ${fmtScore(c.score)}`
756
+ ` ${c.selected ? "\u2713" : "\xB7"} ${c.cardId} (${c.origin}, ${runCardSource(c)}) ${fmtScore(c.score)}`
605
757
  );
606
758
  }
607
759
  }
@@ -649,9 +801,13 @@ function sessionText(username, detail, extras = {}, interp) {
649
801
  L.push(" (gate: not ready yet; signal: preference). regulators: the pressure on each class,");
650
802
  L.push(" review mass (due reviews by value) and intake (hours since a new card).");
651
803
  L.push(" hints: the ReplanHints the navigator was told (_label = replan reason).");
804
+ L.push(" versions: the strategy docs' hash and the content version the run ran on; the");
805
+ L.push(" headline's are the framework and app versions. A change between runs marks a deploy.");
652
806
  L.push(' selection: the chosen cards and top runners-up. "next new in line" / "top-generated');
653
807
  L.push(' new (sunk)": the unselected new cards worth explaining, with each score change.');
654
- L.push(' Prescribed and hint-required cards count as origin "unknown" (known miscount).');
808
+ L.push(" Each card reads (origin, source). origin: review = a scheduled review, new = anything");
809
+ L.push(' else. source: the generator that produced it, or "required: <hint>" when a hint forced');
810
+ L.push(' it. Older runs show origin "unknown" for prescribed and hint-required cards.');
655
811
  L.push(`- RESP "\u2713/\u2717 type <cardId> [tags] Ts (attempt k) 'answer'": one presentation and`);
656
812
  L.push(' its outcome. A trailing "ELO g:before\u2192after (\u0394) | tag:\u0394 \u2026" is the exchange it');
657
813
  L.push(" produced. Only first attempts move ELO.");
@@ -659,6 +815,11 @@ function sessionText(username, detail, extras = {}, interp) {
659
815
  L.push("## Headline");
660
816
  L.push(`- status: ${doc.status}`);
661
817
  L.push(`- start: ${doc.startTime}${doc.endTime ? ` \xB7 end: ${doc.endTime}` : ""}`);
818
+ if (doc.versions) {
819
+ L.push(
820
+ `- versions: framework ${doc.versions.framework}` + (doc.versions.app ? ` \xB7 app ${doc.versions.app}` : "")
821
+ );
822
+ }
662
823
  L.push(
663
824
  `- clock: ${s.durationSeconds ?? "\u2014"}s of ${doc.plannedSeconds}s planned` + (doc.tally ? ` \xB7 ${doc.tally.secondsRemaining}s remaining` : "")
664
825
  );
@@ -720,137 +881,6 @@ function sessionText(username, detail, extras = {}, interp) {
720
881
  }
721
882
  return L.join("\n");
722
883
  }
723
-
724
- // src/diagnostics/pipeline.ts
725
- function pipelineRunStats(ds, opts = {}) {
726
- const sessions = ds.sessions.filter((s) => !opts.since || s.startTime >= opts.since);
727
- const recordsBySession = /* @__PURE__ */ new Map();
728
- for (const h of ds.cardHistories) {
729
- for (const record of h.records) {
730
- if (!record.sessionId) continue;
731
- const list = recordsBySession.get(record.sessionId) ?? [];
732
- list.push({ cardId: h.cardID, record });
733
- recordsBySession.set(record.sessionId, list);
734
- }
735
- }
736
- const gens = /* @__PURE__ */ new Map();
737
- const gen = (name) => {
738
- let g = gens.get(name);
739
- if (!g) {
740
- g = {
741
- name,
742
- runs: 0,
743
- cards: 0,
744
- newCards: 0,
745
- reviewCards: 0,
746
- topScoreMax: 0,
747
- topScoreLast: 0,
748
- selected: 0,
749
- firstAttempts: 0,
750
- firstAttemptsCorrect: 0
751
- };
752
- gens.set(name, g);
753
- }
754
- return g;
755
- };
756
- const filters = /* @__PURE__ */ new Map();
757
- const regulators = /* @__PURE__ */ new Map();
758
- let runs = 0;
759
- let runsWithSelection = 0;
760
- let selectedUnattributed = 0;
761
- let firstRunAt;
762
- let lastRunAt;
763
- for (const session of sessions) {
764
- const originBySelectedCard = /* @__PURE__ */ new Map();
765
- for (const run of session.runs ?? []) {
766
- runs++;
767
- if (!firstRunAt || run.at < firstRunAt) firstRunAt = run.at;
768
- if (!lastRunAt || run.at > lastRunAt) lastRunAt = run.at;
769
- for (const s of run.generators ?? []) {
770
- const g = gen(s.name);
771
- g.runs++;
772
- g.cards += s.cardCount;
773
- g.newCards += s.newCount;
774
- g.reviewCards += s.reviewCount;
775
- g.topScoreMax = Math.max(g.topScoreMax, s.topScore);
776
- g.topScoreLast = s.topScore;
777
- }
778
- for (const f of run.filters ?? []) {
779
- const acc = filters.get(f.name) ?? {
780
- name: f.name,
781
- runs: 0,
782
- boosted: 0,
783
- penalized: 0,
784
- passed: 0,
785
- removed: 0
786
- };
787
- acc.runs++;
788
- if (f.kind) acc.kind = f.kind;
789
- acc.boosted += f.boosted;
790
- acc.penalized += f.penalized;
791
- acc.passed += f.passed;
792
- acc.removed += f.removed;
793
- filters.set(f.name, acc);
794
- }
795
- for (const r of run.regulators ?? []) {
796
- const acc = regulators.get(r.name) ?? {
797
- name: r.name,
798
- class: r.class,
799
- runs: 0,
800
- meanMultiplier: 0,
801
- maxMultiplier: 0,
802
- runsActive: 0,
803
- last: r,
804
- sumMultiplier: 0
805
- };
806
- acc.runs++;
807
- acc.sumMultiplier += r.multiplier;
808
- acc.maxMultiplier = Math.max(acc.maxMultiplier, r.multiplier);
809
- if (r.multiplier > 1) acc.runsActive++;
810
- acc.last = r;
811
- regulators.set(r.name, acc);
812
- }
813
- if (run.cards) {
814
- runsWithSelection++;
815
- for (const c of run.cards) {
816
- if (!c.selected) continue;
817
- if (!c.generator) {
818
- selectedUnattributed++;
819
- continue;
820
- }
821
- gen(c.generator).selected++;
822
- if (!originBySelectedCard.has(c.cardId)) originBySelectedCard.set(c.cardId, c.generator);
823
- }
824
- }
825
- }
826
- for (const { cardId, record } of recordsBySession.get(session.sessionId) ?? []) {
827
- const origin = originBySelectedCard.get(cardId);
828
- if (!origin || record.priorAttemps !== 0) continue;
829
- const g = gen(origin);
830
- g.firstAttempts++;
831
- if (record.isCorrect === true) g.firstAttemptsCorrect++;
832
- }
833
- }
834
- return {
835
- sessions: sessions.length,
836
- runs,
837
- runsWithSelection,
838
- firstRunAt,
839
- lastRunAt,
840
- generators: [...gens.values()].map(({ cards, newCards, reviewCards, ...g }) => ({
841
- ...g,
842
- meanCards: g.runs ? cards / g.runs : 0,
843
- meanNew: g.runs ? newCards / g.runs : 0,
844
- meanReview: g.runs ? reviewCards / g.runs : 0
845
- })).sort((a, b) => b.runs - a.runs || a.name.localeCompare(b.name)),
846
- filters: [...filters.values()].sort((a, b) => a.name.localeCompare(b.name)),
847
- regulators: [...regulators.values()].map(({ sumMultiplier, ...r }) => ({
848
- ...r,
849
- meanMultiplier: r.runs ? sumMultiplier / r.runs : 0
850
- })),
851
- selectedUnattributed
852
- };
853
- }
854
884
  export {
855
885
  SESSION_FLAGS,
856
886
  SESSION_FLAG_THRESHOLDS,
@@ -861,14 +891,17 @@ export {
861
891
  fmtAnswer,
862
892
  fmtDelta,
863
893
  fmtDuration,
894
+ fmtScore,
864
895
  fromDump,
865
896
  isSkillTag,
866
897
  parseLearnerDump,
867
898
  pipelineRunStats,
868
899
  recordPerformance,
869
900
  regulatorText,
901
+ runCardSource,
870
902
  runText,
871
903
  scoredTagDeltas,
904
+ selectedBySource,
872
905
  servedTags,
873
906
  sessionDetail,
874
907
  sessionText,