Candidate readiness
Evaluate advisory readiness from independently admitted credited retrievals.
Candidate readiness uses the optional eligibility policy. A practice pass affects the practice schedule. It never counts toward eligibility, even if it includes freshness and hint metadata. The host admits credited retrievals independently of Retention.
Qualification
A surviving credited pass qualifies if its eligibility policy version matches, its freshness meets the policy, and its hints and ladder meet the thresholds. A matching-version failure uses onFailure. A version mismatch or a nonqualifying pass uses onNonqualifying. Either action can reset the streak or ignore the observation.
A reset clears the qualifying success count, the set of distinct sessions and the timestamps of the first and last qualifying successes. The qualifying span measures the time between the first and last qualifying successes. Waiting alone cannot increase that span.
| Readiness | Meaning |
|---|---|
| unknown | No active credited observations. |
| developing | Credited observations exist, but one or more thresholds are unmet. |
| candidate_ready | Success count, distinct sessions and qualifying span all meet the policy. |
With no eligibility policy, rebuild omits the candidate field and evaluateReadiness returns a successful null after validating and reconciling the input.
Example with admitted evidence
The following synthetic records illustrate the contract. In an application, create these records only after your independent admission process has accepted the evidence.
// retention-docs: runnable
import { evaluateReadiness } 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 eligible = {
...policy,
eligibility: {
eligibilityPolicyVersion: "v1",
minSuccesses: 2,
minSessions: 2,
minSpanMs: day,
requireFresh: true,
maxHints: 0,
minLadder: 3,
onFailure: "reset",
onNonqualifying: "ignore",
},
};
function credited(sequence, atMs) {
return {
...event,
kind: "eligible_credited_retrieval",
sequence,
atMs,
eventId: "credit-" + sequence,
sessionId: "credited-session-" + sequence,
creditDecisionId: "decision-" + sequence,
decisionVersion: 1,
eligibilityPolicyVersion: "v1",
fresh: true,
hints: 0,
ladder: 3,
};
}
const first = credited(1, day);
const second = credited(2, 2 * day);
const before = value(evaluateReadiness(eligible, "deck", "binary-search", [event, first], 2 * day));
const after = value(evaluateReadiness(eligible, "deck", "binary-search", [event, first, second], 2 * day));
console.log(before.readiness, before.qualifyingSuccesses, after.readiness, after.qualifyingSuccesses);Expected output:
developing 1 candidate_ready 2A corrected decision replaces evidence at its original effective time; a revocation or deletion can remove a success and change the candidate result. Always reconcile the complete scope, including controls. Retention cannot verify the authenticity of a credited tag or decide official mastery. See history replay and integration.