feat: worker presence layer + batch-loop docs (#7)
* feat: add next_action field to update_job_status response * docs: add Batch-loop section to README * feat: presence layer — registerWorker, startHeartbeat, registerShutdownHandlers * feat: bootstrap worker presence at server startup, remove inline presence from wait-for-job * docs: document worker presence layer in CLAUDE.md * docs: refine Batch-loop intro — add 'Hier is de flow:' per implementation plan
This commit is contained in:
parent
c990d8547e
commit
f87b20744b
9 changed files with 243 additions and 108 deletions
11
CLAUDE.md
11
CLAUDE.md
|
|
@ -42,6 +42,17 @@ If no repo root is found, `wait_for_job` rolls the claim back to QUEUED and retu
|
|||
|
||||
Run `cleanup_my_worktrees` (no arguments) to scan `~/.scrum4me-agent-worktrees/` and remove worktrees for jobs that are in a terminal state (DONE, FAILED, CANCELLED). Worktrees for active jobs (QUEUED, CLAIMED, RUNNING) are left untouched. Returns `{ removed, kept, skipped }`.
|
||||
|
||||
## Worker presence
|
||||
|
||||
Server-startup registers a `ClaudeWorker` record + starts a 5 s heartbeat; SIGTERM/SIGINT cleans it up. The Scrum4Me NavBar counts active workers via `last_seen_at < now() - 15s`.
|
||||
|
||||
| File | Purpose |
|
||||
|---|---|
|
||||
| `src/presence/worker.ts` | `registerWorker` (upsert + pg_notify worker_connected) + `unregisterWorker` |
|
||||
| `src/presence/heartbeat.ts` | `startHeartbeat` — 5 s interval, stops on record-not-found |
|
||||
| `src/presence/shutdown.ts` | `registerShutdownHandlers` — SIGTERM/SIGINT → stop heartbeat + unregister |
|
||||
| `src/index.ts` | Bootstrap: calls `getAuth` → `registerWorker` → `startHeartbeat` → `registerShutdownHandlers` |
|
||||
|
||||
## Key source files
|
||||
|
||||
| File | Purpose |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue