feat(coder): v2.6 Phase 3 — lifecycle hardening (idle evict, crash recovery, worktree reaper)
Idle TTL eviction per (chat,agent) + LRU cap (never a busy backend); pure lifecycle-decisions.ts (TDD). Crash recovery lifts openchamber's health-monitor + busy-aware-restart + stale-grace state machine into opencode-server.ts (+ port reclaim) and warm-acp.ts; opencode crash -> fresh sessions, ACP -> re-session/new. F.1 turn-guard + U.6 usage preserved (their tests pass). Orphan worktree reaper (1h grace, superset-style dirty/unpushed preflight, Paseo soft-delete) + close hooks + diff re-baseline after apply_pending. 35 new tests + DB-opt-in reconnect test; 215 coder tests pass; tsc + build clean. Completes v2.6. Follow-ups out of scope: apps/server close-hook caller, 3.7 DiffPanel staging hint, live smokes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -99,4 +99,21 @@ export interface AgentBackend {
|
||||
dispose(): Promise<void>;
|
||||
/** Liveness for health endpoint + dispatcher fallback decision. §2 */
|
||||
health(): 'up' | 'down';
|
||||
/**
|
||||
* v2.6 Phase 3: true iff a turn is in flight on this backend. The pool's idle
|
||||
* eviction + LRU cap NEVER evict a busy backend (design §6 busy rule); the
|
||||
* health-monitor defers a restart while busy (stale-grace). Optional so the
|
||||
* Phase-0 scaffold and any test double stay compatible — absent ⇒ treated as
|
||||
* not busy. opencode-server (multi-session) is busy iff ANY session has an
|
||||
* active turn; warm-acp (single session) iff its one slot is active.
|
||||
*/
|
||||
isBusy?(): boolean;
|
||||
/**
|
||||
* v2.6 Phase 3: optional proactive health probe + busy-aware self-restart, run
|
||||
* by the pool's periodic sweep. The opencode-server backend implements it
|
||||
* (detects a hung-but-not-exited server and restarts when non-busy). Backends
|
||||
* with no long-lived shared process (warm-ACP recovers lazily on its own child
|
||||
* exit) can omit it. Must never throw — the sweep ignores rejections.
|
||||
*/
|
||||
tickHealth?(now?: number): Promise<void>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user