fix: stop ruflo daemon leak + statusline sqlite3 churn; consolidate shell helpers (#3) - #5
Merged
Merged
Conversation
…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/.
10 tasks
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
Investigates and fixes the three claims in #3 (Claude Code
ENOSPCsession crashes), then consolidates the kit's duplicated shell logic for maintainability.Reproducibility verdict (#3)
ruflo-setup-projectstarted a per-workspaceruflo daemonthat nothing ever stopped; throwaway/removed workspaces (e.g.ruflo-parity-test's/tmpdirs) left orphans running forever (18 observed live, 14 for dead workspaces).sqlite3churn: confirmed (with a correction). The activation footer spawned 2–4sqlite3subprocesses every render (refreshMs: 5000) against a ~52 MB DB. Each was alreadytimeout:1500-bounded, so the report's "hangs indefinitely" is inaccurate — the real issue is per-5s subprocess churn.daemon.autoStart: true: refuted. The kit never wrote that key (upstreamruflo initdoes; it wasfalsehere). A defensive guard is added regardless.Resource fix
claudeFlow.daemon.autoStart=falsewhen present and true.ruflo-daemon-gcreaps daemons whose--workspaceis gone;ruflo-parity-teststops its throwaway daemon on every exit;uninstall.shstops stale daemons (always) and this-repo's (--this-project).RUFLO_QE_STATUSLINE_TTL_MS, default 60s) and makes ≤1sqlite3spawn per window (SQL on stdin +.bail off,e.stdoutrecovery). Rendered output is byte-identical for the same DB state.Maintainability (helper consolidation)
shell/ruflo-lib.shis the single home for colored output,ask_yes_no,run, PATH guards, the daemon ps-parser, and the Node-ABI / native-better-sqlite3primitives that were copy-pasted acrossinstall.sh,uninstall.sh, and thebin/helpers.install.shdeploys it to~/.config/ruflo/so the standalone bin scripts can source it from a stable path;uninstall.shremoves it.ruflo-enable-learning'seval-based assertion harness with directif/thenchecks.shellcheck-clean at every severity (pre-existing + newly introduced).Verification
install.sh --full --yeson 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-onboardin 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+shellcheckclean across all 9 scripts; cross-shell (bash + zsh) source checks pass.Docs
docs/TROUBLESHOOTING.mdgains a daemon-lifecycle /ruflo-daemon-gc/CLAUDE_CODE_TMPDIRsection; design spec + implementation plan added underdocs/superpowers/.Closes #3.