disclaw/tasks/DIS-007.md

42 lines
1.3 KiB
Markdown

---
id: DIS-007
status: backlog
phase: 0
priority: p1
labels: [phase:0, type:feat, priority:p1]
branch: phase-0/startup-lockfile
assignee: null
started: null
pr: null
merged: null
---
# DIS-007: Lock-File gegen Doppelstart
## Ziel
Zwei gleichzeitig laufende DisClaw-Instanzen auf derselben DB/Workspace-Root werden
verhindert. Zweiter Start bricht mit klarer Fehlermeldung ab.
## Kontext
`docs/development-plan.md` §7 (Risiko-Tabelle).
## Scope
- **In**: `src/runtime/lockfile.ts`: `acquireLock(path)` legt `<workspaces_root>/.disclaw.lock` mit PID + ISO-Timestamp an. Stale-Lock-Recovery via `process.kill(pid, 0)`. · `src/index.ts` ruft `acquireLock` vor DB-Init auf · Graceful Shutdown löscht Lock
- **Out**: Distributed Locking für Multi-Host
## Definition of Done
- [ ] Zweiter Startversuch bricht mit „DisClaw bereits aktiv (PID X)" ab
- [ ] Stale-Lock (PID tot) wird automatisch übernommen
- [ ] Unit-Test `tests/unit/lockfile.test.ts` mit tmp-Dir: Acquire, Doppel-Acquire, Stale-Recovery, Release
- [ ] `npm run build && npm test` grün
## Dateien (erwartet)
- `src/runtime/lockfile.ts`
- `src/index.ts`
- `tests/unit/lockfile.test.ts`
## Abhängigkeiten
Blockiert durch: **DIS-001** (Lock liegt unter finalem `workspaces_root`).
## Spec
`docs/backlog.md` #DIS-007