Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): completion-gate review pass, honor refresh delay, filter runnable reps before cap

Adam Eivyf81316386a05
diff --git a/server/services/meatspacePost.js b/server/services/meatspacePost.js
index 2ad4a7b508..952bc19b24 100644
--- a/server/services/meatspacePost.js
+++ b/server/services/meatspacePost.js
@@ -309,6 +309,11 @@ export async function submitPostSession(sessionData) {
// SKILL RE-VERIFICATION (issue #2096) — mastered-skill review scheduling
// =============================================================================
+// A maintenance-review rep must reach at least this fraction of its questions to
+// count as a genuine re-verification (mirrors COGNITIVE_MASTERY_DEFAULTS
+// minCompletion). Below it, the review is recorded as failed rather than passed.
+const MIN_REVIEW_COMPLETION = 0.75;
+
/**
* Current mastered-but-inactive skills eligible for re-verification tracking:
* - multiplication rungs strictly BELOW the resolved current level (you've
@@ -388,8 +393,17 @@ export function getSessionSkillContext(session) {
for (const task of session?.tasks || []) {
const cfg = task.config || {};
if (cfg.reviewSkillId) {
+ // A review passes only when it's both accurate AND sufficiently completed:
+ // accuracy is answered-only, so without the completion gate answering one
+ // question correctly and skipping the rest would bank a "pass" (acc===1)
+ // and push the interval out without actually re-verifying the skill. A
+ // low-completion attempt is recorded as a FAIL → needs-refresh + sooner
+ // re-review, which is the safe outcome for a bailed review.
const acc = deriveTaskAccuracy(task);
- reviewResults.push({ skillId: cfg.reviewSkillId, passed: acc != null && acc >= MASTERY_TARGET_ACCURACY });
+ const completion = deriveTaskCompletion(task);
+ const passed = acc != null && acc >= MASTERY_TARGET_ACCURACY
+ && (completion == null || completion >= MIN_REVIEW_COMPLETION);
+ reviewResults.push({ skillId: cfg.reviewSkillId, passed });
continue;
}
if (task.type === 'multiplication' && Number.isInteger(cfg.level)) {
@@ -421,9 +435,14 @@ export async function syncReviewScheduleForSession(session, now = new Date()) {
* `reviewSkillId` so the session-submit path records the pass/fail.
*/
export async function getPostReviewReps(now = new Date(), limit = 2) {
- const due = await getDueReviews(now, limit);
+ // Fetch ALL due reviews, then filter to the runnable kinds BEFORE capping —
+ // capping first would let older due memory-chunk entries (which have no
+ // runnable rep) consume the limit slots and starve runnable multiplication/
+ // cognitive reps that are due later in the schedule.
+ const due = await getDueReviews(now, Infinity);
const reps = [];
for (const entry of due) {
+ if (reps.length >= limit) break;
if (entry.kind === 'multiplication') {
reps.push({
skillId: entry.skillId,
diff --git a/server/services/meatspacePost.test.js b/server/services/meatspacePost.test.js
index ce5e76a349..533053db25 100644
--- a/server/services/meatspacePost.test.js
+++ b/server/services/meatspacePost.test.js
@@ -1815,6 +1815,22 @@ describe('getSessionSkillContext', () => {
expect(getSessionSkillContext(session).reviewResults).toEqual([{ skillId: 'multiplication:L1', passed: false }]);
});
+ it('marks a review rep FAILED when accuracy is high but completion is too low (bailed review)', () => {
+ // One correct answer, four skipped: answered-only accuracy is 1.0, but the
+ // review was barely completed — it must not bank a pass and advance the
+ // interval without re-verifying the skill.
+ const session = { tasks: [{
+ type: 'multiplication',
+ config: { level: 1, review: true, reviewSkillId: 'multiplication:L1' },
+ questions: [
+ { answered: 10, correct: true },
+ { answered: null, correct: false }, { answered: null, correct: false },
+ { answered: null, correct: false }, { answered: null, correct: false },
+ ],
+ }] };
+ expect(getSessionSkillContext(session).reviewResults).toEqual([{ skillId: 'multiplication:L1', passed: false }]);
+ });
+
it('collects practiced skill ids from normal (non-review) multiplication / cognitive / memory tasks', () => {
const session = { tasks: [
{ type: 'multiplication', config: { level: 2 }, questions: [{ answered: 1, correct: true }] },
diff --git a/server/services/meatspacePostReview.js b/server/services/meatspacePostReview.js
index 05058863a7..026810073a 100644
--- a/server/services/meatspacePostReview.js
+++ b/server/services/meatspacePostReview.js
@@ -273,8 +273,13 @@ export async function getReviewSchedule() {
*/
export async function getDueReviews(now = new Date(), limit = 2) {
const entries = await getReviewSchedule();
+ // Gate on `nextReviewAt`, NOT on `reviewState !== 'fresh'`: a failed review is
+ // rescheduled a few days out (needs-refresh), and serving it again immediately
+ // would ignore that refresh delay and re-surface the same rep every session.
+ // isReviewDue covers both a fresh skill past its interval and a needs-refresh
+ // skill past its (shorter) refresh interval.
return entries
- .filter(e => reviewState(e, now) !== 'fresh')
+ .filter(e => isReviewDue(e, now))
.sort((a, b) => Date.parse(a.nextReviewAt || 0) - Date.parse(b.nextReviewAt || 0))
.slice(0, Math.max(0, limit));
}
@@ -301,7 +306,10 @@ export async function getRetentionReport(now = new Date()) {
retentionPct: ret.retentionPct,
};
});
- const dueCount = skills.filter(s => s.state !== 'fresh').length;
+ // "due" here means actually servable now (nextReviewAt elapsed) — a
+ // needs-refresh skill still inside its short refresh delay is shown with a
+ // needs-refresh badge but is NOT counted as due (it isn't served yet).
+ const dueCount = entries.filter(e => isReviewDue(e, now)).length;
return {
skills,
dueCount,
diff --git a/server/services/meatspacePostReview.test.js b/server/services/meatspacePostReview.test.js
index 835e274fe8..d7bdd317f1 100644
--- a/server/services/meatspacePostReview.test.js
+++ b/server/services/meatspacePostReview.test.js
@@ -155,13 +155,17 @@ describe('applySessionToReviewSchedule — session sync', () => {
expect(store.skills['multiplication:L0'].label).toBe('Renamed'); // metadata refreshed
});
- it('records a review rep result and surfaces a failed skill as needs-refresh', async () => {
+ it('records a failed review as needs-refresh and honors the shorter refresh delay before re-serving', async () => {
await applySessionToReviewSchedule({ masteredSkills: [skill()], now: new Date('2026-07-01T00:00:00.000Z') });
const res = await applySessionToReviewSchedule({ reviewResults: [{ skillId: 'multiplication:L0', passed: false }], now: new Date('2026-07-10T00:00:00.000Z') });
expect(res.reviewed).toBe(1);
expect(store.skills['multiplication:L0'].status).toBe('needs-refresh');
- const due = await getDueReviews(new Date('2026-07-10T00:00:00.000Z'));
- expect(due.map(d => d.skillId)).toEqual(['multiplication:L0']);
+ // Rescheduled REFRESH_INTERVAL_DAYS out — NOT served again immediately even
+ // though it's needs-refresh (the refresh delay must be honored).
+ expect(await getDueReviews(new Date('2026-07-10T12:00:00.000Z'))).toEqual([]);
+ // ...but it IS served once the (shorter) refresh interval elapses.
+ const later = new Date(Date.parse('2026-07-10T00:00:00.000Z') + (REFRESH_INTERVAL_DAYS + 1) * DAY);
+ expect((await getDueReviews(later)).map(d => d.skillId)).toEqual(['multiplication:L0']);
});
it('resets staleness for actively-practiced mastered skills', async () => {