Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

4.3 KB
Raw Blame

Item 5b implementation notes

The former external behavior golden is already recorded in commit 12d6b640b before any move. Preserve its fixture bytes and make the adapter cross the actual service factory and JSON validators. New safety behavior needs separate regressions.

Search owns ExternalSessions, OpenSessions, providers, metadata and index. Adoption metadata remains available when SQLite indexing cannot open. Core accepts a bounded exact requested-ID/engine response with explicit unavailable vs authoritative missing/free. Display last-good scans cannot authorize adoption. Lazy provider failure, failed process listing, partial/unreadable owner reads and conflicting owners are unknown, never free.

Core retains adoption decisions, canonical/alias reservations, process-incarnation checks, signals and pane dispatch. An external intent remains separate from an owned session until admission; initial row atomically contains launch:held and validated externalResume. Malformed persisted intent must never degrade to a fresh launch. Include intent phase/generation in restore ownership. Known refusals retain existing error/detail; unavailable facts produce a durable held tile before any trust/config/engine write. Skip launch-receipt pre-trust for external resume.

A pending adoption survives daemon/tmux restart. Stop cancels it and its verified inert pane without archiving/deleting the external conversation, signalling its owner, or allowing delayed work to revive it. Owner busy uses a per-intent hold, not the pass-wide service outage map. A bounded coalesced refresh must return held promptly, never idle-poll inside heldLaunches global queue.

Before any signal, recheck core generation, route, exact owner PID/start marker/session/TTY and non-Harness ownership. Recheck after foreground-group lookup and before TERM and KILL. Do not reset the TTY after exit: its ownership can no longer be proved. A signal already sent cannot be undone; persist that phase. An identity replacement cannot inherit permission to terminate. Never trust worker to signal anything.

Each signal takes the strict registry lock and rechecks durable reservations, including an unchanged intent before KILL after TERM's grace period. A verified core binding may overlap a held provisional reservation; the held adoption never gains authority from that overlap. An exact owner with another non-alias conversation in the same process cannot be stopped. FD ownership also requires a positively identified engine process; lsof's command-prefix match is not enough.

Idle takeover requires a final coherent record proving the exact session, PID, incarnation and activity together, after all asynchronous process/terminal work. Claude's process record supports this. Providers whose ownership and activity live in separate stores report unknown activity for this purpose: idle/wait stays held with the missing-evidence reason, and explicit takeover can stop the verified owner without inventing a continuation prompt. The optional validated busyConfirmed wire bit alone permits automatic continuation; unknown never does. No asynchronous work follows the final proof before the service's synchronous generation check.

Admission/dispatch must have a durable boundary. Generic restore currently treats held panes as inert: crash after respawn but before its starting commit would replay. Record dispatch phase before the side effect and reconcile exact pane/process on restart. Once admitted, resume is core owned and strict (never fresh fallback), and never asks search again. Keep launch prep outside the pane-operation lock so Stop can cancel it immediately.

Review feedback from independent reviewer: wire and read failures must hold; separate unadmitted identity; initial held row atomic; strict resume; phase/generation in restoreOwner; per-intent waits outside global queue; distinguish busy from outage; fail closed malformed persistence. A buildLaunch-only wrapper is insufficient because it cannot mutate cwd/sessionId/launch without invalidating current(), and resumeOnly+empty session is rejected before buildLaunch. Use an explicit guarded transition/fresh snapshot.

New owner steering: two panes of the same agent started in the same millisecond fail. buildHarnessSessionLabel currently formats engine + Date.now() with no nonce. Fix with regression in core follow-ups; nonblocking for #1078.