Repository navigation
Conversation
Single Go binary: a daemon supervising agent runs over a Unix-socket /v1 API, and the CLI that drives it (spec §4, §10). - XDG-native layout identical on macOS and Linux, with socket-length fallback and 0700 state/runtime dirs - Strict TOML config and manifests with file:line:key diagnostics - claude-code, codex, and exec adapters with overridable argv templates and a minimal run environment - Run store (run.json, events.jsonl, timestamped logs), supervisor with timeouts, stop grace, concurrency caps, and lost-run recovery - Advisory policy: cwd precondition plus best-effort post-run scan - plan/apply with a managed.toml ledger; agents register on apply - launchd/systemd user service management, doctor, uninstall - install.sh, GoReleaser (cask + cosign keyless), CI and release workflows gated on the §15 acceptance suite docs/spec.md carries the spec with an Amendments section recording deviations (e.g. [runtime] -> [runtime_options], which was invalid TOML). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Linux stamps mtimes from a coarse kernel clock that can lag time.Now() by a few milliseconds, so files written right after launch could get an mtime before the window start and escape the scan (TestScan failed on ubuntu-latest). Probe the filesystem clock by touching a file in the state dir just before exec and use its mtime as the window start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hunt4Bugs
commented
Sep 28, 2026
Hunt4Bugs
left a comment
Owner
Author
There was a problem hiding this comment.
Review of the v0.1 implementation. The two I'd fix before merging are the shutdown/launch race in supervisor.go and agentsd run exiting early when a follower gets cut off. The rest are smaller correctness issues plus a few efficiency and cleanup notes. Each is in its own thread below.
- Supervisor: start the process under the lock and refuse if a stop or shutdown already arrived, so a run mid-launch can no longer be orphaned; Stop now works on a pending run. Snapshot runs under the lock (data race). Reap leftover process-group members after the main process exits and record group_reaped on run.exited. - Streams: every sink item gets a strictly increasing nanosecond timestamp and a seq, so replay order matches emission order. Replay reads files up to offsets recorded under the lock instead of holding it. Followers that fall behind get stream.truncated and the client resumes with after=<seq>; complete streams end with stream.end, so `agentsd run` no longer exits early on a cut-off follower. - Adapter: prompts starting with "-" go to claude/codex on stdin, never argv, so they cannot be parsed as flags. - plan: remove nested apply-created dirs in a single apply. - Agent listings find each agent's last run in one pass. - Cleanup: cmp.Or instead of two firstNonEmpty helpers; drop filter.go. Spec amendments 13-16 document the behavior changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hunt4Bugs
commented
Sep 28, 2026
- wait() now marks the proc exited and stops the timeout/kill timers before reaping leftover group members. onTimeout, Stop and Shutdown skip an exited proc, so a timeout or stop landing during the reap can no longer record a clean exit as timed_out or stopped. - cmd.Start() runs outside the supervisor lock. A stop or shutdown that arrives while the process is starting sets stopReq (with its grace), which launch applies to the new process group as soon as Start returns. Tests: TestCleanExitDuringReapKeepsStatus (fails on the previous ordering) and TestStopDuringStartSignalsNewProcess. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the agentsd v0.1 spec in Go as a single binary: a daemon that supervises agent runs, and the CLI that talks to it over a Unix-socket
/v1API. The spec now lives atdocs/spec.md. Its Amendments section records every deviation from the draft.Core
0700. A socket path that is too long falls back to/tmp/agentsd-$UID.keychain:/op://secret references are errors.claude-code,codex, andexec. Argv templates can be overridden in config, and runs get a minimal environment containing onlyenv.pass,env.set, and theAGENTSD_*variables.lostafter a daemon crash, and graceful shutdown.run.json,events.jsonl, and timestamped stdout/stderr logs. Following a run replays its history and then streams live events with no gaps.SO_PEERCREDon Linux,LOCAL_PEERCREDon macOS).Declarative, service, and diagnostics
plan/applykeep amanaged.tomlledger.applynever deletes anything it didn't create, or any non-empty directory, and it registers agents with the daemon.service install|uninstall|start|stop|restart|statusmanages a launchd agent or a systemd user unit, with--env-filesupport. It only controls a service that was loaded from its own service file.doctorimplements every §10 check.uninstall --purge-statenever touches config or the AHS roots.Distribution
install.sh: POSIX sh, 149 lines, wrapped inmain(). It verifies the checksum, and the cosign signature when cosign is installed. It replaces the binary with an atomic rename..sigstore.jsonbundle), and publishes a Homebrew cask.-race, the e2e acceptance suite, the install.sh tests, golangci-lint, shellcheck, and a GoReleaser dry run. The release workflow is gated on CI passing.Deviations from the draft spec (see docs/spec.md → Amendments)
[runtime]→[runtime_options]. The draft's examples were invalid TOML:runtimewas defined as both a string and a table.applyhas recorded inmanaged.toml.checksums.txt.sigstore.jsoninstead ofchecksums.txt.sig.Test plan
make test: vet plus unit tests with-race(macOS)make e2e: seven acceptance tests against an isolated HOME: lifecycle and idempotentplan, lost on restart, policy violation, doctor detections,--jsonand exit codes everywhere, no writes outside allowed locations, and a purge that keeps config and roots (macOS)make install-test: happy path, reinstall, checksum-mismatch abort, truncated script does nothinggoreleaser release --snapshotbuilds all four targets and the cask.GOOS=linuxvet and build (amd64 and arm64)ubuntu-latest. The Linux tests have only run in CI; Docker wasn't available locally.agentsd service installon macOS (launchd) and Linux (systemd)Hunt4Bugs/homebrew-tapand theHOMEBREW_TAP_TOKENsecret🤖 Generated with Claude Code