Skip to content

fix: stop ruflo daemon leak + statusline sqlite3 churn; consolidate shell helpers (#3) - #5

Merged
pacphi merged 1 commit into
mainfrom
fix/daemon-statusline-resource-leak
May 29, 2026
Merged

fix: stop ruflo daemon leak + statusline sqlite3 churn; consolidate shell helpers (#3)#5
pacphi merged 1 commit into
mainfrom
fix/daemon-statusline-resource-leak

Conversation

@pacphi

@pacphi pacphi commented May 29, 2026

Copy link
Copy Markdown
Owner

Summary

Investigates and fixes the three claims in #3 (Claude Code ENOSPC session crashes), then consolidates the kit's duplicated shell logic for maintainability.

Reproducibility verdict (#3)

  • RC1 — daemon leak: confirmed. ruflo-setup-project started a per-workspace ruflo daemon that nothing ever stopped; throwaway/removed workspaces (e.g. ruflo-parity-test's /tmp dirs) left orphans running forever (18 observed live, 14 for dead workspaces).
  • RC2 — statusline sqlite3 churn: confirmed (with a correction). The activation footer spawned 2–4 sqlite3 subprocesses every render (refreshMs: 5000) against a ~52 MB DB. Each was already timeout:1500-bounded, so the report's "hangs indefinitely" is inaccurate — the real issue is per-5s subprocess churn.
  • RC3 — daemon.autoStart: true: refuted. The kit never wrote that key (upstream ruflo init does; it was false here). A defensive guard is added regardless.

Resource fix

  • Idempotent per-workspace daemon start; defensive claudeFlow.daemon.autoStart=false when present and true.
  • New ruflo-daemon-gc reaps daemons whose --workspace is gone; ruflo-parity-test stops its throwaway daemon on every exit; uninstall.sh stops stale daemons (always) and this-repo's (--this-project).
  • Statusline footer caches QE metrics (RUFLO_QE_STATUSLINE_TTL_MS, default 60s) and makes ≤1 sqlite3 spawn per window (SQL on stdin + .bail off, e.stdout recovery). Rendered output is byte-identical for the same DB state.

Maintainability (helper consolidation)

  • New shell/ruflo-lib.sh is the single home for colored output, ask_yes_no, run, PATH guards, the daemon ps-parser, and the Node-ABI / native-better-sqlite3 primitives that were copy-pasted across install.sh, uninstall.sh, and the bin/ helpers. install.sh deploys it to ~/.config/ruflo/ so the standalone bin scripts can source it from a stable path; uninstall.sh removes it.
  • Replaced ruflo-enable-learning's eval-based assertion harness with direct if/then checks.
  • All 9 shell files are shellcheck-clean at every severity (pre-existing + newly introduced).

Verification

  • install.sh --full --yes on the dev machine: npm packages installed (ruflo v3.10.8), 6 agentdb locations patched native v12.10.0, self-learning 5/5 ACTIVE (proves the installed bins source the deployed lib).
  • ruflo-onboard in this repo: "Daemon already running for this workspace (not starting another)" (idempotent fix, live), statusline footer + version pinned, memory write verified, doctor 13✓/4⚠ (warnings pre-existing/environmental), learning loop verified (patterns 0→7, 50 learned).
  • bash -n + shellcheck clean across all 9 scripts; cross-shell (bash + zsh) source checks pass.

Docs

docs/TROUBLESHOOTING.md gains a daemon-lifecycle / ruflo-daemon-gc / CLAUDE_CODE_TMPDIR section; design spec + implementation plan added under docs/superpowers/.

Closes #3.

…hell helpers (#3)

Investigate and fix the three claims in issue #3 (Claude Code ENOSPC session
crashes), then consolidate the kit's duplicated shell logic for maintainability.

Resource fix (issue #3):
- ruflo-setup-project starts the per-workspace daemon idempotently (never a
  second daemon for a workspace that already has one) and defensively forces
  claudeFlow.daemon.autoStart=false when that key is present and true.
- New ruflo-daemon-gc reaps daemons whose --workspace no longer exists;
  ruflo-parity-test stops its throwaway-workspace daemon on every exit;
  uninstall.sh stops stale daemons (always) + this-repo's (--this-project).
- The statusline activation footer caches QE metrics
  (RUFLO_QE_STATUSLINE_TTL_MS, default 60s) and makes at most one sqlite3
  spawn per window (SQL on stdin + ".bail off", e.stdout recovery), down from
  2-4 spawns every 5s; rendered output is unchanged.
- RC3 refuted: the kit never wrote daemon.autoStart:true (upstream ruflo init
  does); the defensive guard is added regardless.

Maintainability:
- New shell/ruflo-lib.sh is the single home for colored output, ask_yes_no,
  run, PATH guards, the daemon ps-parser, and Node-ABI / native-better-sqlite3
  primitives that were copy-pasted across install.sh, uninstall.sh, and the
  bin/ helpers. install.sh deploys it to ~/.config/ruflo/ so the standalone
  bin scripts can source it from a stable path; uninstall.sh removes it.
- Replaced ruflo-enable-learning's eval-based assertion harness with direct
  if/then checks. All 9 shell files are shellcheck-clean at every severity.

Verified on the dev machine: install.sh --full --yes (self-learning 5/5
active, 6 agentdb locations native) and ruflo-onboard (idempotent daemon
confirmed, learning loop verified, memory write verified) both pass.

Docs: docs/TROUBLESHOOTING.md (daemon lifecycle, ruflo-daemon-gc,
CLAUDE_CODE_TMPDIR) plus the design spec and implementation plan under
docs/superpowers/.
@pacphi
pacphi merged commit 03aa814 into main May 29, 2026
@pacphi
pacphi deleted the fix/daemon-statusline-resource-leak branch May 29, 2026 17:24
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.

install.sh fills Claude Code sandbox tmpfs, causing session crashes (ENOSPC)

1 participant