fix(core): require integer compaction counts - #5646
Conversation
|
@qwen-code /triage |
|
Thanks for the PR! Template looks good ✓ On direction: this is a clean bug fix — On approach: the diff is minimal and focused — adds an Moving on to code review. 🔍 中文说明感谢贡献! 模板完整 ✓ 方向:这是一个干净的 bug 修复——当下游 collector 和整数长度做比较时, 方案:diff 很小且专注——给共享的 进入代码审查 🔍 — Qwen Code · qwen3.7-max |
Code ReviewThis is a clean, minimal fix. The approach — adding an No blockers or concerns. TestingUnit TestsAll 35 tests in Before / AfterDemonstration of the bug and fix — same inputs, old vs new validation logic: All 5 invalid-value scenarios now correctly fall through to settings/defaults. Valid integer values continue to work as before. Typecheck中文说明代码审查这是一个干净、最小化的修复。在共享的 没有阻塞问题。 测试单元测试
Before / After同样的输入,旧逻辑 vs 新逻辑的对比演示:
类型检查
— Qwen Code · qwen3.7-max |
|
Stepping back: this is a textbook bug fix. The problem is real (fractional counts silently changing retention behavior), the fix is minimal (one flag, one helper, three call sites), and the evidence is clean (35/35 tests, typecheck passes, before/after demo confirms all 5 edge cases). The approach matches what I'd have written independently. The lexical pre-check on env strings is a nice touch — it catches the No reservations. Approving. ✅ 中文说明退后一步看:这是一个教科书式的 bug 修复。问题是真实存在的(小数 count 值会静默改变保留行为),修复是最小化的(一个标志、一个辅助函数、三个调用点),证据是干净的(35/35 测试通过、类型检查通过、before/after 演示确认了全部 5 个边界场景)。 方案和我的独立提案一致。对 env 字符串的词法预检是个很好的处理——在 没有顾虑。批准。✅ — Qwen Code · qwen3.7-max |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅
✅ Local verification — real runtime A/B build (Linux)Verdict: verified, looks good to merge. The bug is real and reproduces end-to-end; the fix corrects every case without changing any valid configuration; the three new tests have teeth. I didn't just run the unit suite — I built the PR head and its parent commit into two real That last hop is the real harm: Bug cases — BEFORE (parent) wrong → AFTER (this PR) correct
Regression guard — valid configs are byte-for-byte identical before & after
The Tests, teeth, and static checks (all on Linux)
One non-blocking note for awarenessThe new env parsing uses a strict
This is an intentional, safe tightening for count knobs (and there's a minor, defensible asymmetry: env Environment: Linux (kernel 6.12), Node 中文说明(点击展开)✅ 本地验证 —— 真实运行时 A/B 构建(Linux)结论:已验证,建议合并。 这个 bug 是真实存在并且能端到端复现的;修复修正了所有问题场景,同时不改变任何合法配置;新增的 3 个测试是有“咬合力”的(能真正卡住回归)。 我没有只跑单元测试,而是把 PR head 和它的父提交分别构建成两份真实的 最后这一跳才是真正的危害所在: Bug 场景 —— 修复前(父提交)错误 → 修复后(本 PR)正确
回归保护 —— 合法配置在修复前后完全一致
测试、咬合力与静态检查(全部在 Linux 上)
一个不阻塞合并的提醒新的 env 解析使用了严格的
对于“计数类”配置项来说,这是一个有意为之、且安全的收紧(另外有一个很小、且合理的不对称:env 环境: Linux(内核 6.12),Node |
What this PR does
Requires integer values for compaction tuning knobs that are used as counts: recent file retention, recent image retention, and the screenshot trigger threshold. Fractional and unsafe integer values now fall through to the next source in the normal env > settings > default order.
Why it's needed
These knobs are documented and consumed as counts, but
resolveCompactionTuningpreviously accepted any finite number above the minimum. A value like1.5could therefore reach collectors that compare against integer lengths, effectively retaining 2 items instead of rejecting the invalid count. Env strings also need a lexical integer check before numeric conversion so huge fractional values cannot be rounded into an apparently safe integer.Reviewer Test Plan
How to verify
Confirm that
resolveCompactionTuningaccepts valid integer values, rejects fractional count-like env/settings values, rejects unsafe integers, and still preserves the existing fallback order from env to settings to defaults.Commands run locally:
Evidence (Before & After)
Before: fractional values such as
1.5were accepted for count-like compaction tuning and could change the effective retention count. After: fractional and unsafe integer values are treated as invalid and fall through to settings/defaults. The new tests cover fractional env values for all three count-like knobs, a huge fractional env value that would otherwise be rounded byNumber(), fractional settings values, and unsafe integers.Tested on
Environment (optional)
Local macOS arm64, Node.js v26.3.0.
Risk & Scope
Linked Issues
Fixes #5640
AI Assistance Disclosure
I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases.
中文说明
What this PR does
这个 PR 要求用于“计数”的 compaction tuning 必须是整数,包括最近文件保留数量、最近图片保留数量,以及截图触发阈值。小数和不安全整数现在会按正常的 env > settings > default 顺序回落到下一个来源。
Why it's needed
这些配置项在文档和下游逻辑里都是作为数量使用的,但之前
resolveCompactionTuning会接受任何大于等于下限的有限数字。因此像1.5这样的值可以进入和整数长度比较的 collector,实际效果会变成保留 2 个条目,而不是拒绝这个非法数量。env 字符串也需要在数字转换前先做整数字面量校验,避免超大的小数字符串被Number()舍入成看起来安全的整数。Reviewer Test Plan
How to verify
确认
resolveCompactionTuning会接受合法整数,拒绝 count-like env/settings 小数,拒绝不安全整数,并保留现有 env 到 settings 再到默认值的回落顺序。本地运行过的命令:
Evidence (Before & After)
修复前:
1.5这类小数会被 count-like compaction tuning 接受,并可能改变实际保留数量。修复后:小数和不安全整数都会被视为非法值,并回落到 settings/defaults。新增测试覆盖了三个 count-like 配置项的小数 env 值、一个会被Number()舍入的超大小数 env 值、小数 settings 值,以及不安全整数。Tested on
Environment (optional)
本地环境为 macOS arm64,Node.js v26.3.0。
Risk & Scope
Linked Issues
Fixes #5640
AI Assistance Disclosure
I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases.