Skip to content

fix: enums, daemon cwd crash, L0 cleanup after gc/killall - #18

Merged
araa47 merged 4 commits into
mainfrom
fix/enums-gc-cleanup-notifications
Mar 21, 2026
Merged

fix: enums, daemon cwd crash, L0 cleanup after gc/killall#18
araa47 merged 4 commits into
mainfrom
fix/enums-gc-cleanup-notifications

Conversation

@araa47

@araa47 araa47 commented Mar 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Daemon cwd crash fix: The daemon inherited its cwd from the spawning process. When that cwd was a deleted worktree (.worktrees/<name>), subprocesses like openclaw system event crashed on startup because Node.js requires a valid cwd. Fixed by setting current_dir($HOME) on all subprocess spawns in run_out() and chdir($HOME) in the daemon's double-fork grandchild.
  • L0 cleanup after gc/killall: After gc or killall removed all child workers, the L0 orchestrator entry stayed in state.json, making orca list show a stale "orc" entry. Added gc_orphaned_l0() that removes L0 entries with no remaining children.
  • Backend/Orchestrator/WorkerStatus enums: Replaced raw string comparisons ("running", "claude", etc.) with type-safe enums throughout the codebase. Serde representations remain backwards-compatible with existing state.json files. Aliases like "cc"Backend::Claude are handled in deserialization.

Test plan

  • cargo fmt --check passes
  • cargo clippy -- -D warnings passes
  • cargo nextest run — 643 tests pass
  • Manual: spawn workers under openclaw, kill them, verify orca list shows clean state
  • Manual: verify daemon notifications reach openclaw after worktree deletion

🤖 Generated with Claude Code

araa47 and others added 3 commits March 21, 2026 17:05
- Set stable cwd ($HOME) for all subprocess spawns so the daemon
  doesn't crash openclaw/Node.js when the inherited cwd is a deleted
  worktree.
- chdir daemon grandchild to $HOME immediately after double-fork.
- Add gc_orphaned_l0() to remove L0 orchestrator entries that have
  no remaining children after gc or killall.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tatus enums

Add `src/types/mod.rs` with three enums (`Backend`, `Orchestrator`,
`WorkerStatus`) that carry serde, `FromStr`, and `Display` impls.
Worker struct fields are now typed instead of `String`, so invalid
values are caught at compile time.  Existing `state.json` files
deserialise without changes thanks to the same lowercase string
representation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Mar 21, 2026

Copy link
Copy Markdown

🧪 Coverage Report

Metric Coverage
Lines 85.76% (15745 lines, 2242 missed)
Functions 94.86%
Regions 85.85%
📄 Coverage by file
File Lines Functions Regions
cli.rs 89.52% 98.05% 90.87%
cli/mod.rs 77.93% 85.14% 77.49%
config.rs 94.94% 95.71% 94.35%
config/mod.rs 90.57% 90.00% 87.10%
daemon.rs 80.05% 92.47% 81.36%
daemon/mod.rs 42.07% 77.11% 39.87%
events.rs 99.44% 100.00% 97.63%
events/mod.rs 98.72% 100.00% 92.86%
main.rs 100.00% 100.00% 100.00%
names.rs 100.00% 100.00% 100.00%
names/mod.rs 100.00% 100.00% 100.00%
prompts.rs 100.00% 100.00% 100.00%
prompts/mod.rs 100.00% 100.00% 100.00%
spawn.rs 93.08% 96.43% 92.57%
spawn/mod.rs 90.15% 93.55% 87.94%
state.rs 98.09% 93.33% 96.13%
state/mod.rs 95.32% 87.23% 87.77%
tmux.rs 97.53% 100.00% 96.69%
tmux/mod.rs 93.04% 99.15% 91.85%
types/mod.rs 96.50% 93.02% 96.73%
wake.rs 98.60% 100.00% 98.93%
wake/mod.rs 95.08% 100.00% 95.67%
worktree.rs 95.25% 100.00% 95.61%
worktree/mod.rs 84.76% 100.00% 83.91%

Coverage must not decrease. See CONTRIBUTING.md for policy.

When killing or GC-ing nested workers, parent worktrees were removed
before their children, causing git worktree remove failures for any
nested .worktrees paths. Sort workers deepest-first (L3 → L2 → L1)
before processing. Also bump version to 0.0.9.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@araa47
araa47 merged commit 7749dbd into main Mar 21, 2026
3 checks passed
@araa47
araa47 deleted the fix/enums-gc-cleanup-notifications branch March 21, 2026 12:55
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.

1 participant