Skip to content

fleet gh cache daemon: sandbox runs no local daemon (ensure step missing); laptop daemon alive but unsupervised #14099

Done

Description

@developing-today-fleet

fleet gh cache daemon: sandbox runs no local daemon (the ensure step the design doc describes does not exist); laptop daemon alive but unsupervised

Filed 2026-11-23 (diagnosis lane FLEET-GH-DAEMON). Design of record: doc/agents/gh-cache-daemon.md (code#10742) — the rule is a local cache daemon runs at all times on any host that runs fleet gh, and the doc states ~/tools/init-ensure.sh keeps the sandbox one running. That claim does not match the installed estate.

Symptom / measured impact (2026-11-23 evening)

  • Multiple lanes (AUDIT-7 first) found fleet gh api from the Muse sandbox hanging / falling back; work routed around it via the GitHub App route (~/tools/gh-post) all evening.
  • Reproduced tonight from the sandbox: fleet gh cache-status → both addresses DOWN; a timed fleet gh api rate_limit took 26.7s with the stderr notice no cache daemon answered (tried 127.0.0.1:4802, 100.99.113.103:4802 …); resolving in-process. In-process resolution is the slow path by design (~120s per call when the secrets broker is cold, per the design doc's 2026-11-22 measurement).

Diagnosis (verified on both hosts tonight)

  1. Sandbox: no local daemon — the actual defect. Nothing listens on 127.0.0.1:4802 in the sandbox. Grep finds no cache-serve step in ~/tools/init-ensure.sh, ~/tools/init.sh, the laptop-channel heal script, or the canonical scripts/boot-hook/init.sh in hatch-personal — the ensure leg the design doc describes was never implemented (or was lost). Nothing starts the daemon at boot and nothing revives it.
  2. Sandbox → laptop fallback is unreachable by construction. The client's second address, 100.99.113.103:4802, fails from the sandbox with Operation not permitted (os error 1) — the sandbox cell's egress policy denies the direct tailnet connect before it leaves the host (same EPERM class as the tailnet findings on Broker-stack performance under load: queue reads 8-28s, fleet gh +5s vs direct, DERP-only tailnet path (490-873ms) #13894). The laptop daemon also binds loopback only (default bind), so the tailnet leg could not be served even with egress granted. Per the design doc this leg is a fallback, not the plan — the plan is a local daemon per host.
  3. Laptop daemon: alive and healthy — not down. fleet gh cache-serve pid 251919, started 2026-11-23 19:36 CST, cache-status on the laptop: 127.0.0.1:4802 UP, entries=11, hits=55018, misses=355, uptime≈3h46m. Laptop-local calls are fast (0.59s measured). The evening's laptop-side slowness reports predate the 19:36 start or were other seats' fallbacks. Weaknesses, recorded for follow-up: it is unsupervised — an ad-hoc child of an OpenCode session shell (no systemd user unit; it dies with that session tree and nothing restarts it), and it runs a since-replaced binary (exe shows (deleted) after the fleet-static-74eee89 flip).

Fix applied (sandbox, tonight)

Started the sandbox daemon with the design doc's own pattern: setsid nohup fleet gh cache-serve (log ~/logs/gh-cache-daemon.log on the sandbox). Verified:

  • fleet gh cache-status in the sandbox: 127.0.0.1:4802 UP (entries=10 after warm-up, hits accumulating).
  • Timed warm reads from the sandbox: fleet gh api rate_limit → 1.45s and 1.47s (was 26.7s in-process). No fallback notice.

The laptop daemon was deliberately not restarted: it is healthy and serving production lane traffic; a restart only buys a binary refresh at the cost of a cold cache mid-evening.

Follow-ups (the durable fixes)

  1. Implement the missing ensure leg: add the gh cache daemon to the sandbox init-ensure pattern (pgrep/port gate, setsid nohup spawn — same shape as the sandbox-local secrets broker leg), in the canonical scripts in hatch-personal as well as the installed copies, so the daemon survives VM recycles. Until then, the manually started daemon dies with the sandbox.
  2. Supervise the laptop daemon: a systemd user unit (or the laptop equivalent of the ensure pattern) instead of an OpenCode session's ad-hoc child; pick up current binaries on flip.
  3. Optional: correct doc/agents/gh-cache-daemon.md's init-ensure claim once (1) lands, so the doc stops asserting a keeper that doesn't exist.
{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-24T05:25:54Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": null,
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": null,
    "auth_subject": "archer",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Activity

  1. developing-today commented on Nov 24, 2026

    @developing-today
    Contributor
  2. developing-today-fleet commented on Nov 24, 2026

    @developing-today-fleet
    ContributorAuthor

    Fix record — GH-DAEMON-FIX lane, 2026-11-24

    Drew's order ("fix the daemon") executed. Two of the three follow-ups are landed and proven live; the third (the doc correction) is fully prepared below and its landing is blocked only by repo mechanics in this lane — see the end.

    1. Sandbox init-ensure leg — DONE, proven

    ~/tools/init-ensure.sh now carries a gh credential-cache daemon leg, in the same ensure pattern as the session proxy and the sandbox-local secrets broker: pgrep/port gate on 127.0.0.1:4802, flock, setsid nohup spawn from the test-exec'd fleet binary (FLEET_BIN_OK — the #12498 lesson), best-effort, log ~/logs/gh-cache-daemon.log. It runs after the secrets-broker leg because the daemon mints through the secrets chain. (init-ensure.sh is ~/tools-only by the boot-hook README's own statement — init.sh/nix-ensure.sh are the scripts with canonical copies in hatch-personal, and neither carries these prelude legs — so there was no canonical copy to mirror; the README documentation bullet is prepared below.)

    Kill-and-ensure proof (2026-11-24 ~06:05–06:07 CST):

    • Baseline: manually-started daemon pid 3587, warm gh api read of this issue in 2.3 s.
    • Killed pid 3587 exactly; port 4802 confirmed down.
    • Ran ~/tools/init-ensure.sh (0.59 s, exit 0): new daemon pid 7051 (/home/hatch/tools/fleet gh cache-serve) listening on 127.0.0.1:4802.
    • Reads through the fresh daemon: 4.9 s cold (minting), 3.3 s warm; fleet gh cache-status UP (hits recorded).
    • Idempotence: a second init-ensure.sh run left pid 7051 untouched.

    2. Laptop daemon supervision — DONE, proven

    The unsupervised OpenCode-session child (pid 251919, exe /home/user/.local/bin/fleet (deleted), parent bash 251918 under opencode serve) is replaced by a systemd user unit in the estate's normal shape (mirroring mcpx-bridge.service):

    • Unit: ~/.config/systemd/user/fleet-gh-cache.service — ExecStart=%h/.local/bin/fleet gh cache-serve, Restart=on-failure, RestartSec=5, WantedBy=default.target; enabled. File sha256 3524c2e5baf79cad4be974562458245500622d0e343989e11f18bdc2c0813fcd.
    • No-gap sequencing: a transient systemd instance was first started on the tailnet bind (100.99.113.103:4802, pid 215662) and verified UP via cache-status, so a supervised-form daemon was serving before the old process was touched. Old pid 251919 was then killed by exact PID (its bash parent exited with it), the permanent unit started immediately, and the transient was stopped only after the permanent one verified.
    • Result: fleet-gh-cache.service active/running, MainPID 218796, listening on 127.0.0.1:4802 with the current (non-deleted) binary. Timed fleet gh api reads on the laptop through it: 1.09 s / 1.20 s. The cold cache refilled within seconds (entries=10 at first status check).

    3. Design-doc correction — PREPARED, landing blocked in this lane

    For doc/agents/gh-cache-daemon.md, "The rule" section — replace the sandbox sentence (which currently asserts the ensure leg as fact) with:

    On Muse sandboxes, ~/tools/init-ensure.sh keeps it running (leg added 2026-11-24, code#14099 — before that the leg did not exist and this paragraph described a fiction) in the same ensure pattern as the session proxy and the sandbox-local secrets broker (pgrep/port gate, flock, setsid nohup spawn from the test-exec'd fleet binary, best-effort; log ~/logs/gh-cache-daemon.log) — if fleet gh is slow on a sandbox, run init-ensure.sh and check fleet gh cache-status before anything else. On the laptop the daemon is a supervised systemd user unit, fleet-gh-cache.service (~/.config/systemd/user/, Restart=on-failure), not a session child.

    And in hatch-personal scripts/boot-hook/README.md §6, after the "Session proxy" bullet:

    • gh credential-cache daemon: init-ensure.sh also keeps the local fleet gh cache-serve daemon (127.0.0.1:4802) alive in the same pattern (leg added 2026-11-24, code#14099); the laptop's daemon is a systemd user unit (fleet-gh-cache.service).

    Why not landed here: every repo-write route from this lane failed or was barred — the sandbox code clone's git fetch died writing pack files (Operation not permitted on .git/objects/pack/...), a second sandbox clone's fetch stalled the same way, the hatch-personal git worktree add failed mid-checkout (unable to write file .../packet-code-2818-coverage.json, index reset failed), and the laptop worktree route (~/git/wt-gh-daemon-doc, branch archer/gh-daemon-doc-14099, created at origin/main a8dd96c) was flagged by a platform execution-risk check, after which this lane did not run git or edits inside it. Per the standing route ruling, the two text landings above belong to a laptop-local OpenCode session, which can apply them verbatim and open the PRs; the laptop worktree is still there for it (or it can start its own).

    Nothing else is outstanding on this issue: the daemon now self-heals on the sandbox within one init-ensure run and is supervised on the laptop.

  3. dezren39 commented on Nov 24, 2026

    @dezren39
    Member

    Record for code#14099 (both prepared texts applied verbatim from comment 7123671575). Neither PR is merged; Archer merges.

    1. developing-today/code: PR #14125 — #14125
    Branch archer/gh-daemon-doc-14099 (worktree ~/git/wt-gh-daemon-doc).

    git diff origin/main...HEAD --stat
     doc/agents/gh-cache-daemon.md | 6 +-----
     1 file changed, 1 insertion(+), 5 deletions(-)
    

    Confirmed: only the "## The rule" paragraph changed. The following "Note the secrets broker..." sentence is untouched.

    2. dezren39/hatch-personal: PR #82 — https://github.com/dezren39/hatch-personal/pull/82
    Branch archer/gh-daemon-readme-14099 (worktree ~/git/wt-gh-daemon-readme, cut from origin/main of ~/hatch-personal).

    git diff origin/main...HEAD --stat
     scripts/boot-hook/README.md | 1 +
     1 file changed, 1 insertion(+)
    

    Confirmed: a single bullet inserted after the "Session proxy (laptop-agent broker)" bullet. Nothing else changed.

  4. dezren39 commented on Nov 24, 2026

    @dezren39
    Member

    Triage verdict (lane code-j, 2026-11-24): resolved in substance. Sandbox ensure leg proven (kill-and-ensure), laptop daemon supervised by a systemd user unit (fix record comment), and the design-doc correction is merged as PR #14125. Closing as implemented. Refs #14158.

  5. dezren39 commented on Nov 24, 2026

    @dezren39
    Member

    Closed as implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions