fix: address round-4 review findings

- apply(): if a newer invocation changed the catalog while this one
  awaited the model refresh, exit silently. The superseded invocation
  otherwise reported the second's catalog in its notice and could fire
  one extra setModel. Pinned with a deferred-refresh test.
- CITATION.cff: drop date-released while the CHANGELOG is [Unreleased]
  and no release tag exists; version stays 0.1.0.
- Tests: 18 (was 17).
This commit is contained in:
AlexKucera committed 2026-11-25 10:43:26 +01:00
1 parent 8d91094022
commit 78e89241a6
3 files changed
+17 -3

No files matched your search

+15 -2
View File
@@ -150,10 +150,10 @@ const drive = (flag) => {
registerProvider: (input) => Object.assign(provider, input),
setModel: async (model) => switched.push(model),
});
const run = (name, model, available) =>
const run = (name, model, available, refresh = async () => {}) =>
commands[name].handler("", {
model,
modelRegistry: { refresh: async () => {}, getAvailable: () => available },
modelRegistry: { refresh, getAvailable: () => available },
ui: { notify: (message) => notes.push(message) },
});
return { run, provider, switched, notes };
@@ -217,6 +217,19 @@ test("/nous-catalog cycles full → free → promo → full", async () => {
}
});
test("overlapping catalog switches: the invocation superseded while awaiting a slow refresh stays silent", async () => {
const { run, switched, notes } = drive();
const all = [nous("free-a", "free"), nous("promo-a", "promo"), nous("paid")];
let release;
const gate = new Promise((resolve) => (release = resolve));
const first = run("nous-free", undefined, all, () => gate); // apply("free"), then awaits a slow refresh
await run("nous-catalog", undefined, all); // reads catalog "free" → applies "promo", refresh resolves at once
release();
await first;
assert.deepEqual(notes.map((n) => n.split(" ")[2]), ["promo"]);
assert.deepEqual(switched, []);
});
test("a saved catalog survives restart; a corrupted flag falls back to full", () => {
const all = [nous("free-a", "free"), nous("promo-a", "promo"), nous("paid")];
try {