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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
A core with no master ends its own stop, and Harness OS stops waiting at 10 s
bitcoinbuilder765add101d04
diff --git a/cli/src/core/main.ts b/cli/src/core/main.tsindex 993c2cce2..922d4cef8 100644--- a/cli/src/core/main.ts+++ b/cli/src/core/main.ts@@ -123,6 +123,7 @@ import { createLiveTransport } from './engines/liveTransport.js'import { createLiveWatcher } from './engines/liveWatcher.js'import { readerEngine, READER_SERVICES } from '../engines/worker/protocol.js'import { createRecaps } from './turns/recaps.js'+import { stopDeadline } from './stopDeadline.js'import { createUpdateHandoff, handOverOnceReleased, probeStagedMaster, type TeardownStep } from './updateHandoff.js'import { needsUpdaterBeside, startUpdaterBeside } from './updaterBeside.js'import { createHeartbeats } from './turns/heartbeats.js'@@ -2602,6 +2603,12 @@ async function runForeground(session: AuthSession | null): Promise<void> {console.log(`\n[cli] ${signal} — shutting down`)// A slow teardown may exhaust the master's grace. Persist already acknowledged bindings first.registry.flush({ exiting: true })+ const leave = (): never => {+ try { if (readPid() === process.pid) rmSync(PID_FILE, { force: true }) } catch { /* ignore */ }+ process.exit(coreLink.supervised && forGood(signal) ? CORE_EXIT_STOP : 0)+ }+ // A core with no master keeps the master's grace on itself (core/stopDeadline.ts).+ const deadline = stopDeadline({ supervised: coreLink.supervised, exit: leave, log: (line) => console.log(line) })// Mid-handoff everything below is already being torn down, and nothing has been started yet: leave// — a second teardown of closed servers is noise.if (updateHandoff.restarting()) {@@ -2621,23 +2628,30 @@ async function runForeground(session: AuthSession | null): Promise<void> {heartbeats.clear()cursorSubagents.stop()normalizers.stopPollers()+ deadline.at('Cursor discovery')await cursorDiscovery.stop()+ deadline.at('the transcript watcher')await watcher.stop()runtimeProfiles.stop()+ deadline.at('Share')await ports.sharing?.stop()// The data folder's socket first: a successor waiting for this core to leave (lib/localSocket.ts) can// start as soon as it is gone, whatever the clients below take to close.+ deadline.at('the local socket')await localSocket?.close()+ deadline.at('the local websocket')await localWsServer.close()hookServer.close()nativeControls.close()externalResumes?.stop()usageLink.port.stop(); ports.usage?.stop()+ deadline.at('the viewers')await ports.viewers?.stop()+ deadline.at('the gateway')await gateway.stop()+ deadline.at('the backend')await backend.stop()- try { if (readPid() === process.pid) rmSync(PID_FILE, { force: true }) } catch { /* ignore */ }- process.exit(coreLink.supervised && forGood(signal) ? CORE_EXIT_STOP : 0)+ leave()}process.on('SIGINT', () => void shutdown('SIGINT'))process.on('SIGTERM', () => void shutdown('SIGTERM'))diff --git a/cli/src/core/stopDeadline.spec.ts b/cli/src/core/stopDeadline.spec.tsnew file mode 100644index 000000000..13e2d3111--- /dev/null+++ b/cli/src/core/stopDeadline.spec.ts@@ -0,0 +1,48 @@+import { describe, expect, it, vi } from 'vitest'+import { ALONE_STOP_DEADLINE_MS, stopDeadline } from './stopDeadline.js'++function stop(supervised: boolean) {+ const timers: Array<{ fn: () => void; ms: number }> = []+ const exit = vi.fn()+ const log = vi.fn()+ const deadline = stopDeadline({ supervised, exit, log, setTimer: (fn, ms) => timers.push({ fn, ms }) })+ return { timers, exit, log, deadline }+}++describe('a core\'s stop', () => {+ it('keeps the master\'s grace on itself when it runs alone, and names the step it gave up on', () => {+ const { timers, exit, log, deadline } = stop(false)+ expect(timers.map(({ ms }) => ms)).toEqual([ALONE_STOP_DEADLINE_MS])+ expect(ALONE_STOP_DEADLINE_MS).toBe(2_500)+ deadline.at('the gateway')+ expect(exit).not.toHaveBeenCalled()+ timers[0].fn()+ expect(log).toHaveBeenCalledWith(`[cli] the stop is still on the gateway after ${ALONE_STOP_DEADLINE_MS} ms — leaving without it`)+ expect(exit).toHaveBeenCalledOnce()+ })++ it('names the first steps when nothing was marked yet', () => {+ const { timers, log } = stop(false)+ timers[0].fn()+ expect(log).toHaveBeenCalledWith(expect.stringContaining('still on the first steps'))+ })++ it('leaves the deadline to the master that runs it', () => {+ const { timers, deadline, exit } = stop(true)+ deadline.at('the backend')+ expect(timers).toEqual([])+ expect(exit).not.toHaveBeenCalled()+ })++ it('uses a real timer by default', () => {+ vi.useFakeTimers()+ try {+ const exit = vi.fn()+ stopDeadline({ supervised: false, exit, log: () => {} })+ vi.advanceTimersByTime(ALONE_STOP_DEADLINE_MS - 1)+ expect(exit).not.toHaveBeenCalled()+ vi.advanceTimersByTime(1)+ expect(exit).toHaveBeenCalledOnce()+ } finally { vi.useRealTimers() }+ })+})diff --git a/cli/src/core/stopDeadline.ts b/cli/src/core/stopDeadline.tsnew file mode 100644index 000000000..5435cb806--- /dev/null+++ b/cli/src/core/stopDeadline.ts@@ -0,0 +1,37 @@+/**+ * A core's stop, bounded. Under harnessd the master gives its core `stopGraceMs` (2.5 s) to leave and kills+ * it after (harnessd/supervisor.ts). A core with no master had no such bound: Harness OS's+ * harness-daemon.service runs the core alone (HARNESS_NO_MASTER=1), and one step of the stop that never+ * resolved held it until systemd's own 90 s ran out, three seconds after boot, with the OS's update waiting+ * on all of it (2026-10-13). A core alone keeps the same time on itself, and says which step it gave up on.+ * By then the registry is already written: the stop flushes it first.+ */++export const ALONE_STOP_DEADLINE_MS = 2_500++export interface StopDeadline {+ /** The step the stop is on: what the log names should it be given up on. */+ at(step: string): void+}++export interface StopDeadlineDeps {+ /** A master runs this core, and ends a stop that outlives its grace itself. */+ supervised: boolean+ /** Leave now, as a stop that finished would. */+ exit: () => void+ log: (line: string) => void+ deadlineMs?: number+ setTimer?: (fn: () => void, ms: number) => unknown+}++export function stopDeadline(deps: StopDeadlineDeps): StopDeadline {+ let step = 'the first steps'+ if (!deps.supervised) {+ const ms = deps.deadlineMs ?? ALONE_STOP_DEADLINE_MS+ ;(deps.setTimer ?? setTimeout)(() => {+ deps.log(`[cli] the stop is still on ${step} after ${ms} ms — leaving without it`)+ deps.exit()+ }, ms)+ }+ return { at: (next) => { step = next } }+}diff --git a/os/DEVELOPMENT.md b/os/DEVELOPMENT.mdindex a49d37ca1..d4da48968 100644--- a/os/DEVELOPMENT.md+++ b/os/DEVELOPMENT.md@@ -378,7 +378,10 @@ daemon counts: one serving beside it is stopped first, and activation fails unleunit's daemon answers afterward. The CLI starts and stops the daemon through that uniton Harness OS (`cli/src/lib/platformDaemon.ts`), so a sign-in or sign-out cannot move itoutside systemd. Never `systemctl stop` the unit: every pane's scope is PartOf it.-Failure restores the previous+The core alone ends its own stop after 2.5 s, as a master would end it, and the unit+stops waiting after 10 s. The new screen counts once `hn-screen.service`'s own client+runs the selected binary, whichever hn server answers: an hn started over SSH before the+screen leaves `hn-list-clients` empty. Failure restores the previousselection. `harness updates rollback` restores the previous runtime and holdsrejected versions until a newer release arrives. Ordinary macOS/Linux hn is unchanged.diff --git a/os/root/usr/lib/systemd/user/harness-daemon.service b/os/root/usr/lib/systemd/user/harness-daemon.serviceindex 59e7e1f6f..f73b438d3 100644--- a/os/root/usr/lib/systemd/user/harness-daemon.service+++ b/os/root/usr/lib/systemd/user/harness-daemon.service@@ -20,6 +20,10 @@ TimeoutStartSec=150Restart=on-failureRestartSec=2KillMode=process+# The core alone ends its own stop after 2.5 s (cli/src/core/stopDeadline.ts). An older CLI has no such+# bound, and systemd's default 90 s held an update for all of it (2026-10-13). Its main process only, as+# the CLI's own unit does: the agents in tmux outlive the kill.+TimeoutStopSec=10[Install]WantedBy=default.target