---
name: "Watcher and auto-assign do not reinitialize when project root changes"
---

# Bug 253: Watcher and auto-assign do not reinitialize when project root changes

## Description

When the server starts, if the frontend opens the project at the wrong path (e.g. server/ subdirectory instead of project root), the filesystem watcher and auto-assign run against that wrong path. When the frontend corrects itself by calling DELETE /project then open_project with the right path, the watcher and auto-assign do not reinitialize. This means:

1. The filesystem watcher watches the wrong directory for the entire session
2. Auto-assign only runs once at startup (against the wrong root) and never re-runs
3. Stories placed in 2_current/ are never auto-assigned to coders
4. The archive sweep never fires (same watcher thread)

This is likely the root cause of bug 251 (archive sweep not working) and explains why coders are not being auto-assigned.

## How to Reproduce

1. Start the Story Kit server\n2. Open a project in the frontend — note the first open_project sets project_root to the wrong subdirectory\n3. Frontend corrects by calling DELETE /project then open_project with the correct path\n4. Move a story into 2_current/\n5. Observe that no coder is auto-assigned

## Actual Result

Watcher and auto-assign remain bound to the initial (wrong) project root. No filesystem events are detected for the correct project directory. Stories in 2_current/ are never picked up.

## Expected Result

When project_root changes via open_project, the watcher thread should be stopped and restarted against the new root, and auto_assign_available_work() should re-run.

## Acceptance Criteria

- [ ] When open_project is called with a new path, the filesystem watcher restarts watching the new project root
- [ ] auto_assign_available_work() re-runs after a project root change
- [ ] If DELETE /project is called, the watcher stops (no zombie watcher on a stale path)
- [ ] Stories in 2_current/ are auto-assigned after the project root is corrected
