Repository navigation
Description
What happens
When the ledger file cannot be parsed at startup, the store quarantines it, starts with an empty
board, and says nothing:
src/host/store.ts:160-171:
} catch (error) {
const code = (error as NodeJS.ErrnoException).code
if (code !== 'ENOENT') {
try { await rename(this.file, `${this.file}.corrupt-${Date.now()}`) } catch { /* best effort */ }
}
}
this.loaded = trueThere is no warning on this path (the only related log is the per-record dropping implausible ledger entry at :118). The board then renders empty, and the same boot runs the image-attachment
GC against that empty snapshot:
src/index.ts:77→assets.cleanup(JSON.stringify(store.snapshot()))right after the load;src/host/assets.ts:101-119deletes every content-addressed attachment whose name is not in
the ledger string and whose mtime is older thanORPHAN_GRACE_MS(24 h).
So after a corrupt read, all images referenced only by that ledger are deleted for good — they are
not part of the ledger, not in the .corrupt-* copy, and there is no trash for attachments.
Note: the terminal .catch added to this chain in #80 only covers a rejected storage.ready(),
not the corrupt-ledger path — store.load() resolves after quarantine, so the cleanup still runs
with an empty reference set.
Separately, the first mutation after that boot writes a fresh ledger: mutate re-reads under the
lock (store.ts:227), the original path is now gone (ENOENT), the empty in-memory ledger is
persisted with revision 1 (:233). The original content survives only as
dsh-taskboard.json.corrupt-<timestamp> — which nothing tells the user about.
Trigger
A truncated or hand-edited dsh-taskboard.json (the README points users at it for backups), a bad
restore/import, or a non-ENOENT file read error at boot (EIO/EBUSY/EACCES). Restarting dsh web
then shows an empty board with no explanation.
Verification
Reproduced against the real TaskStore / AssetStore / StorageCoordinator:
- truncated ledger → cold snapshot has 0 tasks; the next mutation writes a ledger with just that
new task at revision 1; the directory containsdsh-taskboard.jsonplus
dsh-taskboard.json.corrupt-*; - one referenced PNG with an mtime older than 24 h → a boot-equivalent
assets.cleanup(JSON.stringify(snapshot))removes it (CLEANUP_REMOVED: 1, assets directory
empty).
Environment
- dsh-taskboard
0.9.8/dev@615b435(originally reproduced on0.9.6@3054eba) - DSH
0.2.1-rc.5, Windows 11, Node26.13.0
Suggested fix
- Log the quarantine loudly (
console.warnwith the original error and the.corrupt-*path), so
the user can recover the file instead of assuming the board was emptied. - Track "ledger could not be read" in
TaskStoreand skipassets.cleanupunless a load actually
produced a trustworthy reference set; better to leave a few orphans than to delete live images. - Consider refusing the first write when the previous load failed, until the user resolves the
.corrupt-*file (or blocks it behind an explicit GUI action).
Dedupe
#42 was a truncated /state response; #53 was ledger-lock recovery. The quarantine itself is
intentional (code comment: "Never take the host down over ledger damage") — the silent destruction
that follows is the bug.
Activity