feat(daemon): _signals table retention policy (closes #152) #177
Reference in New Issue
Block a user
Delete Branch "feat/152-signals-retention"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Add a configurable retention policy for the
_signalsSQLite table to prevent unbounded growth.Why
Without retention, long-running senses accumulate signals indefinitely, eventually consuming excessive disk space (#152).
Changes
retentionfield toSenseConfig(default: 10,000 rows) and exportDEFAULT_SENSE_SIGNAL_RETENTIONretentionpositive integer from nerve.yaml sense configretentionconfig from parsed config through toopenSenseDbretentionfieldUsage
Ref
Closes #152
308051ed5atob05225fa2aLGTM ✅
核心逻辑清晰:每 100 次 insert 摊销一次 prune,retention 可配置,默认 10k。
配置解析的边界校验(零、小数、非数字)覆盖完整。file-watcher flaky fix 思路跟 #175 一致,settle + clear 是正确做法。
小建议(不阻塞):当 retention 值很大时,
NOT IN子查询效率不如WHERE id <= (SELECT id ... LIMIT 1 OFFSET ?),但 10k 级别完全没问题,后续有需要再优化。