@cohortapp/agent-sdk 2.18.35 → 2.18.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -127,7 +127,12 @@ export function roomNoticeWindowMs(env = process.env) {
|
|
|
127
127
|
return num(env && env.ASSURANCE_ROOM_NOTICE_WINDOW_MS, DEFAULT_ROOM_NOTICE_WINDOW_MS);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
/**
|
|
130
|
+
/**
|
|
131
|
+
* How many decision windows an entry is retained for before it is landfill.
|
|
132
|
+
*
|
|
133
|
+
* The retention must be measured against the LONGEST window the entry could be
|
|
134
|
+
* judged by, not the shortest — see the note on `pruneLedger`.
|
|
135
|
+
*/
|
|
131
136
|
const RETAIN_WINDOWS = 2;
|
|
132
137
|
|
|
133
138
|
/** The shape on disk. `v` is there so a future migration is not a guess. */
|
|
@@ -216,6 +221,29 @@ export function noticeKey(o) {
|
|
|
216
221
|
return `${roomKey(a)}|${notice}|${ident}`;
|
|
217
222
|
}
|
|
218
223
|
|
|
224
|
+
/**
|
|
225
|
+
* Was this notice key minted WITH a work id, and therefore judged by the 24-hour
|
|
226
|
+
* window rather than the 15-minute one?
|
|
227
|
+
*
|
|
228
|
+
* Reads the identity segment `noticeKey` writes: `w:<digest>` for a work-keyed
|
|
229
|
+
* notice, a bare digest for a text-keyed one. This is a deliberate coupling to
|
|
230
|
+
* that format and it is why this function lives beside it — the prune cannot
|
|
231
|
+
* retain an entry correctly without knowing which window will judge it, and the
|
|
232
|
+
* key is the only thing the ledger keeps.
|
|
233
|
+
*
|
|
234
|
+
* If `noticeKey`'s format changes, change this with it: the failure mode is
|
|
235
|
+
* silent under-retention, which deletes a stamp that was still refusing and
|
|
236
|
+
* makes the notice look like one never said.
|
|
237
|
+
*
|
|
238
|
+
* @param {string} key
|
|
239
|
+
* @returns {boolean}
|
|
240
|
+
*/
|
|
241
|
+
export function isWorkKeyedNotice(key) {
|
|
242
|
+
const k = String(key == null ? "" : key);
|
|
243
|
+
const i = k.lastIndexOf("|");
|
|
244
|
+
return i >= 0 && k.slice(i + 1).startsWith("w:");
|
|
245
|
+
}
|
|
246
|
+
|
|
219
247
|
/** One of the ledger's maps, or an empty one — never a throw, never a null deref. */
|
|
220
248
|
function mapOf(ledger, field) {
|
|
221
249
|
if (!ledger || typeof ledger !== "object") return {};
|
|
@@ -339,7 +367,45 @@ export function pruneLedger(o = {}) {
|
|
|
339
367
|
}
|
|
340
368
|
return keep;
|
|
341
369
|
};
|
|
342
|
-
|
|
370
|
+
// PRUNE IS A SIZE BOUND, NOT A POLICY — AND IT WAS SILENTLY ACTING AS ONE.
|
|
371
|
+
//
|
|
372
|
+
// The notices map holds entries with TWO intended lifetimes: `noticeAllowed`
|
|
373
|
+
// judges a work-keyed notice against DEFAULT_ROOM_WORK_NOTICE_WINDOW_MS (24h)
|
|
374
|
+
// and every other notice against DEFAULT_ROOM_NOTICE_WINDOW_MS (15m). This
|
|
375
|
+
// sifted ALL of them with the 15-minute figure, so with RETAIN_WINDOWS = 2 a
|
|
376
|
+
// work-keyed entry was deleted after exactly THIRTY MINUTES — and once it is
|
|
377
|
+
// gone `noticeAllowed` finds no stamp, returns "room-notice-new", and allows
|
|
378
|
+
// the notice again. The one-per-day guarantee was really one per half hour.
|
|
379
|
+
//
|
|
380
|
+
// It was observed before it was understood: the document-notice loop measured
|
|
381
|
+
// on 2026-10-01 had a median gap of 11.5 minutes and a MAX of 32.5 — thirty
|
|
382
|
+
// minutes of retention plus a sweep interval. The outer cadence of that loop
|
|
383
|
+
// was partly this line.
|
|
384
|
+
//
|
|
385
|
+
// The fix is to retain against the longest window any entry could be judged
|
|
386
|
+
// by. Over-retaining is free and cannot cause a wrong refusal: `noticeAllowed`
|
|
387
|
+
// applies the correct per-entry window itself, so a surviving stamp outside its
|
|
388
|
+
// own window still returns "room-notice-window-elapsed". UNDER-retaining is the
|
|
389
|
+
// only direction that changes behaviour, because a missing stamp is
|
|
390
|
+
// indistinguishable from a notice never said.
|
|
391
|
+
//
|
|
392
|
+
// GENERAL SHAPE, worth grepping for elsewhere: a ledger whose entries have
|
|
393
|
+
// mixed lifetimes and a single prune. The short lifetime wins and the long
|
|
394
|
+
// guarantee quietly becomes the short one.
|
|
395
|
+
// Each notice is retained against ITS OWN window, read off the key. A blanket
|
|
396
|
+
// max over all entries would also fix the bug, but it would keep 15-minute
|
|
397
|
+
// entries for two days and make the bounded-growth pin meaningless.
|
|
398
|
+
const siftNotices = (map) => {
|
|
399
|
+
const keep = {};
|
|
400
|
+
for (const k of Object.keys(map)) {
|
|
401
|
+
const at = stampAt(map, k);
|
|
402
|
+
if (at == null) continue;
|
|
403
|
+
const win = isWorkKeyedNotice(k) ? DEFAULT_ROOM_WORK_NOTICE_WINDOW_MS : noticeWindowMs;
|
|
404
|
+
if (now - at < win * RETAIN_WINDOWS) keep[k] = at;
|
|
405
|
+
}
|
|
406
|
+
return keep;
|
|
407
|
+
};
|
|
408
|
+
return { v: 1, rooms: sift(rooms, windowMs), notices: siftNotices(notices) };
|
|
343
409
|
}
|
|
344
410
|
|
|
345
411
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cohortapp/agent-sdk",
|
|
3
|
-
"version": "2.18.
|
|
3
|
+
"version": "2.18.36",
|
|
4
4
|
"description": "Cohort Agent SDK — autonomous AI colleague runtime. Deploy senior AI colleagues on dedicated Mac minis, wired to the Cohort operating surface.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|