Files
CatoandClaude Fable 5.2 070d317c88 Exercises: reviews in another form; situations ask the word that matters (#382)
* Owner check: why the owner pages do not open, for the person asking

The owner was named on the server and still got 404 on the numbers, with nothing to tell a missing sign-in from an unconfirmed address from a different address. /api/owner/check answers that about the caller only, and never says who the owner is.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r

* Exercises: a review comes back in another form

Simulated over twelve daily sittings, a learner who got everything right met 52 different questions in 96: half of every sitting was the identical question on its review day. What is due is the subject, so where the scope has a never-answered question about the same subject in a different form, that one takes the review's seat (Plan.reviewOf) and its answer moves the card that was due (recordAnswer, siblings), so a subject keeps one schedule. New questions also prefer subjects not met yet. After: 83 different questions in 96; with half the answers wrong, 48 subjects instead of 30.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r

* Situations: ask the word that matters, near-miss options, claims last

Reported from a phone on 2026-11-28 as useless: a heard line asked as a whole is read off its German cognates, with wrong options that are unrelated lines, or as a claim that is the German read back. Now the line is asked through its least German-looking pack word, in its sentence, with the pack's own four meanings (WordAsk; once per run; no cognates), else as three meanings whose wrong ones are near misses (negation out, day moved, number changed; German word tables with the packs), and as a claim only when neither is possible. Recorded against the line's own item, as pickOf is. Also: pagesFor for chat wayfinding, and no second printing of the German after a true claim.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r

* Situations: a right answer moves on by itself, as in a sitting

Reported from a phone: the situation run waited for «Wiiter» after a right answer while a sitting moved on by itself. The pulse and the beat lived inside Verdict; they are now useAnswered, used by both. Touching the answer holds it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-28 03:45:02 +01:00

103 lines
4.5 KiB
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { REVIEW_STEPS } from "../saved/review.ts";
import {
NO_MEMORY,
combineMemories,
comingBack,
decodeMemory,
dueCount,
scheduleAnswer,
urgency,
type Memory,
} from "./memory.ts";
const DAY = 86_400_000;
const now = new Date("2026-10-01T08:00:00Z");
const later = (days: number) => new Date(now.getTime() + days * DAY);
const q = { id: "transform:annas-sister", kind: "transform" } as const;
test("a right answer walks up the steps, a miss starts again", () => {
let memory: Memory = scheduleAnswer(NO_MEMORY, q, "right", now);
assert.equal(memory[q.id]!.step, 0);
assert.equal(memory[q.id]!.due, now.getTime() + REVIEW_STEPS[0] * DAY);
memory = scheduleAnswer(memory, q, "right", later(1));
memory = scheduleAnswer(memory, q, "right", later(4));
assert.equal(memory[q.id]!.step, 2);
memory = scheduleAnswer(memory, q, "wrong", later(11));
assert.equal(memory[q.id]!.step, 0);
assert.equal(memory[q.id]!.lapses, 1);
assert.equal(memory[q.id]!.due, later(12).getTime());
});
test("at the last step it keeps coming back instead of vanishing", () => {
let memory: Memory = NO_MEMORY;
for (let i = 0; i < REVIEW_STEPS.length + 3; i++) memory = scheduleAnswer(memory, q, "right", later(i * 40));
assert.equal(memory[q.id]!.step, REVIEW_STEPS.length - 1);
assert.ok(Number.isFinite(memory[q.id]!.due));
});
test("a skip and a kept word change nothing", () => {
assert.equal(scheduleAnswer(NO_MEMORY, q, "skipped", now), NO_MEMORY);
assert.equal(scheduleAnswer(NO_MEMORY, { id: "recall:gäll", kind: "recall" }, "right", now), NO_MEMORY);
});
test("due, new and resting", () => {
const memory = scheduleAnswer(NO_MEMORY, q, "right", now);
assert.equal(urgency(memory, "never:asked", now), 1);
assert.equal(urgency(memory, q.id, now), 2);
assert.equal(urgency(memory, q.id, later(1)), 0);
assert.equal(dueCount(memory, now), 0);
assert.equal(dueCount(memory, later(1)), 1);
assert.equal(dueCount(memory, later(1), ["other"]), 0);
assert.equal(comingBack(memory, now, 1), 1);
});
test("across devices, the newest answer of each question wins", () => {
const phone = scheduleAnswer(NO_MEMORY, q, "right", now);
const laptop = scheduleAnswer(scheduleAnswer(NO_MEMORY, q, "right", later(-2)), q, "wrong", later(1));
const both = combineMemories([phone, laptop]);
assert.equal(both[q.id]!.lapses, 1);
assert.deepEqual(combineMemories([laptop, phone]), both);
});
test("the decoder keeps good cards and refuses what is not a memory", () => {
assert.equal(decodeMemory("[]"), null);
assert.equal(decodeMemory("nope"), null);
const decoded = decodeMemory(
JSON.stringify({ ok: { step: 99, due: 5, seen: 4, lapses: 0 }, bad: { step: "1" }, neg: { step: 0, due: -1, seen: 0, lapses: 0 } }),
);
assert.deepEqual(Object.keys(decoded!), ["ok"]);
assert.equal(decoded!.ok!.step, REVIEW_STEPS.length - 1);
});
test("a sitting shares its seats between what is due and what is new, and leaves resting questions alone", async () => {
const { PACK_ITEMS } = await import("./published.ts");
const { orderSession } = await import("./session.ts");
const translate = PACK_ITEMS.filter((i) => i.kind === "translate").slice(0, 10);
const resting = PACK_ITEMS.filter((i) => i.kind === "cloze").slice(0, 30);
let memory: Memory = NO_MEMORY;
for (const item of translate) memory = scheduleAnswer(memory, item, "right", later(-2));
for (const item of resting) memory = scheduleAnswer(memory, item, "right", now);
const { planSession } = await import("./session.ts");
const planned = planSession({ items: PACK_ITEMS, saved: [], now, memory, size: 8 });
const session = planned.items;
// Ten due questions of ONE kind take every review seat, not one of them —
// and the review seats are the sitting less its share of new questions.
// Counted by the card that was due: a review may sit in another form.
const { NEW_SHARE } = await import("./session.ts");
const dueCards = planned.due.map((id) => planned.reviewOf[id] ?? id);
assert.equal(dueCards.filter((id) => translate.some((t) => t.id === id)).length, 8 - Math.round(8 * NEW_SHARE));
assert.equal(session.length, 8);
// A day and a half earlier nothing is due yet: every answered question is
// resting, and new ones fill the sitting.
const noDue = orderSession({ items: PACK_ITEMS, saved: [], now: later(-1.5), memory, size: 8 });
const answered = new Set(Object.keys(memory));
assert.ok(!noDue.some((i) => answered.has(i.id)), "a resting question waits while new ones remain");
});