Skip to content

fix(observer,create): pid-robust observer stop (#45) + loud/strict create failures#47

Merged
ikeikeikeike merged 1 commit into
mainfrom
fix/observer-pid-and-create-strict
Jun 28, 2026
Merged

fix(observer,create): pid-robust observer stop (#45) + loud/strict create failures#47
ikeikeikeike merged 1 commit into
mainfrom
fix/observer-pid-and-create-strict

Conversation

@ikeikeikeike

Copy link
Copy Markdown
Member

Two dogfood-hardening fixes for the worktree/observer surfaces.

observer stop / status pid robustness (#45). Both trusted <project>/observer.pid exclusively, so a stale or wrong pid (a spawn race, or a daemon launched out-of-band) made stop report "not running" and orphan a live daemon that kept ticking. The _run-daemon loop now writes its OWN pid on startup (the authoritative record), and stop / status fall back to discovering a live observer _run-daemon --root <root> process via the process table when the pid file is stale or missing. Found by dogfooding: a leftover daemon (pid 49920) survived observer stop because the pid file held a dead pid (85654).

bough create surfaces post-setup failures (and gains --strict). A failed git worktree add for one repo, or a failed post_create hook (e.g. a migration), was logged mid-stream but create still exited 0 — so a WorktreeCreate hook looked fully successful when the environment was half-built. create now prints a prominent final WARNING summarising every failure (the worktree path is still emitted so Claude Code can cd in), and --strict turns any such failure into a non-zero exit for CI / scripted callers. Default stays best-effort to preserve the hook's cd contract.

Closes #45

Test plan

  • go test ./internal/cli/... green — new internal/cli/observer_daemon_test.go (TestParseDaemonPID: right-root match, skip-self, skip-dead, prefix-collision guard).
  • golangci-lint run ./internal/cli/... → 0 issues.
  • Manually traced against the dogfood incident: a daemon whose pid file held a dead pid is now found by the --root command-line fallback.

…ailures

#45: observer stop/status trusted observer.pid exclusively, so a stale or wrong pid (spawn race / out-of-band daemon) made stop report 'not running' and orphan a live daemon. The _run-daemon loop now writes its own pid on startup, and stop/status fall back to discovering a live 'observer _run-daemon --root <root>' via the process table (parseDaemonPID, unit-tested).

create: a failed worktree-add or post_create hook was logged but create still exited 0, so a half-built env looked fully successful. materializeRepositories + runPostCreateHooks now return the failures; create prints a prominent final WARNING (still emitting the worktree path for the cd contract) and --strict makes any failure a non-zero exit for CI.
@ikeikeikeike
ikeikeikeike merged commit a07581d into main Jun 28, 2026
9 checks passed
@ikeikeikeike
ikeikeikeike deleted the fix/observer-pid-and-create-strict branch June 28, 2026 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

observer stop: trusts a stale .observer.pid and misses the live daemon

1 participant