fix(session-start): support ECC_SESSION_RETENTION_DAYS opt-out + document env var (#2151) - #2163
Conversation
…ment env var The retention pass for *-session.tmp files (issue affaan-m#2151) landed previously, but the env var that controls it was undocumented in the README and rejected falsy values (0, off, disabled), silently falling back to the 30-day default. Users who want to keep all sessions for forensic or research workflows had no way to opt out. This patch: - Extends getSessionRetentionDays() so 0|off|false|disabled|never|none disables pruning entirely (returns null sentinel; default behavior unchanged). - Updates the call site in main() to skip pruneExpiredSessions when retention is null and emits a clear "[SessionStart] Pruning disabled via ECC_SESSION_RETENTION_DAYS" log line so the operator can tell pruning is off. - Documents ECC_SESSION_RETENTION_DAYS in the README "Hook Runtime Controls" section alongside the other ECC_SESSION_* knobs. - Adds three regression tests in tests/hooks/hooks.test.js covering opt-out via 0, opt-out via off, and garbage-value fallback to default 30. Verification: - node tests/hooks/hooks.test.js — 240/240 green (incl. 3 new retention tests) - node tests/run-all.js — 2622/2622 green - npx eslint scripts/hooks/session-start.js tests/hooks/hooks.test.js — clean - node scripts/ci/validate-no-personal-paths.js — clean - node scripts/ci/check-unicode-safety.js — clean - node scripts/ci/validate-hooks.js — 28 matchers validated - node scripts/ci/validate-rules.js — 115 files validated Fixes affaan-m#2151
|
Lost in the diff? Review this PR in Change Stack to follow the change map from intent to exact ranges. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughSession retention is now configurable via ChangesSession Retention Configuration
🎯 2 (Simple) | ⏱️ ~12 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Around line 482-484: Update the README line for ECC_SESSION_RETENTION_DAYS to
document all supported opt-out values; specifically mention that setting
ECC_SESSION_RETENTION_DAYS to 0 or any of the string values "off", "false",
"disabled", "never", or "none" will disable session retention (keep all
sessions). Ensure the text around the variable name ECC_SESSION_RETENTION_DAYS
clearly lists these accepted values and their effect.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: aded40d5-f8af-4ffc-a5d8-65e5b309e39e
📒 Files selected for processing (3)
README.mdscripts/hooks/session-start.jstests/hooks/hooks.test.js
There was a problem hiding this comment.
1 issue found across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…d Windows example Address reviewer feedback on PR affaan-m#2163: - CodeRabbit and cubic both flagged that the README docs only listed 3 of 6 opt-out values accepted by getSessionRetentionDays() (0, off, disabled), while the implementation also accepts false, never, none. - cubic also flagged the missing Windows PowerShell example for the new variable, breaking the parallel structure of the existing ECC_CONTEXT_MONITOR_COST_WARNINGS example block. Updated the README to: - Spell out all six opt-out values (0, off, false, disabled, never, none) and clarify they "keep all sessions (disable pruning)". - Add an ECC_SESSION_RETENTION_DAYS line to the Windows PowerShell example. No behavior change. README only. Verification: - npx markdownlint README.md — clean - npx eslint scripts/hooks/session-start.js tests/hooks/hooks.test.js — clean
|
ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR. |
…ment env var (affaan-m#2151) (affaan-m#2163) * fix(session-start): support ECC_SESSION_RETENTION_DAYS opt-out + document env var The retention pass for *-session.tmp files (issue affaan-m#2151) landed previously, but the env var that controls it was undocumented in the README and rejected falsy values (0, off, disabled), silently falling back to the 30-day default. Users who want to keep all sessions for forensic or research workflows had no way to opt out. This patch: - Extends getSessionRetentionDays() so 0|off|false|disabled|never|none disables pruning entirely (returns null sentinel; default behavior unchanged). - Updates the call site in main() to skip pruneExpiredSessions when retention is null and emits a clear "[SessionStart] Pruning disabled via ECC_SESSION_RETENTION_DAYS" log line so the operator can tell pruning is off. - Documents ECC_SESSION_RETENTION_DAYS in the README "Hook Runtime Controls" section alongside the other ECC_SESSION_* knobs. - Adds three regression tests in tests/hooks/hooks.test.js covering opt-out via 0, opt-out via off, and garbage-value fallback to default 30. Verification: - node tests/hooks/hooks.test.js — 240/240 green (incl. 3 new retention tests) - node tests/run-all.js — 2622/2622 green - npx eslint scripts/hooks/session-start.js tests/hooks/hooks.test.js — clean - node scripts/ci/validate-no-personal-paths.js — clean - node scripts/ci/check-unicode-safety.js — clean - node scripts/ci/validate-hooks.js — 28 matchers validated - node scripts/ci/validate-rules.js — 115 files validated Fixes affaan-m#2151 * docs(readme): list all ECC_SESSION_RETENTION_DAYS opt-out values + add Windows example Address reviewer feedback on PR affaan-m#2163: - CodeRabbit and cubic both flagged that the README docs only listed 3 of 6 opt-out values accepted by getSessionRetentionDays() (0, off, disabled), while the implementation also accepts false, never, none. - cubic also flagged the missing Windows PowerShell example for the new variable, breaking the parallel structure of the existing ECC_CONTEXT_MONITOR_COST_WARNINGS example block. Updated the README to: - Spell out all six opt-out values (0, off, false, disabled, never, none) and clarify they "keep all sessions (disable pruning)". - Add an ECC_SESSION_RETENTION_DAYS line to the Windows PowerShell example. No behavior change. README only. Verification: - npx markdownlint README.md — clean - npx eslint scripts/hooks/session-start.js tests/hooks/hooks.test.js — clean
Summary
getSessionRetentionDays()soECC_SESSION_RETENTION_DAYS=0|off|false|disabled|never|nonedisables session-tmp pruning entirely. Issue [BUG]: Session tmp files accumulate indefinitely #2151 follow-up — the underlying retention pass landed previously; this closes the configurability + discoverability gaps the original report asked for. Default behavior is unchanged.ECC_SESSION_RETENTION_DAYSin the README "Hook Runtime Controls" section alongside the otherECC_SESSION_*knobs (was previously undocumented, so users could not discover the setting).0, opt-out viaoff, and garbage-value fallback to default 30.Fixes #2151
Verification
node tests/hooks/hooks.test.js— 240/240 green (incl. 3 new retention tests).node tests/run-all.js— 2622/2622 green.npx eslint scripts/hooks/session-start.js tests/hooks/hooks.test.js— clean.node scripts/ci/validate-no-personal-paths.js— clean.node scripts/ci/check-unicode-safety.js— clean.node scripts/ci/validate-hooks.js— 28 matchers validated.node scripts/ci/validate-rules.js— 115 files validated.ECC_SESSION_RETENTION_DAYS=0 …skips the prune pass;ECC_SESSION_RETENTION_DAYS=14 …prunes at 14 days;ECC_SESSION_RETENTION_DAYS=garbage …falls back to 30-day default.Summary by cubic
Adds opt-out support for session-tmp pruning via
ECC_SESSION_RETENTION_DAYSand documents the env var. Default 30-day behavior stays the same with clear logging when pruning is disabled. Fixes #2151.0/off/false/disabled/never/noneas opt-out; skip pruning and log "Pruning disabled via ECC_SESSION_RETENTION_DAYS". Garbage values fall back to 30 days.ECC_SESSION_RETENTION_DAYSin README with default, all six opt-out values, and a Windows PowerShell example.0,off) and default fallback.Written for commit a75130d. Summary will update on new commits.
Summary by CodeRabbit
New Features
Documentation
Tests