@vue-skuilder/db 0.3.2 → 0.3.3
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/core/index.cjs.map +1 -1
- package/dist/core/navigators/filters/eloDistance.mjs.map +1 -1
- package/dist/core/navigators/generators/prescribed.mjs.map +1 -1
- package/dist/core/versionStamps.mjs +1 -1
- package/dist/diagnostics/derive.mjs.map +1 -1
- package/dist/diagnostics/index.cjs +16 -3
- package/dist/diagnostics/index.cjs.map +1 -1
- package/dist/diagnostics/index.d.ts +27 -4
- package/dist/diagnostics/tagElo.mjs +20 -4
- package/dist/diagnostics/tagElo.mjs.map +1 -1
- package/dist/impl/couch/index.cjs.map +1 -1
- package/dist/impl/static/index.cjs.map +1 -1
- package/dist/index.cjs +8 -2
- package/dist/index.cjs.map +1 -1
- package/dist/study/services/tagRecent.mjs +2 -1
- package/dist/study/services/tagRecent.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/navigators/filters/eloDistance.ts +2 -2
- package/src/core/navigators/generators/prescribed.ts +5 -6
- package/src/diagnostics/derive.ts +6 -1
- package/src/diagnostics/tagElo.ts +43 -3
- package/src/study/services/tagRecent.test.ts +57 -3
- package/src/study/services/tagRecent.ts +8 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
-
import { pushTagPresentation } from "@vue-skuilder/common";
|
|
2
|
+
import { TAG_OK_MIN_PERF, pushTagPresentation } from "@vue-skuilder/common";
|
|
3
3
|
//#region src/study/services/tagRecent.ts
|
|
4
4
|
/**
|
|
5
5
|
* Mastery signal: per-tag ring buffer of recent presentations.
|
|
@@ -51,6 +51,7 @@ function recordTagPresentations(userElo, perf, records, cardId, at) {
|
|
|
51
51
|
const entry = {
|
|
52
52
|
at,
|
|
53
53
|
ok,
|
|
54
|
+
tagOk: score > TAG_OK_MIN_PERF,
|
|
54
55
|
perf: score,
|
|
55
56
|
card: cardId
|
|
56
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tagRecent.mjs","names":[],"sources":["../../../src/study/services/tagRecent.ts"],"sourcesContent":["import {\n CourseElo,\n EloRank,\n TaggedPerformance,\n TagPresentation,\n pushTagPresentation,\n} from '@vue-skuilder/common';\nimport { CardRecord } from '@db/core';\n\n/**\n * Mastery signal: per-tag ring buffer of recent presentations.\n *\n * Written on the same path as the per-tag ELO update, one entry per\n * *presentation* of a card. Retries within a presentation (a record with\n * `priorAttemps > 0`, or any record after the first on the current card)\n * are not evidence and add nothing — including the \"dismiss-failed\" final\n * penalty, which reaches the ELO path on a retry record.\n *\n * Only tags the question actually graded (numeric perf) get an entry;\n * count-only exposure tags (`null`) carry no correctness signal.\n */\n\n/** The record for the presentation being graded, or null if none is visible. */\nfunction currentRecord(records: readonly CardRecord[]): CardRecord | null {\n return records.length ? records[records.length - 1] : null;\n}\n\n/**\n * Whether the record under grading is the first attempt of its presentation.\n *\n * `priorAttemps` is the authoritative marker (written by the question view).\n * When it is absent (non-question records, or a caller that did not push the\n * record onto `currentCard.records`), fall back to the presentation's record\n * count. With no record visible at all we cannot tell, and say no.\n */\nexport function isFirstAttempt(records: readonly CardRecord[]): boolean {\n const rec = currentRecord(records);\n if (!rec) return false;\n const prior = (rec as { priorAttemps?: unknown }).priorAttemps;\n if (typeof prior === 'number') return prior === 0;\n return records.length === 1;\n}\n\n/**\n * Append a presentation entry to every scored tag in `perf`, mutating\n * `userElo.tags[tag]` in place (each rank object is replaced, not mutated).\n * No-op for retries. Returns the tags that received an entry.\n */\nexport function recordTagPresentations(\n userElo: CourseElo,\n perf: TaggedPerformance,\n records: readonly CardRecord[],\n cardId: string,\n at: string\n): string[] {\n if (!isFirstAttempt(records)) return [];\n const rec = currentRecord(records) as { isCorrect?: unknown } | null;\n const ok = rec?.isCorrect === true;\n\n const written: string[] = [];\n for (const [tag, score] of Object.entries(perf)) {\n if (tag === '_global') continue;\n if (typeof score !== 'number') continue; // count-only exposure tag\n const rank: EloRank = userElo.tags[tag] ?? { score: userElo.global.score, count: 0 };\n const entry: TagPresentation = {
|
|
1
|
+
{"version":3,"file":"tagRecent.mjs","names":[],"sources":["../../../src/study/services/tagRecent.ts"],"sourcesContent":["import {\n CourseElo,\n EloRank,\n TAG_OK_MIN_PERF,\n TaggedPerformance,\n TagPresentation,\n pushTagPresentation,\n} from '@vue-skuilder/common';\nimport { CardRecord } from '@db/core';\n\n/**\n * Mastery signal: per-tag ring buffer of recent presentations.\n *\n * Written on the same path as the per-tag ELO update, one entry per\n * *presentation* of a card. Retries within a presentation (a record with\n * `priorAttemps > 0`, or any record after the first on the current card)\n * are not evidence and add nothing — including the \"dismiss-failed\" final\n * penalty, which reaches the ELO path on a retry record.\n *\n * Only tags the question actually graded (numeric perf) get an entry;\n * count-only exposure tags (`null`) carry no correctness signal.\n */\n\n/** The record for the presentation being graded, or null if none is visible. */\nfunction currentRecord(records: readonly CardRecord[]): CardRecord | null {\n return records.length ? records[records.length - 1] : null;\n}\n\n/**\n * Whether the record under grading is the first attempt of its presentation.\n *\n * `priorAttemps` is the authoritative marker (written by the question view).\n * When it is absent (non-question records, or a caller that did not push the\n * record onto `currentCard.records`), fall back to the presentation's record\n * count. With no record visible at all we cannot tell, and say no.\n */\nexport function isFirstAttempt(records: readonly CardRecord[]): boolean {\n const rec = currentRecord(records);\n if (!rec) return false;\n const prior = (rec as { priorAttemps?: unknown }).priorAttemps;\n if (typeof prior === 'number') return prior === 0;\n return records.length === 1;\n}\n\n/**\n * Append a presentation entry to every scored tag in `perf`, mutating\n * `userElo.tags[tag]` in place (each rank object is replaced, not mutated).\n * No-op for retries. Returns the tags that received an entry.\n */\nexport function recordTagPresentations(\n userElo: CourseElo,\n perf: TaggedPerformance,\n records: readonly CardRecord[],\n cardId: string,\n at: string\n): string[] {\n if (!isFirstAttempt(records)) return [];\n const rec = currentRecord(records) as { isCorrect?: unknown } | null;\n const ok = rec?.isCorrect === true;\n\n const written: string[] = [];\n for (const [tag, score] of Object.entries(perf)) {\n if (tag === '_global') continue;\n if (typeof score !== 'number') continue; // count-only exposure tag\n const rank: EloRank = userElo.tags[tag] ?? { score: userElo.global.score, count: 0 };\n const entry: TagPresentation = {\n at,\n ok,\n tagOk: score > TAG_OK_MIN_PERF,\n perf: score,\n card: cardId,\n };\n userElo.tags[tag] = pushTagPresentation(rank, entry);\n written.push(tag);\n }\n return written;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,SAAS,cAAc,SAAmD;AACxE,QAAO,QAAQ,SAAS,QAAQ,QAAQ,SAAS,KAAK;;;;;;;;;;AAWxD,SAAgB,eAAe,SAAyC;CACtE,MAAM,MAAM,cAAc,QAAQ;AAClC,KAAI,CAAC,IAAK,QAAO;CACjB,MAAM,QAAS,IAAmC;AAClD,KAAI,OAAO,UAAU,SAAU,QAAO,UAAU;AAChD,QAAO,QAAQ,WAAW;;;;;;;AAQ5B,SAAgB,uBACd,SACA,MACA,SACA,QACA,IACU;AACV,KAAI,CAAC,eAAe,QAAQ,CAAE,QAAO,EAAE;CAEvC,MAAM,KADM,cAAc,QAAQ,EAClB,cAAc;CAE9B,MAAM,UAAoB,EAAE;AAC5B,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,EAAE;AAC/C,MAAI,QAAQ,UAAW;AACvB,MAAI,OAAO,UAAU,SAAU;EAC/B,MAAM,OAAgB,QAAQ,KAAK,QAAQ;GAAE,OAAO,QAAQ,OAAO;GAAO,OAAO;GAAG;EACpF,MAAM,QAAyB;GAC7B;GACA;GACA,OAAO,QAAQ;GACf,MAAM;GACN,MAAM;GACP;AACD,UAAQ,KAAK,OAAO,oBAAoB,MAAM,MAAM;AACpD,UAAQ,KAAK,IAAI;;AAEnB,QAAO"}
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
|
-
"version": "0.3.
|
|
16
|
+
"version": "0.3.3",
|
|
17
17
|
"description": "Database layer for vue-skuilder",
|
|
18
18
|
"main": "dist/index.cjs",
|
|
19
19
|
"module": "dist/index.mjs",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@nilock2/pouchdb-authentication": "^1.0.2",
|
|
72
|
-
"@vue-skuilder/common": "0.3.
|
|
72
|
+
"@vue-skuilder/common": "0.3.3",
|
|
73
73
|
"cross-fetch": "^4.1.0",
|
|
74
74
|
"moment": "^2.29.4",
|
|
75
75
|
"pouchdb": "^9.0.0",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"vite": "^8.0.0",
|
|
88
88
|
"vitest": "^4.1.0"
|
|
89
89
|
},
|
|
90
|
-
"stableVersion": "0.3.
|
|
90
|
+
"stableVersion": "0.3.3"
|
|
91
91
|
}
|
|
@@ -35,8 +35,8 @@ import { logger } from '../../../util/logger';
|
|
|
35
35
|
//
|
|
36
36
|
// Intro cards pass through untouched. They carry an `intro`-role tag, grade
|
|
37
37
|
// nothing, and their ELO is a placeholder, so a distance on it means nothing.
|
|
38
|
-
// Penalising them
|
|
39
|
-
//
|
|
38
|
+
// Penalising them starves established learners of intros: a learner rated
|
|
39
|
+
// well above the placeholder sees every intro at the curve's floor.
|
|
40
40
|
//
|
|
41
41
|
// A `signal`, not a gate: it expresses preference, not readiness. `liveOnly`:
|
|
42
42
|
// forecasts and card-space scans start every card at 1.0 without a generator,
|
|
@@ -35,16 +35,15 @@ import { logger } from '@db/util/logger';
|
|
|
35
35
|
//
|
|
36
36
|
// KNOWN LATENT BUG (2026-11-17): this generator decides targets, support,
|
|
37
37
|
// boost hints and pressure *before* the gates run, and knows nothing about
|
|
38
|
-
// them. It will target and support cards a gate is certain to block (
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
//
|
|
38
|
+
// them. It will target and support cards a gate is certain to block (e.g. a
|
|
39
|
+
// target whose prerequisites sit behind a course gate that never opens), so
|
|
40
|
+
// the group can never complete. Harmless while every such card stays gated;
|
|
41
|
+
// but staleness escalates the support boost hint to its cap on those tags,
|
|
42
42
|
// so the day one becomes ungated it gets that boost at once (a pressure
|
|
43
43
|
// mania). Proposed fix: Pipeline offers generators the gate-kind filters
|
|
44
44
|
// (e.g. `context.gate(cardIds)`), and prescribed treats gated candidates as
|
|
45
45
|
// blocked: not emitted, not boosted, not escalating. That would also replace
|
|
46
|
-
// this file's own hierarchy walk.
|
|
47
|
-
// (Watch: "Prescribed targets gated cards").
|
|
46
|
+
// this file's own hierarchy walk.
|
|
48
47
|
//
|
|
49
48
|
// ============================================================================
|
|
50
49
|
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
StudySessionRunSummary,
|
|
14
14
|
} from '../core/types/studySession';
|
|
15
15
|
import type { CardSummary, DatasetRecord, LearnerDataset } from './dataset';
|
|
16
|
-
import type { TagBatch } from './tagElo';
|
|
16
|
+
import type { TagBatch, TagEloViewOptions } from './tagElo';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Course-supplied meaning for the generic views. Every member is optional and
|
|
@@ -36,6 +36,11 @@ export interface DiagnosticsInterpreters {
|
|
|
36
36
|
* batches it finds on its own. Default: none.
|
|
37
37
|
*/
|
|
38
38
|
tagBatches?: TagBatch[];
|
|
39
|
+
/**
|
|
40
|
+
* How the ELO view reads skills: which tags security and need consider, and
|
|
41
|
+
* their thresholds. Default: exercise-role tags, framework thresholds.
|
|
42
|
+
*/
|
|
43
|
+
tagEloOptions?: TagEloViewOptions;
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
export const isSkillTag = (i: DiagnosticsInterpreters | undefined, tag: string): boolean =>
|
|
@@ -10,9 +10,17 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import {
|
|
12
12
|
COUNT_ONLY_SCORE,
|
|
13
|
+
courseSecurity,
|
|
13
14
|
isCountOnlyTag,
|
|
15
|
+
presentationOk,
|
|
16
|
+
skillNeed,
|
|
14
17
|
tagRole,
|
|
15
18
|
type CourseElo,
|
|
19
|
+
type CourseSecurity,
|
|
20
|
+
type SkillNeedConfig,
|
|
21
|
+
type TagSecurity,
|
|
22
|
+
type TagSecurityConfig,
|
|
23
|
+
type TagSelector,
|
|
16
24
|
type EloRank,
|
|
17
25
|
type TagPresentation,
|
|
18
26
|
type TagRole,
|
|
@@ -104,8 +112,14 @@ export interface TagEloRow {
|
|
|
104
112
|
vsGlobal: number | null;
|
|
105
113
|
/** The rating's ring buffer of recent first attempts, oldest first. */
|
|
106
114
|
recent: TagPresentation[];
|
|
107
|
-
/**
|
|
115
|
+
/** Entries in `recent` right on this tag (per-tag, not the card's ok). */
|
|
108
116
|
recentOk: number;
|
|
117
|
+
/** Secure / shaky / unproven, for tags the security selector picks (met exercise tags by default). */
|
|
118
|
+
security?: TagSecurity;
|
|
119
|
+
/** 0–1 need from skillNeed; absent for tags that don't qualify as skills. */
|
|
120
|
+
need?: number;
|
|
121
|
+
/** Skill reference − rating; absent with need. */
|
|
122
|
+
deficit?: number;
|
|
109
123
|
/** First and last response whose per-tag performance named the tag, or a recent entry. */
|
|
110
124
|
firstSeen: string | null;
|
|
111
125
|
lastSeen: string | null;
|
|
@@ -134,6 +148,16 @@ export interface TagEloView {
|
|
|
134
148
|
series: { global: EloPoint[]; tags: Record<string, EloPoint[]> };
|
|
135
149
|
/** The first ELO event, or null: trajectories start here. */
|
|
136
150
|
seriesFrom: string | null;
|
|
151
|
+
/** Median rating over the learner's qualifying skills (skillNeed); null if too few. */
|
|
152
|
+
skillReference: number | null;
|
|
153
|
+
/** Security totals over the selected tags. */
|
|
154
|
+
security: Omit<CourseSecurity, 'tags'>;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** How the view reads skills: a course may pass its own selectors and thresholds. */
|
|
158
|
+
export interface TagEloViewOptions {
|
|
159
|
+
security?: { selector?: TagSelector; config?: TagSecurityConfig };
|
|
160
|
+
need?: SkillNeedConfig;
|
|
137
161
|
}
|
|
138
162
|
|
|
139
163
|
/** The learner's `CourseElo` for the dataset's course, or null if not registered. */
|
|
@@ -164,10 +188,15 @@ function step(line: EloPoint[], at: string, before: number, after: number): void
|
|
|
164
188
|
}
|
|
165
189
|
|
|
166
190
|
/** The learner's per-tag ELO for display. Null if the dataset has no registration for its course. */
|
|
167
|
-
export function tagEloView(ds: LearnerDataset): TagEloView | null {
|
|
191
|
+
export function tagEloView(ds: LearnerDataset, options: TagEloViewOptions = {}): TagEloView | null {
|
|
168
192
|
const elo = learnerCourseElo(ds);
|
|
169
193
|
if (!elo) return null;
|
|
170
194
|
|
|
195
|
+
const security = courseSecurity(elo, options.security);
|
|
196
|
+
const securityByTag = new Map(security.tags.map((s) => [s.tag, s]));
|
|
197
|
+
const need = skillNeed(elo, options.need);
|
|
198
|
+
const needByTag = new Map(need.skills.map((s) => [s.tag, s]));
|
|
199
|
+
|
|
171
200
|
// When each tag was named by a response, from card history.
|
|
172
201
|
const seen = new Map<string, { first: string | null; last: string | null }>();
|
|
173
202
|
for (const h of ds.cardHistories) {
|
|
@@ -220,7 +249,11 @@ export function tagEloView(ds: LearnerDataset): TagEloView | null {
|
|
|
220
249
|
count: rank.count,
|
|
221
250
|
vsGlobal: score === null ? null : score - elo.global.score,
|
|
222
251
|
recent,
|
|
223
|
-
recentOk: recent.filter(
|
|
252
|
+
recentOk: recent.filter(presentationOk).length,
|
|
253
|
+
...(securityByTag.has(tag) ? { security: securityByTag.get(tag) } : {}),
|
|
254
|
+
...(needByTag.has(tag)
|
|
255
|
+
? { need: needByTag.get(tag)!.need, deficit: needByTag.get(tag)!.deficit }
|
|
256
|
+
: {}),
|
|
224
257
|
firstSeen: first,
|
|
225
258
|
lastSeen: last,
|
|
226
259
|
events: eventCounts.get(tag) ?? 0,
|
|
@@ -253,5 +286,12 @@ export function tagEloView(ds: LearnerDataset): TagEloView | null {
|
|
|
253
286
|
),
|
|
254
287
|
series: { global: globalSeries, tags: tagSeries },
|
|
255
288
|
seriesFrom: events[0]?.at ?? null,
|
|
289
|
+
skillReference: need.reference,
|
|
290
|
+
security: {
|
|
291
|
+
secure: security.secure,
|
|
292
|
+
shaky: security.shaky,
|
|
293
|
+
unproven: security.unproven,
|
|
294
|
+
debt: security.debt,
|
|
295
|
+
},
|
|
256
296
|
};
|
|
257
297
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
TAG_RECENT_MAX,
|
|
4
|
+
courseSecurity,
|
|
5
|
+
pushTagPresentation,
|
|
6
|
+
tagSecurity,
|
|
7
|
+
type CourseElo,
|
|
8
|
+
type EloRank,
|
|
9
|
+
} from '@vue-skuilder/common';
|
|
3
10
|
import { isFirstAttempt, recordTagPresentations } from './tagRecent';
|
|
4
11
|
import type { CardRecord } from '@db/core';
|
|
5
12
|
|
|
@@ -61,7 +68,7 @@ describe('recordTagPresentations', () => {
|
|
|
61
68
|
);
|
|
62
69
|
expect(written).toEqual(['gpc:exercise:th-TH']);
|
|
63
70
|
expect(elo.tags['gpc:exercise:th-TH'].recent).toEqual([
|
|
64
|
-
{ at: '2026-09-18T00:00:00.000Z', ok: true, perf: 0.6, card: 'c-ml-worth-3' },
|
|
71
|
+
{ at: '2026-09-18T00:00:00.000Z', ok: true, tagOk: true, perf: 0.6, card: 'c-ml-worth-3' },
|
|
65
72
|
]);
|
|
66
73
|
expect(elo.tags['gpc:expose:w-W']).toBeUndefined();
|
|
67
74
|
});
|
|
@@ -69,7 +76,7 @@ describe('recordTagPresentations', () => {
|
|
|
69
76
|
it('records a first-attempt miss as ok:false', () => {
|
|
70
77
|
const elo = blank();
|
|
71
78
|
recordTagPresentations(elo, { _global: 0, 'gpc:exercise:sh-SH': 0 }, [rec(0, false)], 'c-ml-hush-2', 't');
|
|
72
|
-
expect(elo.tags['gpc:exercise:sh-SH'].recent).toEqual([{ at: 't', ok: false, perf: 0, card: 'c-ml-hush-2' }]);
|
|
79
|
+
expect(elo.tags['gpc:exercise:sh-SH'].recent).toEqual([{ at: 't', ok: false, tagOk: false, perf: 0, card: 'c-ml-hush-2' }]);
|
|
73
80
|
});
|
|
74
81
|
|
|
75
82
|
it('adds nothing for a retry (priorAttemps > 0), even a correct one', () => {
|
|
@@ -99,3 +106,50 @@ describe('recordTagPresentations', () => {
|
|
|
99
106
|
expect(elo.tags['t'].recent![0].card).toBe('card-3');
|
|
100
107
|
});
|
|
101
108
|
});
|
|
109
|
+
|
|
110
|
+
describe('tagSecurity', () => {
|
|
111
|
+
const day = (d: number) => `2026-11-${String(d).padStart(2, '0')}T12:00:00.000Z`;
|
|
112
|
+
const rank = (oks: boolean[], days: number[]): EloRank => ({
|
|
113
|
+
score: 1500,
|
|
114
|
+
count: oks.length,
|
|
115
|
+
recent: oks.map((ok, i) => ({ at: day(days[i]), ok: true, tagOk: ok, perf: ok ? 0.8 : 0, card: `c${i}` })),
|
|
116
|
+
});
|
|
117
|
+
const cfg = { dayOf: (at: string) => at.slice(0, 10) };
|
|
118
|
+
|
|
119
|
+
it('unproven below minAttempts, shaky under 75% of the window, secure otherwise', () => {
|
|
120
|
+
const five = Array(5).fill(true);
|
|
121
|
+
expect(tagSecurity('t', rank(five, [1, 1, 2, 2, 3]), cfg).status).toBe('unproven');
|
|
122
|
+
// 12 attempts, 8 right (67%): shaky; the card-level ok (all true) is ignored
|
|
123
|
+
const eightOfTwelve = [...Array(8).fill(true), ...Array(4).fill(false)];
|
|
124
|
+
expect(tagSecurity('t', rank(eightOfTwelve, Array(12).fill(0).map((_, i) => 1 + (i % 3))), cfg).status).toBe('shaky');
|
|
125
|
+
// 6 of 6 right, all on one day: unproven (needs two days)
|
|
126
|
+
expect(tagSecurity('t', rank(Array(6).fill(true), Array(6).fill(4)), cfg).status).toBe('unproven');
|
|
127
|
+
expect(tagSecurity('t', rank(Array(6).fill(true), [4, 4, 4, 5, 5, 5]), cfg).status).toBe('secure');
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('falls back to perf for entries without tagOk (hinted 0.5 is not right)', () => {
|
|
131
|
+
const r: EloRank = {
|
|
132
|
+
score: 1500,
|
|
133
|
+
count: 6,
|
|
134
|
+
recent: [0.6, 0.8, 0.5, 0.8, 0.8, 0.8].map((perf, i) => ({ at: day(1 + (i % 2)), ok: true, perf, card: `c${i}` })),
|
|
135
|
+
};
|
|
136
|
+
const s = tagSecurity('t', r, cfg);
|
|
137
|
+
expect(s.right).toBe(5);
|
|
138
|
+
expect(s.status).toBe('secure');
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('courseSecurity counts met exercise tags only; a met tag with no buffer is unproven', () => {
|
|
142
|
+
const elo: CourseElo = {
|
|
143
|
+
global: { score: 1500, count: 100 },
|
|
144
|
+
tags: {
|
|
145
|
+
'gpc:exercise:a-AE': rank(Array(6).fill(true), [1, 1, 1, 2, 2, 2]),
|
|
146
|
+
'gpc:exercise:a-EY': { score: 1300, count: 9 },
|
|
147
|
+
'gpc:expose:a-AE': { score: -1, count: 4 },
|
|
148
|
+
},
|
|
149
|
+
misc: {},
|
|
150
|
+
};
|
|
151
|
+
const c = courseSecurity(elo, { config: cfg });
|
|
152
|
+
expect(c.tags.map((t) => t.tag).sort()).toEqual(['gpc:exercise:a-AE', 'gpc:exercise:a-EY']);
|
|
153
|
+
expect([c.secure, c.shaky, c.unproven, c.debt]).toEqual([1, 0, 1, 1]);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CourseElo,
|
|
3
3
|
EloRank,
|
|
4
|
+
TAG_OK_MIN_PERF,
|
|
4
5
|
TaggedPerformance,
|
|
5
6
|
TagPresentation,
|
|
6
7
|
pushTagPresentation,
|
|
@@ -62,7 +63,13 @@ export function recordTagPresentations(
|
|
|
62
63
|
if (tag === '_global') continue;
|
|
63
64
|
if (typeof score !== 'number') continue; // count-only exposure tag
|
|
64
65
|
const rank: EloRank = userElo.tags[tag] ?? { score: userElo.global.score, count: 0 };
|
|
65
|
-
const entry: TagPresentation = {
|
|
66
|
+
const entry: TagPresentation = {
|
|
67
|
+
at,
|
|
68
|
+
ok,
|
|
69
|
+
tagOk: score > TAG_OK_MIN_PERF,
|
|
70
|
+
perf: score,
|
|
71
|
+
card: cardId,
|
|
72
|
+
};
|
|
66
73
|
userElo.tags[tag] = pushTagPresentation(rank, entry);
|
|
67
74
|
written.push(tag);
|
|
68
75
|
}
|