fix: 为旧版本 profile 自动刷新增加生产级护栏#81
Draft
AsperforMias wants to merge 2 commits into
Draft
Conversation
|
@AsperforMias is attempting to deploy a commit to the hikariming's projects Team on Vercel. A member of the Team first needs to authorize it. |
AsperforMias
force-pushed
the
fix/stale-score-cache
branch
from
July 2, 2026 20:13
1c917fa to
85be1e9
Compare
AsperforMias
force-pushed
the
fix/stale-score-cache
branch
from
July 3, 2026 07:57
85be1e9 to
2836159
Compare
Collaborator
Author
|
补充说明本次追加的护栏修复: 这次把旧版本 profile 的“被动自动刷新”从无条件后台动作改成带生产护栏的按需刷新。 现在只有 Redis 可用、未触发 per-IP 限流、未触发全局限流、同一用户没有 lease/cooldown 时,才会执行确定性 scan + score。刷新开始前会先写入 3 小时 cooldown,因此即使 GitHub、DB 或后续写入失败,同一用户也不会在短时间内被重复扫描。 如果 Redis 不可用、缓存绕过、并发锁失败或限流命中,会 fail-closed:不触发自动 scan,直接展示旧 profile 兜底,并保留“历史评分:规则版本已过期”的提示。这样可以避免版本切换后 sitemap/search/爬虫批量访问旧 profile 时,把生产环境打成无节制 scan 和 DB 写入。 这次没有改评分公式、judge 规则或正常 |
Collaborator
Author
|
Owner review requested. |
AsperforMias
marked this pull request as draft
July 17, 2026 19:09
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.
背景
旧版本
score_version的历史评分在生产环境可能继续被用户页、榜单、搜索或 profile snapshot 命中,导致用户看到已经被新规则修复过的旧判断。同时,旧版本 profile 的自动刷新路径如果缺少生产级护栏,会在版本切换、爬虫回访、sitemap/search 旧链接访问时放大成批量 scan 和 DB 写入压力。原实现主要按 username 做 cooldown;在 Redis 不可用或并发访问较多时,cooldown / single-flight 保护不足,存在请求风暴风险。
改动
scores/profile_snapshots时只暴露当前SCORE_CACHE_VERSION,旧版本行不再进入榜单、搜索、相似用户、开发者目录、百分位和排名。includeStale读取入口,仅用于识别旧缓存是否存在,避免公共事实面继续使用旧版本结果。scan + score,写入当前版本缓存和 profile snapshot。LiveRoast。/api/score/[username]遇到旧缓存时也会自动写回当前版本确定性分数。recordDeterministicScanhelper,明确区分“确定性评分写库”和“LLM roast 写文案”。packages/ghfind-js/tsup.config.ts的子包构建依赖拖失败。自检
./node_modules/.bin/tsc --noEmit./node_modules/.bin/vitest run src/lib/__tests__/redis.test.ts src/lib/__tests__/db.test.ts./node_modules/.bin/eslint src/lib/redis.ts 'src/app/[locale]/u/[username]/page.tsx' src/lib/__tests__/redis.test.tsgit diff --check成本与生产风险
/api/score时才按需刷新该用户。