You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
web: fresh install (sessions dir never existed) 500s on /__bili/overview & /__bili/sessions — #1937's "never silent empty" cannot tell "no data yet" from "misconfigured" #2180
On any environment where the default state dir has never been created (fresh machine / fresh CI runner — ~/.local/share/billion-context/sessions absent):
bili start
GET /__bili/overview → 500{"error":"failed to load session data"} GET /__bili/sessions → same 500
Log: [acp-web] overview failed: Error: ENOENT: no such file or directory, scandir '<state>/sessions'
Reproduced locally by running tests/advisory-endpoint-parity.test.ts with HOME/XDG_DATA_HOME pointed at empty dirs (before its hermeticization in #2175, which is exactly what made all four test-matrix jobs red there — master-side pre-existing, fixed on the TEST side only).
Why it happens
walkSessionFiles() (src/web/sessions-data.ts) throws on ANY top-level readdir failure; refreshIndex() propagates it when no prior snapshot exists. #1937 deliberately pins this: vanished dir serves the stale snapshot, and a missing dir with no prior snapshot rejects loudly (tests/web-sessions.test.ts "#1937: dir breakage serves stale snapshot; missing dir rejects loudly") — the intent being "never silent empty", so a misconfigured/moved sessions path surfaces instead of showing an empty dashboard while real sessions sit elsewhere.
The over-broad part: "the whole data root was never created" (first run, zero sessions ever persisted) is indistinguishable from "path is wrong" by the current code, so a perfectly healthy fresh install reports an error on both endpoints until the first session is persisted.
Impact
Fresh-install web dashboard shows a broken/error state until the first session exists.
Suggested direction (owner decision — this is a contract/default change)
Distinguish pristine from broken, e.g.: the entire data root (XDG_DATA_HOME/billion-context) missing → treat as "no sessions yet" → 200 with empty data; data root present but sessions dir missing/vanished → keep today's loud rejection (and the #1937 stale-snapshot behavior). An explicitly-set BILI_SESSIONS_DIR pointing nowhere could stay loud in either world. Whichever variant is chosen, update the #1937-pinned test in the same PR.
Not fixed in #2175 on purpose: changing this means re-pinning a deliberate #1937 contract — a product decision, not an agent call.
Activity
ranxianglei commentedon Oct 5, 2026
[bot] 🏷 收到。已按 issue 里给出的方向开工(这是 owner 拍板的契约细化,我直接采用你 sketch 的变体):
BILI_SESSIONS_DIR未设置 且 整个 data root(XDG_DATA_HOME/billion-context)不存在 →walkSessionFiles的顶层 ENOENT 视为"还没有任何会话",索引置空,两个端点返回 200 + 空数据(live pool 里的会话照常合并显示)。BILI_SESSIONS_DIR指向不存在的路径 → 两个世界都维持 loudly reject(显式覆盖意味着用户主动搬过数据,缺失更像 typo)。先跑定向验证(web-sessions 套件 + typecheck),然后开 PR。
ranxianglei commentedon Oct 5, 2026
[bot] 🏷 完成。PR: #2182 (Closes #2180)
按你 sketch 的变体实现,结构化七问:
/__bili/overview与/__bili/sessions持续 500——「还没有数据」被当成了「路径坏了」。walkSessionFiles()对任何顶层 readdir 失败都 throw,refreshIndex()在无旧快照时原样传播。管理页面全量加载历史会话时触发堆 OOM:需要有界分页、摘要统计与详情懒加载 #1937 有意钉死 "never silent empty",但它的防御对象是「真实会话在别处、这里显示空会骗人」——而 data root 整体不存在时根本不存在「别处有会话」的可能,两类失败被同一个异常路径混在一起了。refreshIndex()(唯一决策点)对顶层失败做分类:新增isPristineSessionsRoot(error)—— 仅当BILI_SESSIONS_DIR未设置 且 data root(XDG_DATA_HOME/billion-context)本身不存在 且错误是 ENOENT 时,视为 pristine,索引置空正常返回(→200 空数据,live pool 会话照常合并)。其余情形逐字节不变:data root 在但 sessions 子目录缺失/消失 → 旧快照 serve / 无快照 loudly reject(管理页面全量加载历史会话时触发堆 OOM:需要有界分页、摘要统计与详情懒加载 #1937 原样);显式BILI_SESSIONS_DIR指向不存在 → 维持 loud;EACCES 等照旧。pristine 判定不缓存,每次 poll 重新 stat,首个会话落盘后下一次请求自然恢复。src/web/sessions-data.ts+ 对应测试),不动 kernel/、不动持久化格式、不加新端点;管理页面全量加载历史会话时触发堆 OOM:需要有界分页、摘要统计与详情懒加载 #1937 的 "never silent empty" 契约保留,只是把「pristine」从它的覆盖范围里精确排除了。BILI_SESSIONS_DIR/XDG_DATA_HOME语义(PR 正文 config surface 一节已声明)。测试:更新 #1937 钉死测试(改名
#1937/#2180: …,原断言全部保持有效)+ 新增withPristineEnv辅助与两用例(pristine 全链路 resolve→首会话落盘可见;data root 存在但子目录缺失仍 loudly reject)。本地定向验证 typecheck ✓、web-sessions 15/15 ✓、端点套件 9/9 ✓,全量回归交给 CI。收工判定:代码完成、定向验证绿,等 CI 后可由你合并 PR #2182。
fix(web): keep #1937 stale-snapshot when data root vanishes after ses…
Merge pull request #2182 from ranxianglei/2026-10-05_fresh-install-em…
fix: serve empty web index on pristine install instead of 500 (ranxia…
storage: hermetic test tiers + eager storage-mode stamp after master …
storage: hermetic test tiers + eager storage-mode stamp after master …
fix(test): materialize advertised dirs in the hermetic test-env prelo…