0xBUFF / retention

Getting started

Install Retention and calculate your first due review.

Install Retention and calculate when a concept is due for another review. This example uses practice observations and an explicit clock, so it needs no database or external service.

Installation

Retention requires Node.js 24 or later and ECMAScript modules (ESM). TypeScript declarations are included. Browser applications can use the ESM entry in an ES2022-compatible environment with a bundler or import map.

npm install @0xbuff/retention

Pin a tested package version for deployments.

Agent skill

Install the Retention skill to help coding agents configure review policies, replay learning history, rank due reviews and evaluate candidate readiness using the supported API.

npx skills add 0xbuffdev/skills --skill retention

Quick start

Save this example as review.mjs. It records a successful retrieval at Unix time zero (midnight UTC on January 1, 1970), then evaluates the schedule one day later. The intervals are illustrative policy values; choose the intervals that suit your application.

// retention-docs: runnable
import { rebuildReview, scheduleDue } from "@0xbuff/retention";

const day = 86_400_000;
const policy = {
  schemaVersion: 1,
  algorithmVersion: "1",
  policyId: "deck",
  policyVersion: "v1",
  scheduling: {
    intervalsDays: [1, 3, 7],
    retryDays: 1,
    maintenanceDays: 30,
    supportAfterMisses: 2,
    longProbeAction: "restart",
    dateArithmetic: "elapsed_milliseconds",
  },
};

const event = {
  schemaVersion: 1,
  kind: "practice_observation",
  scopeId: "deck",
  conceptId: "binary-search",
  eventId: "review-1",
  sequence: 0,
  atMs: 0,
  sessionId: "session-1",
  outcome: "pass",
};

function value(result) {
  if (!result.ok) throw new Error(JSON.stringify(result.errors));
  return result.value;
}

const review = value(rebuildReview(policy, "deck", [event], day));
const due = value(scheduleDue(policy, "deck", review, day));
console.log(due[0].conceptId, due[0].dueAtMs, due[0].recommendationKind);
node review.mjs

Expected output:

binary-search 86400000 ordinary

The first pass schedules the next review one elapsed day later, at 86,400,000 milliseconds. At that instant, the concept enters the due queue with an ordinary recommendation. Both operations use the supplied clock; no eligibility policy is needed.

Next steps

On this page