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.

18.3 KB
Raw Blame

Daemons, end to end: a sandbox run and a mixed-version matrix

2026-09-27. Daemons were tested one unit at a time; nothing had yet run the whole loop against a real backend, a real harnessd and an engine in a real tmux pane. This is that run: what was built to do it, how to repeat it, what passed, and what it found.

Branch daemons-e2e, off daemons d9bc36d9, then merged with daemons at d61a38ef (the question-id and answer-routing fixes) and cd9fc9e1. The desktop client is daemons-desktop at 80daf6dd and bd394a7e ("daemons off are invisible"). The old side of the matrix is origin/main aeb50151.

The sandbox

 the test (a window)  ── local WebSocket over the Unix socket ──►  harnessd  ──►  tmux -L hde2e-<id>
        │                                                              │                  │
        │ zoo seeds (Prisma)                              BACKEND_WS_URL                  ▼
        ▼                                                              ▼          fake-claude.mjs as `claude`
   MongoDB (rs0) + Redis  ◄──  backend (dist)  ◄──  logging proxy  ◄──┘          (one per harness pane)
   (throwaway containers)          │
                                   └──►  stub SSO: one random token, the test user

Everything lives under one scratch folder (E2E_DIR) and nothing of the person's own Harness is touched:

  • HOME is $E2E_DIR/home: harnessd's ~/.harness, the hooks it installs in ~/.claude, the transcripts, ~/.config/harness/pair.jsonc, the lessons folder. harnessd is started with a hand-made environment (no XDG_*, no TMUX, no CLAUDE_CONFIG_DIR), the way env -i would.
  • tmux: a wrapper first on harnessd's PATH runs tmux -L hde2e-<id>, so every call harnessd and its panes make lands on a private server; down kills that server by its label only.
  • harnessd is cli/dist/cli.js start (never start -f) on port 28473, with the self-updater off, the Node, grid and runtime manifests pointed at a dead loopback address, the grid CLI absent and the USB dial (CABLE_DISABLE) left alone. It is signed in with a session.json holding the sandbox user's token.
  • The engine is daemons/e2e/fake-claude.mjs, copied in as claude (CLAUDE_PATH). No real engine runs and no real credential is read.
  • The backend is backend/dist/server.js on a free port against a MongoDB replica set and a Redis, in containers named hde2e-mongo-<id> and hde2e-redis-<id> of the current docker context (not switched). The test user is created with Prisma; a stub SSO answers the backend's token check for its one random token. HARNESS_DAEMONS_USERS is that user's email.
  • The proxy between harnessd and the backend logs every HTTP request (path, status, and for /api/zoo/ops the op names) and every adapter-ws frame by type only: this is how the off scenarios count zoo traffic. It also lets the backend be swapped for another build under a running harnessd.

The scripted engine

fake-claude.mjs behaves like Claude Code as far as harnessd can tell:

  • It writes Claude's own transcript records (~/.claude/projects/<cwd>/<session>.jsonl): a typed prompt, assistant text with stop_reason: end_turn, a Bash tool_use before its permission dialog and the tool_result after.
  • It runs the SessionStart, UserPromptSubmit and Stop hooks harnessd installed, from inside the pane, with the JSON Claude pipes to them.
  • It draws an inline UI like Claude's: output scrolls, and a live region (the input line, or the permission dialog from cli/src/lib/__fixtures__/permission-claude.txt) is redrawn in place, so an answered dialog leaves nothing in the scrollback for the watcher to find.
  • e2e:bash <cmd> asks permission for a command; e2e:bash-timer <cmd> does it with Muse's status line ticking inside the dialog (◇ Calling tools (21s · esc to interrupt)); e2e:steps a ;; b runs auto-approved steps. A control file lets the test type a prompt, change the open dialog to another tool call, move its cursor, or press a key at the pane, without sending keys through harnessd.
  • Every key that reaches the pane is logged with what was on screen: the proof that an answer was typed, and which key.
  • In --print stream-json mode it is harnessd's one-shot worker: a distill prompt that saw a correction about migrations gets a lesson back, anything else gets nothing.

How to re-run it

# once: builds of the old side, and a desktop build with the daemons client
daemons/e2e/build-ref.sh origin/main "$SCRATCH/old-main"
git archive refs/heads/daemons-desktop desktop | tar -x -C "$SCRATCH/desk" && (cd "$SCRATCH/desk/desktop" && flutter pub get)

# every time: cli and backend built on this branch
(cd cli && npm ci && node build.mjs) && (cd backend && npm ci && node build.mjs)
HARNESS_DAEMONS_E2E=1 E2E_DIR="$SCRATCH/e2e" \
E2E_OLD_CLI="$SCRATCH/old-main/cli" E2E_OLD_BACKEND="$SCRATCH/old-main/backend" \
E2E_DESKTOP="$SCRATCH/desk/desktop" E2E_FLUTTER="$(command -v flutter)" \
  node --test daemons/e2e/daemons.e2e.test.mjs

Without HARNESS_DAEMONS_E2E=1 the file is one skipped test. It needs docker (the current context running), tmux and about fifteen minutes: harnessd says at most one unsolicited line every two minutes, and reports turns once a minute, so several scenarios wait on purpose. The sandbox comes up in the first test and goes down after the last (E2E_KEEP=1 leaves it up; node daemons/e2e/sandbox.mjs down with the same E2E_DIR takes it down). Results land in $E2E_DIR/results.json and as a table at the end of the output. E2E_ONLY=A12,B1 runs a subset.

daemons/e2e/desktop_zoo_e2e_test.dart is the desktop's own zoo client (ZooController with ApiZooTransport and the app's ApiClient) against the sandbox harnessd. It is copied into the desktop build's test/ by the run; on its own: HARNESS_DAEMONS_E2E_PORT=28473 HARNESS_DAEMONS_E2E_EXPECT=on|off flutter test test/desktop_zoo_e2e_test.dart.

Results

The final run: daemons-e2e at 1d9d14f6 (daemons cd9fc9e1 merged in), desktop daemons-desktop bd394a7e, old side origin/main aeb50151. 21 of 22 pass; the failure is a bug (below, 1). Four earlier runs built the kit; their differences are in "Before and after" and in the bugs.

Daemons on: a new harnessd against a new backend

# scenario result what was seen
A1 harnessd probes GET /api/zoo at start and turns daemons on pass 2 reads at start, both 200: the probe, then the re-read every backend connect does once on. /api/status says daemons: { on, server: on }
A2 habits → first egg → hatch → consent turns the sensor on fail turn+split grant nothing; find grants the first egg; zoo.hatch draws on the server (tim, ping, zsh across runs) with serial #1 and pairs it; zoo.consent sets watch and [pair] sensor on. But the window that was attached when pairing came on is never sent daemon_state (bug 1). A window that connects afterwards gets it
A3 at watch a need line carries only [g], and y does nothing pass [g] alpha: Approve Bash command: npm test PING; y after daemon_shown + 450 ms → NOT_OFFERED, no key reached the pane. The dial's question_response then answered it
A4 turns → zoo.turn → a turn egg and a level-up pass seeded to 39 counted turns and 148 xp; the next report came 59 s after the turn (zoo.turn → 200) with two turns (A3's and this one): 41 turns, so the server granted a turn egg (every 40), and 155 xp (+2, +5 for the day's first) took the pair to bond 2, version 1.0; zoo_changed came down the adapter socket to the window
A5 a duplicate pass every regular owned (seeded), a turn egg hatched: duplicate: true, xp: 150, no serial, dupes +1, still one record
D1 the desktop's zoo client, daemons on pass loaded=true source=account daemons=9 eggs=1
A6 suggest: keys, the arming, the socket pass [y/n/g] alpha: Approve Bash command: npm test … with the whole dialog as detail. Before daemon_shown: NOT_SHOWN; over TCP: LOCAL_SOCKET_REQUIRED; from a tool connection: UI_ONLY; right after daemon_shown: TOO_SOON; 450 ms later: ok. Exactly one key reached the pane, 1 (the one-time yes, never 2 "don't ask again"); capture-pane shows approved: npm test; daemon_unsay and commander_question_close followed
A7 deny-class pass git push origin main sits in daemon_state.needs with deny: true, allow: false; declined from the dial with 3
A8 STALE_QUESTION pass a shown, armed need line; the dialog then changed to another tool call (npm run lint → npm run build); y 60 ms later → STALE_QUESTION, nothing typed. The new question was announced under a new id and declined
A9 raising the dial pass zoo.autonomy act-on-key: the account holds it, harnessd stays at suggest with autonomyRequested: act-on-key and a confirm [y/n] let your daemon act at act-on-key? …. daemon_confirm before daemon_shown → NOT_SHOWN; over TCP → LOCAL_SOCKET_REQUIRED; shown + 450 ms → accepted, autonomy: act-on-key; the same nonce again → STALE_CONFIRM
A10 a lesson, end to end pass pair.jsonc { "model": true } applied only after its daemon_confirm. A turn, then "no, always run the migration with --dry-run first…": the learner distilled it through the one-shot worker (the scripted engine) and proposed [y/n/s] teach your agents "run-migrations-safely"? you corrected claude. 30 s later, the whole SKILL.md as detail. A tool's y and a forged nonce were refused; the window's y → learned, one learn: commit in ~/.harness/lessons, zoo.lesson → 200 and the id in progress.lessons. A Store harness (autonomous/starter, installed --link from store/starter) launched in that project got a read-only copy in its runtime; harness pair lessons revert <id> → unlearn: commit, the skill out of skills/, the runtime copy withdrawn
A11 talk pass daemon_talk over TCP → LOCAL_SOCKET_REQUIRED, from a tool → UI_ONLY; from the window → { ok, started }: the pair harness started in …/pair/workspace on the (scripted) engine and its first turn was "what is waiting on me?"
A12 question-id stability (timer + cursor) pass Muse's status line ticking inside the dialog for 12 s, the cursor moved down and back: announced once; the dial's question_response for that first id typed 1
A13 a prompt queued right behind a turn pass (6/6) its permission question was announced every time here; the race it guards against was seen once in an earlier run (bug 2)

Daemons off

# scenario result what was seen
B1 server off (HARNESS_DAEMONS=false) pass per harnessd start exactly one GET /api/zoo (404); then 8 turns and a question answered, 70 s past a report interval: 0 POST /api/zoo/ops, 0 zoo_changed, no daemon_* frame pushed. daemon_act, daemon_talk, daemon_confirm → DAEMONS_OFF; the pair request → DAEMONS_OFF; a window's /api/zoo → 404. (The harnessd being replaced, still on, flushed its last minute of turns on shutdown into the just-switched-off server: 404, dropped, as designed.)
D2 the desktop's zoo client, server off pass loaded=false source=none, nothing drawn (on 80daf6dd it fell back to the guest zoo and drew the first-egg hint: bug 3, fixed in bd394a7e)
B2 the local kill switch (HARNESS_DAEMONS=0, server on) pass 10 s after start: 0 zoo requests; /api/status daemons: { on: false, server: unknown, killed: true }; a window's /api/zoo → 404 DAEMONS_OFF without asking the backend; no daemon_* frames
D3 the desktop's zoo client under the kill switch pass loaded=false, nothing drawn

Mixed versions

# scenario result what was seen
C1 new harnessd + old backend (origin/main) pass the probe got 404 once, daemons idle, 0 zoo ops over a report interval; desk read and ops, agents_list, a turn and a question answered from the dial all work
C2 old harnessd (origin/main) + new backend (daemons on) pass the same flows work; the old harnessd sends no zoo traffic at all. It answers a question_response by typing it but sends no question_response_result (that reply came with #367), so the pane was the proof
C3 new client code + old harnessd pass /api/zoo → 404; daemon_act and daemon_talk → UNSUPPORTED; the connection keeps working (agents_list); nothing pushed
D4 the desktop's zoo client against the old harnessd pass loaded=false, nothing drawn

Before and after the question-id fix (scenario 6)

Recorded on daemons d9bc36d9, before daemons-fixes (d27e7493) merged, with the same ticking dialog and cursor moves as A12: 7 announcements in 12 s (a new requestId on almost every 1.5 s poll, each one a needs-you alert, a sound and a dial push), and the dial's question_response for the first id was refused STALE_QUESTION with nothing typed. After the merge: one announcement, and the answer typed 1. The fix strips live status lines and cursor marks from the fingerprint (dialogSignature); the fake paints Muse's own format, ◇ Calling tools (21s · esc to interrupt). The signature knows the shapes the engines paint today, not every shape: against the built code, (3s · esc to interrupt) → (4s · …) and Hermes' (212s) → (213s) keep the id, while a bare waiting 3s → waiting 4s still makes a new one: an engine that starts painting its timer that way brings the bug back.

Bugs found

  1. No daemon_state to a window already attached when pairing comes on (daemons; low–medium). A2, in all five runs. PairBrain.refresh() (cli/src/pair/brain.ts) turns active and calls fleet.start(), which emits nothing (pair/fleet.ts), and never sends state; only a window that attaches later gets it (clientAttached). So the window the person hatched and consented in keeps pair: null (roster lines, no needs, no dial) until something else changes the state: a harness event, a confirm, a proposal. Fix: when refresh() turns active with clients attached, send daemon_state (as it already does when it turns off).
  2. A Stop hook can close the next turn (pre-existing, same code on origin/main; medium, silent). Seen in one of the five runs, right after a harnessd restart while it was restoring four harnesses: the Claude turn-stop handler (cli.ts, if (session.engine !== 'claude') return onwards) polls the transcript, finds a turn open, waits the 1.5 s grace and force-closes it. But the open turn was the next one: its prompt had landed between the Stop hook and the poll (Claude submits a prompt typed while it worked as soon as the Stop hook returns). Log: turn-stop 37.414, next turn started 37.565, force-closed by Stop hook (after grace) 38.060. That turn's permission dialog was then never announced (the watcher stops with the turn): no needs-you line, no dial push, nothing for the pair; the recap said "done" with no text (empty assistant text → done). It needs a busy event loop to lose the race; A13 (queued prompts on an idle daemon) passes 6/6. Fix: close only the turn the Stop hook was for (remember the open turn's start when the hook arrives, and do nothing if a newer one opened since).
  3. The desktop showed the guest zoo when daemons were off (desktop, 80daf6dd; fixed by bd394a7e). With the server off, the kill switch, or an old harnessd, ApiClient.zoo() returned null and ZooController adopted the local guest zoo: loaded=true source=local, first-egg hint drawn. D2–D4 failed on 80daf6dd and pass on bd394a7e ("Daemons off are invisible and free").
  4. The question id followed the dialog's timer and cursor (daemons d9bc36d9; fixed by d27e7493 and verified here, see above).

Smaller things seen on the way:

  • agent_create sent while harnessd is still booting is answered UNSUPPORTED_ON_REMOTE (pre-existing): the handler is wired after agents are restored and the first reconcile, while /api/status already answers. A window that creates a harness in that window is told the machine is remote. The kit waits for discoveryReady and retries.
  • harnessd has no Unix socket when its data folder's path is longer than 96 bytes (lib/localSocket.ts), and then no window can press a daemon key (LOCAL_SOCKET_REQUIRED for everything). A normal home is far below that; the sandbox needed a short link for it. harnessd rightly refuses a linked data folder itself (O_NOFOLLOW), so the link is its parent.
  • The backend binds 0.0.0.0 (hard-coded in server.ts), so the sandbox's backend is reachable from the local network while it runs; only the random token opens it.
  • DISABLE_GRID_INSTALL=true does not stop harnessd from downloading the managed grid runtime at start; only HARNESS_GRID_BIN does. And cli.js stop creates the data folder it stops. Both matter only for isolated runs like this one.
  • A lesson from a correction is its project's: a Store harness in another folder does not get it (as LEARNING.md says). The first version of A10 checked the wrong folder.

What could not be run, and why

  • Real engines. By rule: no real Claude or Codex, no real credential. The scripted engine stands in for the pane, the transcript, the hooks, the one-shot model call behind distilling, and the pair harness. So talk was checked up to the words reaching the pair harness's first turn; its reply, and a model calling the harnessd MCP tools, were not.
  • The brief on return. It needs harnessd up for 15 minutes before the absence begins (a restart is a baseline); the run keeps each harnessd for about six.
  • Night, week, marathon and history eggs. Only the turn egg and a level-up were driven through zoo.turn; the rest are the server's arithmetic, covered by the backend's tests.
  • Across machines. One machine: no sealed pair_*, no relayed keys.
  • hn and the phone. Not in this branch; the desktop was checked through its zoo client (the gate for everything it draws), not its pixels or its daemon_* client.
  • An old desktop app against a new harnessd. Not asked for, not run: with pairing on, harnessd pushes daemon_state/daemon_say to every local window, and an app from before daemons has to ignore them.