Automatically rebuild stale indexes in the background after engine upgrades
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- sqlite, typescript
调研方向
Start with EXTRACTION_VERSION and getIndexBuildInfo()/isIndexStale() in src/extraction/extraction-version.ts and src/index.ts, then read #710 and #940 for existing behavior and database-replacement constraints. Identify the project-open/query entry points and the session-transcript index’s versioning before scoping the rebuild lifecycle. Add regression tests for stale/current indexes, concurrent clients, failure recovery, source changes during rebuilding, and platform-specific handover; done means stale indexes refresh without blocking queries or exposing a partial replacement.
由索引模型根据 Issue 内容生成。
描述
Problem
After an upgrade changes extraction or resolution output, an existing graph can remain on the old behavior even when every source file is unchanged. End users should not need to read release notes, understand which fixes affect stored index content, or choose between sync and index to benefit from the new engine.
Could CodeGraph automatically rebuild a stale index in the background when that project is next opened/queried, while continuing to serve the last completed index until its replacement is ready?
Existing foundation
Checked upstream main at 374b3b4209d93d8be5bc77ca487ba027e76e0758 on 2026-09-08. The latest published release listed by GitHub is v1.6.0 (2026-08-26). This is a feature proposal based on source inspection, not a claim of a newly reproduced release regression.
EXTRACTION_VERSIONalready distinguishes extracted-content changes from SQLite schema migrations. Its documented purpose is currently to drive a reindex recommendation/reminder.getIndexBuildInfo()/isIndexStale()already compare the stored extraction version with the running engine. Full indexing stamps that version; incremental sync deliberately does not advance it.- #710 introduced this detection and the reminder. #525 covers automatic updates when source files change; this proposal covers an engine change while source files remain unchanged. #1526 improves incremental/full-rebuild convergence after source edits, which is a related but different trigger.
- #940 provides related groundwork for reopening a replaced database in a running server on POSIX. Its implementation explicitly excludes Windows, so the handover needs platform-specific validation rather than assuming an open database can be replaced everywhere.
Proposed behavior
- Extraction/resolver changes that require existing content to be regenerated advance the extraction version, including fixes that change stored output. CLI/UI-only releases do not cause a rebuild.
- On the next normal project open/use, detect an older or missing extraction stamp and start a background rebuild into a separate replacement database. Continue answering from the last completed, readable index with an explicit stale/updating status. Users should not need a manual command or confirmation, and the expensive rebuild should not block ordinary queries.
- Concurrent clients share one rebuild. After it succeeds, catch up any intervening source changes and coordinate the switch to the replacement database and its fresh query caches. Publish the new stamp only after success. On failure, retain the old usable index and report the failure; never expose a partially built replacement as current. A short coordinated handover is acceptable, particularly where Windows file locking requires it. If no usable old index exists or its schema cannot be read safely, the nonblocking fallback does not apply.
- Apply the same compatibility principle to the separate session-transcript index, using its own reader/index version. Idle projects and temporary indexes are refreshed if and when they are used again; an upgrade does not need to discover and rebuild every database on the machine.
This would eliminate the need for downstream upgrade scripts to maintain a global database inventory and force full reindexes after every deployment.
Suggested regression proof
- Build an index with an older extraction stamp, leave source contents/hashes unchanged, and open it with the newer engine. Hold the background rebuild at a test barrier and prove queries still answer from the old index with an updating status. Release it and prove queries reflect the new extraction without reconnecting or running a manual command.
- Open the same stale project from two clients and assert that only one rebuild runs.
- Inject a rebuild failure and verify that the previous usable index survives and the compatibility stamp is not advanced; a later attempt can recover.
- Change a source file during the rebuild and verify the replacement includes the change at handover. Validate connection/cache handover on Windows as well as POSIX.
- Reopen a current index and verify that no full rebuild runs. Cover the corresponding unchanged-transcript case for the session index.
- 主要语言
- C
- 星标
- 73.2k
- 派生
- 4.7k
- 平均合并
- 3 小时
- 30 天内合并 PR
- 623
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
colbymchenry/codegraph 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
colbymchenry/codegraph#1900 · 2 条评论 · 5 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
colbymchenry/codegraph#1700 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
colbymchenry/codegraph#1535 · 2 条评论 · 2 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 63/100
colbymchenry/codegraph#1403 ·
维护者通常 1 天内回复
-
agent-target
难度 2/5 1-3 小时 新手友好度 68/100
colbymchenry/codegraph#649 · 5 条评论 · 50 个 reaction ·
维护者通常 1 天内回复
查看 colbymchenry/codegraph 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
JS_SetPropertyInternal2 loses the value when a lazy property on the prototype runs out of memory未关闭
难度 2/5 1-3 小时 新手友好度 78/100
quickjs-ng/quickjs#1852 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复