From 24f92a0d758cf2d342c93f131aa6fe806a1f7b30 Mon Sep 17 00:00:00 2001 From: teahubxyz Date: Tue, 20 Oct 2026 03:07:13 +0000 Subject: [PATCH] memory.js: among equals, the newer batch first and a batch in the order it was written Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01VAvUH72XsdCitHdh3t7mjr --- ventures/havre/memory.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ventures/havre/memory.js b/ventures/havre/memory.js index e87da25..fe76be5 100644 --- a/ventures/havre/memory.js +++ b/ventures/havre/memory.js @@ -159,12 +159,13 @@ export function salience(n, now = Date.now()) { } /** - * The notes for the prompt now: the most salient, newest first among equals, as many as fit the budget. With no + * The notes for the prompt now: the most salient, the newer batch first among equals and a batch in the order it was + * written (the most important first), as many as fit the budget. With no * reminders and nothing recalled this comes down to the newest notes, which is what it was before. */ export function select(notes, { now = Date.now(), budget = BUDGET, max = SHORT } = {}) { const scored = notes.map((n, i) => ({ n, i, s: salience(n, now) })).filter((x) => x.s > 0) - .sort((a, b) => b.s - a.s || b.i - a.i); + .sort((a, b) => b.s - a.s || (b.n.at || 0) - (a.n.at || 0) || a.i - b.i); const out = []; let used = 0; for (const { n } of scored) {