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
CLI surface for storage maintenance: bili sessions ls/rm/archive/restore + bili storage gc (re-scoped from #3860) #3928
#3911 gave storage maintenance an HTTP surface (POST /__bili/storage/gc, POST /__bili/storage/restore, ?vacuum=full, storage.archiveAfterDays default 365). It deliberately shipped without a CLI entry. This issue tracks the CLI follow-up re-scoped out of #3860 (closed): a thin command layer over the same store APIs.
Scope
bili sessions ls — id, label, size (decoded bytes), last-updated, storage status (active/archived).
bili sessions rm <id> — full delete (the existing deleteSession discipline: content refcount release incl. media, tombstone-free).
bili storage gc [--days N] [--vacuum full|incremental] [--dry-run] — wrap store.gc(), print the sweep plan (sessions to archive, rows to release, pages to reclaim) before executing; --dry-run prints only.
No scheduler/daemon (age sweep runs on demand; auto-at-boot is a separate decision).
Acceptance
ls/rm/archive/restore/gc --dry-run demonstrated against a scratch store in tests; gc end-to-end matches the HTTP path's results (same archived/contentRowsDeleted numbers).
Docs: README storage section + CONFIGURATION mention the CLI forms.
Context: re-filed from #3860 (superseded by #3911 for the store layer).
Activity
ranxianglei commentedon Oct 20, 2026
(ai: vllm-qwen/qwen3.8-27b)
查重: 不重复。#3860(原
bili sessions ls/rm/prunePR)已由你关闭并明确重定为本 issue;#3911 已合入 master(store 层 + HTTP 面);本地留有 #3860 的分支2026-10-19_sessions-cleanup作先前实现参考(其 store 层部分基于 #3911 之前的代码,CLI 接线与安全语义可复用)。无其他开放条目涉及该 CLI 面。标签:
scope/storage+p2(存储维护入口缺失家族,与 #3830/#3860 同档)。功能请求,不打 bug。开工前三个范围判断(都按 issue 字面执行,如有异议喊停):
rm保持薄封装——直接走既有deleteSession(含 media/CAS 引用计数释放、tombstone-free),不加 [PR] feat: add supported session cleanup (bili sessions ls/rm/prune + VACUUM) #3860 里的「活跃会话拒绝 + --force」层。理由:issue 非目标写明「纯 CLI 管道 + 人类可读输出」,且用户显式输入了精确 id。删除前打印一行将被释放的规模摘要(消息数/内容行数),不做交互确认(脚本友好)。ls在 shadow 模式下降级为 JSON 树视图(与bili export列表同路径),unified/full 模式走 DB 汇总行——两模式都有输出,不静默空表。gc --dry-run的计划用只读查询拼出(按 cutoff 筛选待归档会话 + 零引用行数 + 页数估算),不改任何 store 语义;若现有公开方法不足以拼计划,最多加一个只读方法,绝不动写路径。开始动手:先核对 ff 后 master 上的 API 形态,再落
src/cli.ts接线 + 新模块 + 测试(scratch store 演示 ls/rm/archive/restore/gc --dry-run,gc 端到端数字对齐 HTTP 路径),最后补 README/CONFIGURATION 文档。ranxianglei commentedon Oct 20, 2026
(ai: vllm-qwen/qwen3.8-27b)
**PR: #3958 #3928)。分支
2026-10-20_storage-maintenance-cli,单 commitc62da893f,typecheck 干净,定向测试全绿(新套件 7/7 + storage-archive-gc 5/5 + cli-export 2/2),全量回归交给 CI。交付的命令面
全部支持
--json;archive/restore/gc在 legacy-only 安装上拒绝并给出BILI_STORAGE_UNIFIED提示(与 HTTP 侧 501 同措辞);--days默认走既有的storage.archiveAfterDays(365)解析链。首条回复里说明的三个范围决定(rm 保持薄封装、ls 大小取文件解码字节+DB 状态、gc 计划只读查询)均已按此实现。结构化八问
src/storage-maintenance.ts,复用与 HTTP 端点相同的 facade 方法(unifiedGc/unifiedArchiveSession/unifiedRestoreArchived)。gc 的--dry-run用只读查询(gcPlan(),与gc()同一 cutoff SQL)打印计划后执行同一个unifiedGc()调用,所以 CLI 与 HTTP 的结果数字结构性一致——测试里对等价 scratch store 直接调store.gc()钉死了 archived/contentRowsDeleted 相等。removeLegacyFile重构为委托共享的removeSessionFiles(候选集逐一对齐:relPathFor×2 + flatFileNameFor + content-store 配对);sessionSummaries()/webSummaryRows()新增status字段(additive,/__bili/sessionsJSON 每行多一个 key,无既有字段变动);store 写路径与 gc 语义零改动(gcPlan纯 SELECT,vacuum(mode)是物理收缩原语,SQLITE_BUSY 重试沿用 [PR] feat: add supported session cleanup (bili sessions ls/rm/prune + VACUUM) #3860 验证过的写法)。相邻套件本地通过;高危模式逐项过:无语义漂移、无吞错变化、无阈值/时序/输出格式变动。--days映射到既有storage.archiveAfterDays,没有新 env/config 字段。store 层的四处 additive 能力(
gcPlan/contentZeroRefReport/sessionStorageStats/vacuum(mode)+ summaries 的 status 列)在 PR 描述里已逐一点名;#3860 旧分支的安全语义与 stats/vacuum SQL 已适配到 #3911/#3927 单日志存储层并在此复用。等 CI 绿后可合。fix: cli rm — surface the real VACUUM error instead of assuming datab…
docs: align new CLI help entries with the existing 2-space layout (#3928
feat: CLI surface for storage maintenance — bili sessions ls/rm/archi…
fix: cli rm — surface the real VACUUM error instead of assuming datab…
docs: align new CLI help entries with the existing 2-space layout (#3928
docs: move the archiveAfterDays CLI note into the config-doc seed (#3928
refactor: unexport two internal-only types flagged by the unused-expo…
feat: CLI surface for storage maintenance — bili sessions ls/rm/archi…
fix: cli rm — surface the real VACUUM error instead of assuming datab…
docs: align new CLI help entries with the existing 2-space layout (#3928
docs: move the archiveAfterDays CLI note into the config-doc seed (#3928
4 remaining items
docs: align new CLI help entries with the existing 2-space layout (#3928
docs: move the archiveAfterDays CLI note into the config-doc seed (#3928
refactor: unexport two internal-only types flagged by the unused-expo…
fix: adapt the #3928 pass-throughs to the storage-backend seam (#3946)…
feat: CLI surface for storage maintenance — bili sessions ls/rm/archi…
fix: cli rm — surface the real VACUUM error instead of assuming datab…
docs: align new CLI help entries with the existing 2-space layout (#3928
docs: move the archiveAfterDays CLI note into the config-doc seed (#3928
refactor: unexport two internal-only types flagged by the unused-expo…
fix: adapt the #3928 pass-throughs to the storage-backend seam (#3946)…
Merge pull request #3958 from ranxianglei/2026-10-20_storage-maintena…
fix(#2935): host-side delete uses full-cascade removeSession (master …
fix(cli): sessions ls lists from metadata only — no full-corpus loadA…
fix(cli): sessions ls lists from metadata only — no full-corpus loadA…