A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Keep duplicate tasks distinct in the task move
Fei24119ca8ba49254c
diff --git a/ds-bot/src/host/schedules.js b/ds-bot/src/host/schedules.jsindex df0e94ae..d8ee9613 100644--- a/ds-bot/src/host/schedules.js+++ b/ds-bot/src/host/schedules.js@@ -141,20 +141,29 @@ export function install(rt) {return}// A retry after a crash between create and delete must not copy a task twice.- let moved+ // Copies already on the fresh Session satisfy earlier records of the same+ // request in order, so two genuinely identical tasks still both move.+ const have = new Map()try {- moved = new Set((await service.list({ sessionId: toId })).map(record => keyOfRequest(requestOf(record))))+ for (const record of await service.list({ sessionId: toId })) {+ const key = keyOfRequest(requestOf(record))+ have.set(key, (have.get(key) ?? 0) + 1)+ }} catch {- moved = new Set()+ // Without a read-back every source task is copied; a retry then adds one copy+ // per source record, which is the correct multiplicity anyway.}+ const seen = new Map()for (const record of records) {const request = requestOf(record)if (request === null || (request.at !== undefined && Date.parse(request.at) <= Date.now())) continuetry {const key = keyOfRequest(request)- if (!moved.has(key)) {+ const nth = (seen.get(key) ?? 0) + 1+ seen.set(key, nth)+ if (nth > (have.get(key) ?? 0)) {await service.create(toId, request)- moved.add(key)+ have.set(key, (have.get(key) ?? 0) + 1)}await service.delete({ sessionId: fromId, id: record.id })} catch (error) {diff --git a/ds-bot/test/schedules.test.js b/ds-bot/test/schedules.test.jsindex 30c632bd..a6eaf6aa 100644--- a/ds-bot/test/schedules.test.js+++ b/ds-bot/test/schedules.test.js@@ -139,16 +139,17 @@ test('a repeated task move copies each task only once', async (t) => {const { ctx, home, rt } = setup({ schedule })t.after(async () => { await ctx.dispose(); rmSync(home, { recursive: true, force: true, maxRetries: 5 }) })await schedule.create('w2', { title: 'Ping', prompt: 'Check', every_seconds: 3600 })+ await schedule.create('w2', { title: 'Ping', prompt: 'Check', every_seconds: 3600 })const remove = schedule.deleteschedule.delete = async () => { throw new Error('down') }await rt.moveSchedules('w2', 's9')const on = id => [...schedule.tasks.values()].filter(task => task.sessionId === id)- assert.equal(on('s9').length, 1)- assert.equal(on('w2').length, 1)+ assert.equal(on('s9').length, 2)+ assert.equal(on('w2').length, 2)schedule.delete = removeawait rt.moveSchedules('w2', 's9')- assert.equal(on('s9').length, 1)+ assert.equal(on('s9').length, 2)assert.equal(on('w2').length, 0)})