fix(checkpoint): recalibrate counters after cleanup (#157) - #667
Draft
Guichena wants to merge 2 commits into
Draft
fix(checkpoint): recalibrate counters after cleanup (#157)#667Guichena wants to merge 2 commits into
Guichena wants to merge 2 commits into
Conversation
…entCloud#157) l0_conversations_count and total_memories_extracted were increment-only: nothing ever decremented them when records were removed by memory-cleaner or manual JSONL pruning, so after any cleanup the counters permanently overstated reality and skewed L2/L3 persona thresholds. Add CheckpointManager.recalibrate(source?) which reconciles both counters to live store counts (countL0/countL1), falling back to JSONL shard line counts in degraded mode. It clamps NaN/negative counts, clamps memories_since_last_persona down to the actual L1 total, preserves unrelated fields, reuses the per-file lock, and is idempotent. Wire it in at two non-fatal points: - end of each LocalMemoryCleaner.runOnce, right after deletions; - gateway startup in TdaiCore.ensureSchedulerStarted, before restoring pipeline state, so thresholds resume from accurate counts. Add regression tests covering downward/upward correction, idempotence, field preservation, memories clamping, JSONL fallback, store-source failure fallback, and NaN/negative clamping.
Collaborator
|
Thank you for your interest and contributions! We will review your code and get back to you as soon as possible! |
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.
Description | 描述
修复 Issue #157 的 checkpoint 计数漂移:基于健康存储聚合计数进行启动校准,清理时使用原子增量扣减,并在存储不可用时对 JSONL 做受限恢复。
Related Issue | 关联 Issue
Fixes #157
Change Type | 修改类型
Self-test Checklist | 自测清单
Additional Notes | 其他说明
Verification
npm test(78 tests)npm run buildnpm pack --dry-run