diff --git a/extensions/pi/mempalace.ts b/extensions/pi/mempalace.ts index 5e21833..f30869f 100644 --- a/extensions/pi/mempalace.ts +++ b/extensions/pi/mempalace.ts @@ -1209,10 +1209,16 @@ export default async function mempalaceExtension(pi: ExtensionAPI) { if (!mailboxEnabled || !available) return []; try { const [candidatesRaw, mineRaw, inboundRaw] = await Promise.all([ + // Every cursor-less event_list call in this file passes `order` explicitly. + // The server's default is not ours to lean on: mempalace <= 3.9.0 defaults + // to `asc`, 3.10.0 flips a cursor-less listing to newest-first. Both + // derive* joins want the NEWEST window (see the comment below), so say so + // and the verdict stops depending on which server version answers. client.callTool("mempalace_event_list", { to_agent: mailboxAddress, status: "open", limit: 50, + order: "desc", }), // `order: "desc"` is a fix, not a flourish. event_list defaults to `asc` // (append order), so this asked for the OLDEST 100 events this device @@ -1277,10 +1283,15 @@ export default async function mempalaceExtension(pi: ExtensionAPI) { async function deriveClosed(): Promise { if (!mailboxEnabled || !available) return []; try { + // `order: "desc"` for the same reason as deriveOwed: without it a 3.9.0 + // server hands back the OLDEST window, so past 100 authored events this + // device's newest asks (and past 50 inbound, the replies that close them) + // fall outside the join. The selection below is order-independent + // (isStrictlyAfter), so this only fixes WHICH events are in the window. const [mineRaw, inboundRaw] = await Promise.all([ - client.callTool("mempalace_event_list", { from_agent: mailboxAddress, limit: 100 }), + client.callTool("mempalace_event_list", { from_agent: mailboxAddress, limit: 100, order: "desc" }), // NO status filter, deliberately: that omission is the entire fix. - client.callTool("mempalace_event_list", { to_agent: mailboxAddress, limit: 50 }), + client.callTool("mempalace_event_list", { to_agent: mailboxAddress, limit: 50, order: "desc" }), ]); // Correlations this device opened as a DIRECTED ask. A broadcast owes // nobody a reply, so it cannot be closed by one either.