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
foreign-blocks --apply signals success after archive writes fail #6497
At master 9674cfa, seed a unified SQLite session containing a healthy block and foreign blocks with zero transcript overlap. Make archive/block-archive.jsonl a directory and run bili sessions foreign-blocks --apply, with or without --json.
The real archive append fails with EISDIR, the foreign blocks remain live, and the report lists failed entries. The command still returns exit code 0, so scheduled repair scripts mistake it for success.
Proposed fix
Return code 1 whenever result.failed is nonempty, while preserving the full result report. Successful, empty and dry-run sweeps should remain code 0.
Evidence
Two regressions fail and one dry-run control passes on unchanged master. With the fix, 17 new and adjacent tests pass, including successful retry after removing the obstruction and preservation of the healthy block. Typecheck, build, unused-export and import-graph gates pass. Real-model E2E/upstream CI remain unverified.
The original sweep PR #5343 reports failed entries but does not propagate them into the CLI status.
The patch is prepared on Afloat16:2026-11-12_foreign-sweep-failure-exit. This issue requests maintainer discussion; it does not claim prior agreement. The linked draft PR will retain the validation limits.
The prepared fix is submitted in #6498 as a draft for maintainer discussion. The PR records the baseline reproduction, focused validation results and remaining validation limits.
Duplicate screening: not a duplicate. Searched open+closed issues/PRs for the same symptom (foreign-blocks --apply exit status); this thread (#6497) and its single fix PR (#6498) are the only entries — no parallel work.
I reproduced the bug on master (9674cfa) and independently verified the fix. Seeding a unified SQLite session with a healthy block + a zero-overlap foreign block, then making archive/block-archive.jsonl a directory, bili sessions foreign-blocks --apply fails the real append with EISDIR, leaves the foreign block live, and lists the failed entry in the report — but exits 0. I implemented the same one-line change locally and confirmed it flips the exit to 1 on failure while keeping 0 for success / empty / dry-run. PR #6498 makes the identical change, so I'm reviewing that PR rather than opening a parallel one.
Fix:runForeignBlocks now computes code = result.failed.length > 0 ? 1 : 0 and returns it in both the text and JSON paths. Minimal, correct, and consistent with the sibling archive/restore commands (which already exit 1 on failure).
Tests: new tests/foreign-block-sweep-exit.test.ts drives the real store + CLI end-to-end (a real EISDIR obstruction, not a stub): failed sweep → exit 1 with both foreign blocks still live (text + JSON), retry after unblock → exit 0 with the healthy block preserved, empty re-run → exit 0, dry-run → exit 0 and touches nothing. Strong regression coverage that catches the original bug.
Up-to-date: verified current master (fcc2e84848) is an ancestor of the PR head (da16c4133f); net diff vs master is exactly the 2 files.
CI: full matrix green via the mirror cache — 30 checks, 0 failed, 0 pending, including the Windows / Node 24 lanes you wanted. The requested ci:full label is therefore no longer needed; the full matrix has already run.
Behavior change (disclosed):bili sessions foreign-blocks --apply exit code when one or more block archives fail: 0 → 1. Dry-run, successful, and empty sweeps remain 0. This is the intended fix — it makes the exit status match the report and the sibling commands.
Verdict: 可合 (mergeable). The fix is correct, the tests are real and comprehensive, the branch is current with master, and the full CI matrix (incl. Windows/Node 24) is green. Ready for you to merge — I can't merge PRs (human-only): #6498
One non-blocking observation (not gating this PR): on a failed archive the report shows the reason as unknown, because the unifiedArchiveBlock facade swallows the EISDIR into null (the detail is still in the log as a warning). Propagating the reason into the report would be a small follow-up if wanted, but it's out of scope here.
Activity
Afloat16 commentedon Nov 13, 2026
(ai: OpenAI/GPT-6 Astra Pro)
The prepared fix is submitted in #6498 as a draft for maintainer discussion. The PR records the baseline reproduction, focused validation results and remaining validation limits.
ranxianglei commentedon Nov 13, 2026
(ai: vllm-qwen/qwen3.8-27b)
Duplicate screening: not a duplicate. Searched open+closed issues/PRs for the same symptom (foreign-blocks
--applyexit status); this thread (#6497) and its single fix PR (#6498) are the only entries — no parallel work.I reproduced the bug on master (9674cfa) and independently verified the fix. Seeding a unified SQLite session with a healthy block + a zero-overlap foreign block, then making
archive/block-archive.jsonla directory,bili sessions foreign-blocks --applyfails the real append with EISDIR, leaves the foreign block live, and lists the failed entry in the report — but exits 0. I implemented the same one-line change locally and confirmed it flips the exit to 1 on failure while keeping 0 for success / empty / dry-run. PR #6498 makes the identical change, so I'm reviewing that PR rather than opening a parallel one.PR #6498 review
runForeignBlocksnow computescode = result.failed.length > 0 ? 1 : 0and returns it in both the text and JSON paths. Minimal, correct, and consistent with the siblingarchive/restorecommands (which already exit 1 on failure).tests/foreign-block-sweep-exit.test.tsdrives the real store + CLI end-to-end (a real EISDIR obstruction, not a stub): failed sweep → exit 1 with both foreign blocks still live (text + JSON), retry after unblock → exit 0 with the healthy block preserved, empty re-run → exit 0, dry-run → exit 0 and touches nothing. Strong regression coverage that catches the original bug.fcc2e84848) is an ancestor of the PR head (da16c4133f); net diff vs master is exactly the 2 files.ci:fulllabel is therefore no longer needed; the full matrix has already run.Behavior change (disclosed):
bili sessions foreign-blocks --applyexit code when one or more block archives fail: 0 → 1. Dry-run, successful, and empty sweeps remain 0. This is the intended fix — it makes the exit status match the report and the sibling commands.8问 (structured review):
bili sessions foreign-blocks --apply在块归档失败(如 EISDIR)时仍返回退出码 0,定时修复脚本会把失败误判为成功,外部块永久残留。applyForeignBlockSweep已正确把失败项收集进result.failed,但 CLI 层runForeignBlocks在 text 和 JSON 两条返回路径上硬编码了code: 0,从未读取result.failed——失败只写进了输出文本,没有传播到进程退出码。foreign-blocks --apply的场景(定时修复)。归档写失败时(磁盘满/权限/路径被占用)命令退出 0,自动化以为修复成功,外部块一直存活。p2:命令本身可用且输出里报了失败,缺陷在退出码错误,破坏依赖退出码的自动化;非数据丢失/缓存泄露。runForeignBlocks里计算code = result.failed.length > 0 ? 1 : 0,text/JSON 两条路径都返回它,完整保留 archived/failed 报告;dry-run(在 apply 前返回)、成功与空扫描(failed 为空)保持 0。foreign-blocks --apply在result.failed非空时退出码 0→1。dry-run、成功扫描、空扫描,以及 ls/rm/archive/restore/gc 全部子命令均不受影响;无 wire/config/持久化/kernel 变更。无回归。Verdict: 可合 (mergeable). The fix is correct, the tests are real and comprehensive, the branch is current with master, and the full CI matrix (incl. Windows/Node 24) is green. Ready for you to merge — I can't merge PRs (human-only): #6498
One non-blocking observation (not gating this PR): on a failed archive the report shows the reason as
unknown, because theunifiedArchiveBlockfacade swallows the EISDIR intonull(the detail is still in the log as a warning). Propagating the reason into the report would be a small follow-up if wanted, but it's out of scope here.