Repository navigation
Conversation
helsome
requested changes
Oct 18, 2026
helsome
left a comment
Owner
There was a problem hiding this comment.
发现一个去重容量回归,建议修正后合入:packages/shared/src/alerts/evaluators.ts 中 seenNewsIds 使用 [...currentIds, ...seenIds].slice(0, 1000),跨集合重复 ID 会占用容量。
复现:已保存 a0…a999,本轮仍返回 a0…a19 且没有新文章。保存后数组长度为 1000,但只有 980 个不同 ID,a980…a999 被提前淘汰;下轮出现 a999 就可能重复通知,尽管从未超过 1000 个不同文章。
请先去重再截断,例如 [...new Set([...currentIds, ...seenIds])].slice(0, 1000),并补充满容量重复轮询不淘汰旧 ID、重载后 a999 不再通知的回归。本条不要求改变既有每轮最多 3 条通知的产品语义。
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.
改动与原因
告警引擎把
lastCheckedAt写成轮询时钟,新闻评估器却拿它当文章发布时间游标。Provider 延迟返回的新闻(发布时间早于上次检查)因此永久漏报;同秒文章也不能可靠地靠时间水位区分。本 PR 将最近见过的文章 ID 存在每条规则独立的
alerts-snapshots.json状态中,按 ID 判断新增,并限制状态为最近 1000 个 ID。已有规则在首次升级轮询时仍用旧lastCheckedAt过滤旧文章,再切到 ID 去重,避免升级后批量重放历史新闻。lastCheckedAt继续记录检查时间。Closes #227
本 PR 恢复原 PR #228 的相同提交。原源仓库已脱离 fork 网络,GitHub 无法重新打开旧 PR;因此改由新的贡献 fork 提交。
可复现测试报告
环境:Windows 11 / Bun 1.4.0 / 上游 main
ba5dcdf。分支基于干净 main,改动仅 shared 告警路径。bun test packages/shared/src/alerts/engine.test.tsbun test packages/shared/src/alerts --isolatebun run --filter @finagent/shared typecheckgit diff --check新增真实
AlertEngine.tick()→AlertRuleRepository→JsonFileStore测试,覆盖 provider 迟到文章、同秒新文章、空轮询、重建 Engine/Repository 后的持久去重;旧规则首次升级不重放历史、之后接受迟到新 ID;单独断言持久状态上限。本地全工作区检查的环境限制
独立 worktree 中
bun install --frozen-lockfile2 次均在 Windows 包链接阶段对happy-dom、micromark-util-decode-numeric-character-reference、@babel/helper-module-transforms报 ENOENT(544 个包已安装,3 个失败)。因此bun run typecheck的 core/shared 通过,i18n/ui 因无法解析happy-dom退出 2;这不是本 PR 的代码错误结论,也不宣称本地全仓通过。请以本 PR 在干净 CI 环境的 Typecheck、Focused tests 和 Full unit tests 结果复核。范围与限制
research.news每次默认取 20 条,状态上限覆盖常规连续轮询。