@vue-skuilder/db 0.2.27 → 0.2.29

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 (82) hide show
  1. package/dist/classroomDB-DLTtLZct.d.cts +86 -0
  2. package/dist/classroomDB-DLTtLZct.d.ts +86 -0
  3. package/dist/{contentSource-LPf044hY.d.ts → contentSource-B6FrSihy.d.cts} +282 -99
  4. package/dist/{contentSource-D3c1fMAk.d.cts → contentSource-CqJmbOZN.d.ts} +282 -99
  5. package/dist/core/index.d.cts +16 -92
  6. package/dist/core/index.d.ts +16 -92
  7. package/dist/core/index.js +607 -179
  8. package/dist/core/index.js.map +1 -1
  9. package/dist/core/index.mjs +606 -179
  10. package/dist/core/index.mjs.map +1 -1
  11. package/dist/{dataLayerProvider-DaAootVV.d.ts → dataLayerProvider-B9_UCvkR.d.ts} +2 -8
  12. package/dist/{dataLayerProvider-CeLiFbHv.d.cts → dataLayerProvider-DUxDqMtZ.d.cts} +2 -8
  13. package/dist/diagnostics/index.d.cts +443 -0
  14. package/dist/diagnostics/index.d.ts +443 -0
  15. package/dist/diagnostics/index.js +932 -0
  16. package/dist/diagnostics/index.js.map +1 -0
  17. package/dist/diagnostics/index.mjs +881 -0
  18. package/dist/diagnostics/index.mjs.map +1 -0
  19. package/dist/impl/couch/index.d.cts +13 -3
  20. package/dist/impl/couch/index.d.ts +13 -3
  21. package/dist/impl/couch/index.js +605 -179
  22. package/dist/impl/couch/index.js.map +1 -1
  23. package/dist/impl/couch/index.mjs +605 -179
  24. package/dist/impl/couch/index.mjs.map +1 -1
  25. package/dist/impl/static/index.d.cts +11 -5
  26. package/dist/impl/static/index.d.ts +11 -5
  27. package/dist/impl/static/index.js +602 -185
  28. package/dist/impl/static/index.js.map +1 -1
  29. package/dist/impl/static/index.mjs +602 -185
  30. package/dist/impl/static/index.mjs.map +1 -1
  31. package/dist/{index-BkBJlGDX.d.ts → index-CVGehe_t.d.ts} +1 -1
  32. package/dist/{index-D7WdMDAs.d.cts → index-Ktg72jKb.d.cts} +1 -1
  33. package/dist/index.d.cts +73 -11
  34. package/dist/index.d.ts +73 -11
  35. package/dist/index.js +696 -200
  36. package/dist/index.js.map +1 -1
  37. package/dist/index.mjs +683 -200
  38. package/dist/index.mjs.map +1 -1
  39. package/dist/{types-DjiFOZxJ.d.cts → types-D0oQeJAi.d.cts} +1 -1
  40. package/dist/{types-uJ2Xn3_X.d.ts → types-dXWfyz9B.d.ts} +1 -1
  41. package/dist/{types-legacy-CrwyZIvI.d.cts → types-legacy-BkOYOR6U.d.cts} +1 -1
  42. package/dist/{types-legacy-CrwyZIvI.d.ts → types-legacy-BkOYOR6U.d.ts} +1 -1
  43. package/dist/util/packer/index.d.cts +3 -3
  44. package/dist/util/packer/index.d.ts +3 -3
  45. package/package.json +15 -3
  46. package/src/core/interfaces/contentSource.ts +7 -0
  47. package/src/core/interfaces/dataLayerProvider.ts +3 -8
  48. package/src/core/navigators/Pipeline.ts +149 -14
  49. package/src/core/navigators/PipelineAssembler.ts +19 -40
  50. package/src/core/navigators/PipelineDebugger.ts +74 -17
  51. package/src/core/navigators/SrsDebugger.ts +37 -12
  52. package/src/core/navigators/defaults.ts +29 -5
  53. package/src/core/navigators/filters/WeightedFilter.ts +5 -1
  54. package/src/core/navigators/filters/eloDistance.ts +261 -76
  55. package/src/core/navigators/filters/hierarchyDefinition.ts +5 -1
  56. package/src/core/navigators/filters/index.ts +2 -2
  57. package/src/core/navigators/filters/interferenceMitigator.ts +5 -1
  58. package/src/core/navigators/filters/relativePriority.ts +5 -1
  59. package/src/core/navigators/filters/types.ts +24 -1
  60. package/src/core/navigators/filters/userTagPreference.ts +5 -1
  61. package/src/core/navigators/generators/elo.ts +23 -53
  62. package/src/core/navigators/generators/srs.ts +27 -124
  63. package/src/core/navigators/index.ts +32 -5
  64. package/src/core/navigators/pipelinePlan.ts +245 -0
  65. package/src/core/navigators/regulators.ts +230 -0
  66. package/src/core/types/studySession.ts +40 -0
  67. package/src/diagnostics/dataset.ts +242 -0
  68. package/src/diagnostics/derive.ts +555 -0
  69. package/src/diagnostics/index.ts +27 -0
  70. package/src/diagnostics/loader.ts +194 -0
  71. package/src/diagnostics/pipeline.ts +236 -0
  72. package/src/diagnostics/text.ts +265 -0
  73. package/src/impl/couch/PouchDataLayerProvider.ts +0 -23
  74. package/src/impl/couch/courseDB.ts +13 -0
  75. package/src/impl/static/StaticDataLayerProvider.ts +0 -11
  76. package/src/impl/static/courseDB.ts +9 -0
  77. package/src/index.ts +4 -0
  78. package/src/study/SessionController.ts +76 -2
  79. package/src/study/SessionOverlay.ts +7 -4
  80. package/tests/core/navigators/PipelineAssembler.test.ts +20 -5
  81. package/tests/core/navigators/eloDistanceFilter.test.ts +9 -9
  82. package/tsup.config.ts +1 -0
@@ -7,13 +7,10 @@ import {
7
7
  CourseDBInterface,
8
8
  DataLayerProvider,
9
9
  UserDBInterface,
10
- UserDBReader,
11
10
  } from '../../core/interfaces';
12
11
  import { logger } from '../../util/logger';
13
12
  import { initializeDataDirectory } from '../../util/dataDirectory';
14
13
 
15
- import { getLoggedInUsername } from './auth';
16
-
17
14
  import { AdminDB } from './adminDB';
18
15
  import { StudentClassroomDB, TeacherClassroomDB } from './classroomDB';
19
16
  import { CourseDB, CoursesDB } from './courseDB';
@@ -115,26 +112,6 @@ export class CouchDataLayerProvider implements DataLayerProvider {
115
112
  return new AdminDB();
116
113
  }
117
114
 
118
- async createUserReaderForUser(targetUsername: string): Promise<UserDBReader> {
119
- // Security check: only admin can access other users' data
120
- const requestingUsername = await getLoggedInUsername();
121
- if (requestingUsername !== 'admin') {
122
- throw new Error('Unauthorized: Only admin users can access other users\' data');
123
- }
124
-
125
- logger.info(`Admin user '${requestingUsername}' requesting UserDBReader for '${targetUsername}'`);
126
-
127
- // Create a new sync strategy for the target user
128
- const syncStrategy = new CouchDBSyncStrategy();
129
-
130
- // Create a BaseUser instance for the target user
131
- // Note: This creates a read-capable user instance without affecting the current session
132
- const targetUserDB = await BaseUser.instance(syncStrategy, targetUsername);
133
-
134
- // Return as UserDBReader (which BaseUser implements since UserDBInterface extends UserDBReader)
135
- return targetUserDB as UserDBReader;
136
- }
137
-
138
115
  isReadOnly(): boolean {
139
116
  return false;
140
117
  }
@@ -12,6 +12,7 @@ import {
12
12
 
13
13
  import { filterAllDocsByPrefix, getCourseDB } from '.';
14
14
  import UpdateQueue from './updateQueue';
15
+ import type { StudyContentSource } from '../../core/interfaces/contentSource';
15
16
  import { StudySessionItem } from '../../core/interfaces/contentSource';
16
17
  import {
17
18
  CardData,
@@ -712,6 +713,18 @@ above:\n${above.rows.map((r) => `\t${r.id}-${r.key}\n`)}`;
712
713
  this._pendingHints = hints;
713
714
  }
714
715
 
716
+ /**
717
+ * Forward a presentation to the navigator (a new card restarts its intake
718
+ * clock). Builds the navigator if the cached one has expired.
719
+ */
720
+ public notePresented(card: { cardId: string; courseId: string; status: string }): void {
721
+ if (card.status !== 'new') return;
722
+ void this._getCurrentUser()
723
+ .then((u) => this._getCachedNavigator(u))
724
+ .then(({ navigator }) => (navigator as StudyContentSource).notePresented?.(card))
725
+ .catch((e) => logger.warn(`[courseDB] Could not note a presentation: ${e}`));
726
+ }
727
+
715
728
  public async getWeightedCards(limit: number): Promise<GeneratorResult> {
716
729
  const u = await this._getCurrentUser();
717
730
 
@@ -8,7 +8,6 @@ import {
8
8
  CourseDBInterface,
9
9
  DataLayerProvider,
10
10
  UserDBInterface,
11
- UserDBReader,
12
11
  } from '../../core/interfaces';
13
12
  import { logger } from '../../util/logger';
14
13
  import { StaticCourseManifest } from '../../util/packer/types';
@@ -152,16 +151,6 @@ export class StaticDataLayerProvider implements DataLayerProvider {
152
151
  throw new Error('Admin functions not supported in static mode');
153
152
  }
154
153
 
155
- async createUserReaderForUser(targetUsername: string): Promise<UserDBReader> {
156
- logger.warn(`StaticDataLayerProvider: Multi-user access not supported in static mode`);
157
- logger.warn(`Request: trying to access data for ${targetUsername}`);
158
- logger.warn(`Returning current user's data instead`);
159
-
160
- // In static mode, just return the current user's DB as a reader
161
- // This is safe since static mode is typically for development/testing
162
- return this.getUserDB() as UserDBReader;
163
- }
164
-
165
154
  isReadOnly(): boolean {
166
155
  return true;
167
156
  }
@@ -5,6 +5,7 @@ import {
5
5
  UserDBInterface,
6
6
  CourseInfo,
7
7
  StudySessionItem,
8
+ type StudyContentSource,
8
9
  } from '../../core/interfaces';
9
10
  import type { GeneratorResult, ReplanHints } from '../../core/navigators/generators/types';
10
11
  import { StaticDataUnpacker } from './StaticDataUnpacker';
@@ -450,6 +451,14 @@ export class StaticCourseDB implements CourseDBInterface {
450
451
  this._pendingHints = hints;
451
452
  }
452
453
 
454
+ /** Forward a presentation to the navigator (a new card restarts its intake clock). */
455
+ notePresented(card: { cardId: string; courseId: string; status: string }): void {
456
+ if (card.status !== 'new') return;
457
+ void this.createNavigator(this.userDB)
458
+ .then((navigator) => (navigator as StudyContentSource).notePresented?.(card))
459
+ .catch((e) => logger.warn(`[static/courseDB] Could not note a presentation: ${e}`));
460
+ }
461
+
453
462
  async getWeightedCards(limit: number): Promise<GeneratorResult> {
454
463
  try {
455
464
  const navigator = await this.createNavigator(this.userDB);
package/src/index.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  export * from './core';
2
2
 
3
+ // Not via the navigators barrel: see the note in pipelinePlan.ts.
4
+ export * from './core/navigators/pipelinePlan';
5
+ export * from './core/navigators/regulators';
6
+
3
7
  export { default as CourseLookup } from './impl/couch/courseLookupDB';
4
8
 
5
9
  export * from './courseConfigRegistration';
@@ -21,6 +21,8 @@ import {
21
21
  type SessionStateSnapshot,
22
22
  type SessionStateSnapshotProvider,
23
23
  type StudySessionDoc,
24
+ type StudySessionRunCard,
25
+ type StudySessionRunCardTrail,
24
26
  type StudySessionRunSummary,
25
27
  } from '@db/core/types/studySession';
26
28
  import { recordUserOutcome } from '@db/core/orchestration/recording';
@@ -33,8 +35,10 @@ import {
33
35
  setDebugSessionId,
34
36
  drainCapturedRuns,
35
37
  } from '@db/core/navigators';
38
+ import type { PipelineRunReport, RunReportCard } from '@db/core/navigators';
36
39
  import { ReplanHints } from '@db/core/navigators/generators/types';
37
40
  import { mergeHints } from '@db/core/navigators/Pipeline';
41
+ import type { RegulatorReading } from '@db/core/navigators/regulators';
38
42
  import { SourceMixer, QuotaRoundRobinMixer, SourceBatch } from './SourceMixer';
39
43
  import { captureMixerRun } from './MixerDebugger';
40
44
  import { startSessionTracking, recordCardPresentation, snapshotQueues, endSessionTracking, clearStaleSessionDebugState } from './SessionDebugger';
@@ -222,6 +226,63 @@ export type OutcomeObserver = (
222
226
  controls: SessionControls
223
227
  ) => void | Promise<void>;
224
228
 
229
+ /** Unselected cards persisted per run, after the selected ones. */
230
+ const PERSISTED_RUNNERS_UP = 5;
231
+
232
+ /** 4 significant figures: keeps 6.4e-7 distinguishable from 0 without 17-digit floats. */
233
+ function sig4(x: number): number {
234
+ return Number(x.toPrecision(4));
235
+ }
236
+
237
+ function toRunCard(c: RunReportCard): StudySessionRunCard {
238
+ return {
239
+ cardId: c.cardId,
240
+ origin: c.origin,
241
+ ...(c.generator ? { generator: c.generator } : {}),
242
+ score: sig4(c.finalScore),
243
+ selected: c.selected,
244
+ };
245
+ }
246
+
247
+ function toRunCardTrail(c: RunReportCard): StudySessionRunCardTrail {
248
+ return {
249
+ ...toRunCard(c),
250
+ trail: c.provenance
251
+ .filter((p) => p.action !== 'passed')
252
+ .map((p) => ({
253
+ strategyName: p.strategyName,
254
+ action: p.action,
255
+ score: sig4(p.score),
256
+ reason: p.reason,
257
+ })),
258
+ };
259
+ }
260
+
261
+ function persistedReading(r: RegulatorReading): RegulatorReading {
262
+ return {
263
+ ...r,
264
+ urgency: sig4(r.urgency),
265
+ multiplier: sig4(r.multiplier),
266
+ inputs: Object.fromEntries(Object.entries(r.inputs).map(([k, v]) => [k, sig4(v)])),
267
+ };
268
+ }
269
+
270
+ /** `run.cards` is selected-then-near-misses, each in score order. */
271
+ function persistedRunCards(run: PipelineRunReport): StudySessionRunCard[] {
272
+ const selected = run.cards.filter((c) => c.selected);
273
+ const runnersUp = run.cards.filter((c) => !c.selected).slice(0, PERSISTED_RUNNERS_UP);
274
+ return [...selected, ...runnersUp].map(toRunCard);
275
+ }
276
+
277
+ function persistedUnselectedNew(
278
+ u: NonNullable<PipelineRunReport['unselectedNew']>
279
+ ): StudySessionRunSummary['unselectedNew'] {
280
+ return {
281
+ ...(u.nextInLine ? { nextInLine: toRunCardTrail(u.nextInLine) } : {}),
282
+ ...(u.topGenerated ? { topGenerated: toRunCardTrail(u.topGenerated) } : {}),
283
+ };
284
+ }
285
+
225
286
  interface SessionServices {
226
287
  response: ResponseProcessor;
227
288
  }
@@ -575,13 +636,17 @@ export class SessionController<TView = unknown> extends Loggable {
575
636
  newSelected: run.newSelected,
576
637
  // Compact detail projected off the full report so a persisted run is
577
638
  // self-explanatory once the in-memory ring buffer has rolled over.
578
- // Per-card provenance (`run.cards`) is intentionally left out — it's
579
- // the dominant memory cost and not worth persisting per run.
639
+ // Per-card provenance is the dominant cost, so it's kept only for the
640
+ // (at most two) `unselectedNew` cards, and only its score-changing
641
+ // entries. Everything else is ids and scores.
580
642
  ...(typeof run.userElo === 'number' ? { userElo: run.userElo } : {}),
581
643
  ...(run.generators ? { generators: run.generators } : {}),
582
644
  ...(run.filters ? { filters: run.filters } : {}),
583
645
  ...(run.hints ? { hints: run.hints } : {}),
584
646
  ...(run.discardedTail ? { discardedTail: run.discardedTail } : {}),
647
+ cards: persistedRunCards(run),
648
+ ...(run.unselectedNew ? { unselectedNew: persistedUnselectedNew(run.unselectedNew) } : {}),
649
+ ...(run.regulators ? { regulators: run.regulators.map(persistedReading) } : {}),
585
650
  });
586
651
  }
587
652
  }
@@ -1702,6 +1767,15 @@ export class SessionController<TView = unknown> extends Loggable {
1702
1767
  nextItem.score
1703
1768
  );
1704
1769
 
1770
+ // Tell the sources (a new card discharges a pipeline's intake valve).
1771
+ for (const source of this.sources) {
1772
+ source.notePresented?.({
1773
+ cardId: nextItem.cardID,
1774
+ courseId: nextItem.courseID,
1775
+ status: nextItem.status,
1776
+ });
1777
+ }
1778
+
1705
1779
  // Snapshot queue state
1706
1780
  snapshotQueues(this.supplyQ.length, this.failedQ.length);
1707
1781
 
@@ -403,14 +403,16 @@ function backlogHtml(backlog: SrsBacklogDebug[]): string {
403
403
  const multColor = b.backlogMultiplier <= 1 ? '#86efac' : hot ? '#fca5a5' : '#fcd34d';
404
404
  const headroom =
405
405
  b.backlogMultiplier > 1
406
- ? `climbing (×${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog}-review excess, unbounded)`
406
+ ? `climbing (×${b.backlogGrowthRate.toFixed(2)} per ${b.healthyBacklog} of mass in excess, unbounded)`
407
407
  : 'healthy — no pressure';
408
+ const mass =
409
+ b.reviewMass !== null ? ` · mass ${b.reviewMass.toFixed(1)}` : '';
408
410
  const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : '—';
409
411
  const next = b.nextDueIn ? ` <span style="opacity:.6">· next due ${esc(b.nextDueIn)}</span>` : '';
410
412
  return (
411
413
  `<div style="margin-left:6px">` +
412
414
  `<span style="opacity:.7">${esc(b.courseId.slice(0, 8))}</span> ` +
413
- `due ${b.dueNow}/${b.scheduledTotal} <span style="opacity:.6">(healthy ${b.healthyBacklog})</span>${next}` +
415
+ `due ${b.dueNow}/${b.scheduledTotal}${mass} <span style="opacity:.6">(healthy mass ${b.healthyBacklog})</span>${next}` +
414
416
  `<div style="margin-left:6px">` +
415
417
  `pressure <span style="color:${multColor}">×${b.backlogMultiplier.toFixed(2)}</span> ` +
416
418
  `<span style="opacity:.6">${headroom} · top review ${top}</span></div>` +
@@ -651,9 +653,10 @@ function snapshotToText(s: SessionDebugSnapshot | null): string {
651
653
  const headroom = b.backlogMultiplier > 1 ? 'climbing' : 'healthy';
652
654
  const top = b.topReviewScore !== null ? b.topReviewScore.toFixed(2) : '—';
653
655
  const next = b.nextDueIn ? `, next due ${b.nextDueIn}` : '';
656
+ const mass = b.reviewMass !== null ? `, mass ${b.reviewMass.toFixed(1)}` : '';
654
657
  lines.push(
655
- ` ${b.courseId.slice(0, 8)}: due ${b.dueNow}/${b.scheduledTotal} ` +
656
- `(healthy ${b.healthyBacklog})${next}; pressure ×${b.backlogMultiplier.toFixed(2)} ` +
658
+ ` ${b.courseId.slice(0, 8)}: due ${b.dueNow}/${b.scheduledTotal}${mass} ` +
659
+ `(healthy mass ${b.healthyBacklog})${next}; pressure ×${b.backlogMultiplier.toFixed(2)} ` +
657
660
  `${headroom}; top review ${top}`
658
661
  );
659
662
  }
@@ -185,7 +185,7 @@ describe('PipelineAssembler', () => {
185
185
  expect(result.generatorStrategies).toHaveLength(2);
186
186
  const strategyNames = result.generatorStrategies.map((s) => s.name).sort();
187
187
  expect(strategyNames).toEqual(['ELO (default)', 'SRS (default)']);
188
- expect(result.filterStrategies).toEqual([hierarchy]);
188
+ expect(result.filterStrategies.map((f) => f.name)).toEqual(['ELO Distance (default)', 'hierarchy']);
189
189
  expect(result.warnings).toEqual([]);
190
190
  });
191
191
  });
@@ -199,10 +199,18 @@ describe('PipelineAssembler', () => {
199
199
 
200
200
  expect(result.pipeline).toBeInstanceOf(Pipeline);
201
201
  // expect(result.generatorStrategies).toEqual([elo]); // default pipeline now includes srs+elo
202
- expect(result.filterStrategies).toEqual([hierarchy]);
202
+ expect(result.filterStrategies.map((f) => f.name)).toEqual(['ELO Distance (default)', 'hierarchy']);
203
203
  expect(result.warnings).toEqual([]);
204
204
  });
205
205
 
206
+ it('adds the default ELO distance filter only when the course declares none', async () => {
207
+ const own = createStrategy('own-elo-distance', 'eloDistance', '{"halfLife": 200}');
208
+ const input = createInput([own]);
209
+ const result = await assembler.assemble(input);
210
+
211
+ expect(result.filterStrategies).toEqual([own]);
212
+ });
213
+
206
214
  it('sorts filters alphabetically for deterministic ordering', async () => {
207
215
  const elo = createStrategy('elo', 'elo');
208
216
  const relativePriority = createStrategy(
@@ -230,6 +238,7 @@ describe('PipelineAssembler', () => {
230
238
  // Filters should be sorted alphabetically by name
231
239
  expect(result.filterStrategies.map((f) => f.name)).toEqual([
232
240
  'a-hierarchy',
241
+ 'ELO Distance (default)',
233
242
  'm-interference',
234
243
  'z-relative-priority',
235
244
  ]);
@@ -247,7 +256,7 @@ describe('PipelineAssembler', () => {
247
256
 
248
257
  expect(result.pipeline).toBeInstanceOf(Pipeline);
249
258
  // expect(result.generatorStrategies).toEqual([elo]); // default pipeline now includes srs+elo
250
- expect(result.filterStrategies).toEqual([hierarchy]);
259
+ expect(result.filterStrategies.map((f) => f.name)).toEqual(['ELO Distance (default)', 'hierarchy']);
251
260
  expect(result.warnings).toContain(
252
261
  "Unknown strategy type 'unknownStrategyType', skipping: unknown"
253
262
  );
@@ -266,8 +275,12 @@ describe('PipelineAssembler', () => {
266
275
  // Should have both generators
267
276
  // expect(result.generatorStrategies).toEqual([elo]);
268
277
 
269
- // Should have both filters (sorted alphabetically)
270
- expect(result.filterStrategies.map((f) => f.name)).toEqual(['hierarchy', 'priority']);
278
+ // Should have both filters plus the default ELO distance (sorted alphabetically)
279
+ expect(result.filterStrategies.map((f) => f.name)).toEqual([
280
+ 'ELO Distance (default)',
281
+ 'hierarchy',
282
+ 'priority',
283
+ ]);
271
284
 
272
285
  // Should produce a valid pipeline
273
286
  expect(result.pipeline).toBeInstanceOf(Pipeline);
@@ -291,11 +304,13 @@ describe('PipelineAssembler', () => {
291
304
  'a-filter',
292
305
  'b-filter',
293
306
  'c-filter',
307
+ 'ELO Distance (default)',
294
308
  ]);
295
309
  expect(result2.filterStrategies.map((f) => f.name)).toEqual([
296
310
  'a-filter',
297
311
  'b-filter',
298
312
  'c-filter',
313
+ 'ELO Distance (default)',
299
314
  ]);
300
315
  });
301
316
  });
@@ -63,27 +63,27 @@ describe('ELO Distance Filter', () => {
63
63
  expect(result[0].score).toBeCloseTo(1.0, 2);
64
64
  });
65
65
 
66
- it('should return ~0.6 multiplier at halfLife distance (200 ELO)', async () => {
66
+ it('should return ~0.4 multiplier at halfLife distance (300 ELO)', async () => {
67
67
  const filter = createEloDistanceFilter();
68
68
  const cards = [createCard('card-1', 1.0)];
69
- const context = createMockContext(1000, { 'card-1': 1200 }); // 200 distance
69
+ const context = createMockContext(1000, { 'card-1': 1300 }); // 300 distance
70
70
 
71
71
  const result = await filter.transform(cards, context);
72
72
 
73
73
  // At halfLife: minMultiplier + (maxMultiplier - minMultiplier) * exp(-1)
74
- // = 0.3 + 0.7 * 0.368 ≈ 0.56
75
- expect(result[0].score).toBeCloseTo(0.56, 1);
74
+ // = 0.05 + 0.95 * 0.368 ≈ 0.40
75
+ expect(result[0].score).toBeCloseTo(0.4, 1);
76
76
  });
77
77
 
78
78
  it('should approach minMultiplier for very large distances', async () => {
79
79
  const filter = createEloDistanceFilter();
80
80
  const cards = [createCard('card-1', 1.0)];
81
- const context = createMockContext(1000, { 'card-1': 2000 }); // 1000 distance (5x halfLife)
81
+ const context = createMockContext(1000, { 'card-1': 2000 }); // 1000 distance (3.3x halfLife)
82
82
 
83
83
  const result = await filter.transform(cards, context);
84
84
 
85
- // Should be very close to minMultiplier (0.3)
86
- expect(result[0].score).toBeCloseTo(0.3, 1);
85
+ // Should be very close to minMultiplier (0.05)
86
+ expect(result[0].score).toBeCloseTo(0.05, 2);
87
87
  });
88
88
 
89
89
  it('should be symmetric - same penalty above and below user ELO', async () => {
@@ -162,14 +162,14 @@ describe('ELO Distance Filter', () => {
162
162
 
163
163
  describe('custom configuration', () => {
164
164
  it('should use custom halfLife when provided', async () => {
165
- // With halfLife=100, distance 100 should give ~0.56 multiplier
165
+ // With halfLife=100, distance 100 should give ~0.4 multiplier
166
166
  const filter = createEloDistanceFilter({ halfLife: 100 });
167
167
  const cards = [createCard('card-1', 1.0)];
168
168
  const context = createMockContext(1000, { 'card-1': 1100 }); // 100 distance
169
169
 
170
170
  const result = await filter.transform(cards, context);
171
171
 
172
- expect(result[0].score).toBeCloseTo(0.56, 1);
172
+ expect(result[0].score).toBeCloseTo(0.4, 1);
173
173
  });
174
174
 
175
175
  it('should use custom min/max multipliers when provided', async () => {
package/tsup.config.ts CHANGED
@@ -8,6 +8,7 @@ export default defineConfig({
8
8
  'src/impl/couch/index.ts',
9
9
  'src/impl/static/index.ts',
10
10
  'src/util/packer/index.ts',
11
+ 'src/diagnostics/index.ts',
11
12
  ],
12
13
  format: ['cjs', 'esm'],
13
14
  dts: true,