Skip to content

fix(intelligence): add runaway-storage guard to pending-insights log#2615

Draft
ruvnet wants to merge 1 commit into
mainfrom
claude/stoic-bohr-ebsbow
Draft

fix(intelligence): add runaway-storage guard to pending-insights log#2615
ruvnet wants to merge 1 commit into
mainfrom
claude/stoic-bohr-ebsbow

Conversation

@ruvnet

@ruvnet ruvnet commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds a runaway-storage guard in .claude/helpers/intelligence.cjs to prevent the append-only pending-insights file from growing unbounded when the consolidation daemon never runs.
  • When the file exceeds 512 KB, only the most recent 2000 lines are kept. The statSync cost is negligible per edit; the rewrite fires only when the guard triggers.
  • The guard is wrapped in a try/catch so any filesystem error is non-fatal.

Details

pending-insights is append-only and is only drained by the background consolidation worker. In environments where the daemon never starts (CI, ephemeral containers, source-only checkouts), thousands of un-consolidated edits can accumulate indefinitely. This fix caps growth at a safe ceiling without changing normal-operation behaviour.

Test plan

  • Verify intelligence.cjs loads without errors: node -e "require('./.claude/helpers/intelligence.cjs')"
  • Confirm guard does not fire under normal usage (file stays under 512 KB)
  • Simulate oversized file: write >512 KB to pending-insights, call recordEdit, confirm file is trimmed to ≤2000 lines

Generated by Claude Code

Append-only pending-insights can grow unbounded if the consolidation
daemon never runs. Cap at 2000 most-recent lines once the file exceeds
512 KB; statSync cost is negligible per edit and the rewrite fires only
when the guard triggers.

Co-Authored-By: RuFlo <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_01G8Lzt9guWmHtN8NzcuovaG
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.

2 participants