import { loadJson, saveJson, storageKeys } from '../lib/storage.ts' import { emptyLedger, nowIso, type Ledger } from '../core/work-item.ts' /** Note on each card that a nightly run group picked it up. */ export async function markCardsPickedUp(cardIds: string[], ctx: { groupKey: string; groupName: string }) { const ledger = await loadJson(storageKeys.LEDGER_KEY, emptyLedger()) const at = nowIso() for (const id of cardIds) { const item = ledger.items[id] if (!item) continue ledger.items[id] = { ...item, updatedAt: at, events: [...item.events, { at, from: item.state, to: item.state, reason: `picked up by nightly run: ${ctx.groupName}`.slice(0, 300), actor: 'sweep', meta: { groupKey: ctx.groupKey } }] } } await saveJson(storageKeys.LEDGER_KEY, ledger) }