Repository navigation
[PR] fix: return failure status when foreign block archives fail - #6498
ranxianglei merged 16 commits into
Conversation
(ai: vllm-qwen/qwen3.8-27b) Duplicate screening: no duplicate. Independent check of open+closed PRs/issues on this topic (foreign-blocks exit status, storage-maintenance exit propagation, sweep-failure reporting): only related items are #5343 (the original sweep PR, closed — added the feature, did not propagate failures to exit status, as the PR body states) and #5334 ( Label judgment (reported here; source PR not mutated per the 2026-11-12 no-relabel rule): bug / scope/storage / p2 — a repair-scheduling script misreads a failed sweep as success, but the failure is visible in the report, blocks stay live and retryable; usable with a clear workaround, no data loss. Review — verified, not just read
Existing-behavior walk (②): dry-run path (returns before apply, code 0 — tested); successful sweep (code 0 — tested via retry); empty rerun (code 0 — tested); JSON/text report shape (byte-identical, only Behavior change (disclosed per policy): Adjacent finding — same symptom family, different command (out of scope for this PR)
八问
判定: 可合(merge 由人执行)。PR 当前 behind master —— 已本地验证 rebase 到 |
The suite baseline preload (preload-storage-baseline.mjs) pins BILI_STORAGE_UNIFIED="legacy" for the broad corpus. After ranxianglei#6480 flipped the storage default to pure-sqlite, the notice-registry suite's visibleNotices assertions expect the pure-sqlite default notice, which is gated on unifiedSelectionIsSqlite (unified "sqlite" or absent) — the preload's "legacy" made the notice silent, so the suite was born-red on master. Pin the selection explicitly (ranxianglei#4011 lesson: a test that depends on the production default passes locally but fails in CI).
…test The dsh plugin lane (ci-e2e-dsh.yml) runs node --import tsx --test WITHOUT the preload-storage-baseline.mjs preload, so BILI_STORAGE_UNIFIED is unset and the storage mode defaults to 'full'. Under the pure-sqlite default flip (5a80e2b, ranxianglei#6480), 'full' mode turns the JSON envelope writer OFF — so the .content-store.json sidecar is never written, and the test's readdirSync(namespace) hits ENOENT. Pin BILI_STORAGE_JSON_WRITER=on in the test so the content-store sidecar is written regardless of the storage mode. This keeps the corrupted-store detection path exercised in both full and legacy modes. Closes: dsh plugin lane red on master (run 43532980164, job 132255459726)
The pure-sqlite default flip (5a80e2b, ranxianglei#6480) turns the JSON envelope writer OFF, so the .json session file this lane asserts on is never written and 'proxy must persist the session' / 'no persisted session carried compressed blocks' fail after the 20s wait. Pin the writer ON in the spawned client's env (the bootstrapped proxy inherits it) so the envelope this test was written for is still produced. Closes: native opencode lane red on master (run 43547593803, job 132302438610)
Same pure-sqlite default flip (5a80e2b, ranxianglei#6480) as the opencode lane: the JSON envelope writer is OFF, so 'proxy must persist the session within 20000ms' fails — the on-disk .json session file is never written. Pin the writer ON in the spawned dsh client's env (the bootstrapped proxy inherits it). Closes: native dsh lane red on master (run 43547497015, job 132302138843)
…e2e lane Same pure-sqlite default flip (5a80e2b, ranxianglei#6480) as the opencode/dsh lanes: the JSON envelope writer is OFF, so 'session persisted' fails — the on-disk .json session file is never written. Pin the writer ON in the spawned pi client's env (the bootstrapped proxy inherits it). Closes: pi codex-responses WS lane red on master (run 43547626291, job 132302540960)
…lane 4th lane of the pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON envelope writer is OFF, so 'proxy must persist the session' and 'at least one persisted session must carry compressed blocks' fail — the on-disk .json session file is never written. Pin the writer ON in the spawned pi client's env (the bootstrapped proxy inherits it). Closes: pi package-native lane red on ci-fixes (run 43558179054, job 132336647955)
Same pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON writer is OFF, so the per-session CCR content-store sidecar (.content-store.json) that 'child persists its own companion and survives a proxy restart' asserts on is never written (0 !== 1). The earlier b1bc17b pin only covered tests/plugin-fork.test.ts, not this file. Pin the writer ON at module load (before any SessionStore is constructed). Closes: dsh plugin lane red on ci-fixes (run 43558179102, job 132336519539)
…lane Pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON envelope writer is OFF, so 'proxy must persist the session' fails — the on-disk .json session file is never written. Pin the writer ON in the spawned opencode client's env (the bootstrapped proxy inherits it).
Pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON envelope writer is OFF, so the on-disk .json session envelope this lane asserts on (exactly ONE persisted session under the raw key) is never written. Pin the writer ON in the spawned dsh client's env.
Pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON envelope writer is OFF, so the on-disk .json session file this lane asserts on (state survival across the OLD→NEW update) is never written. Pin the writer ON in the spawned proxy's env (both update phases share envBase).
Resolve CI baseline conflicts using the current upstream test setup.
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b)
Review — code is correct; the current head's CI is CANCELLED (not green), holding approval
The prior review (2026-11-13) verified the code on the original head and concluded mergeable. I independently re-verified the code on the current head 714dae4f5 and it holds. But the PR has since been updated to a new head (the Merge upstream master and ci-fixes commit), and that head's CI is fully cancelled — so the "green" premise no longer holds for the head under review.
Code (re-verified on head 714dae4f5)
runForeignBlockscomputesconst code = result.failed.length > 0 ? 1 : 0and uses it in both the JSON (src/storage-maintenance.ts:290) and text (src/storage-maintenance.ts:298) return paths. The exit code propagates to the process viasrc/cli.ts:767(if (r.code !== 0) process.exit(r.code)), so a failed sweep now exits 1 instead of 0.- New suite 3/3 pass; adjacent
foreign-block-sweep+storage-maintenance-cli14/14 pass (17 total, matching the body's claim). - Teeth check both directions: reverting
src/storage-maintenance.tsto master → exactly the 2 apply-mode tests fail and the dry-run control passes. Genuine regression test, not a tautology. - No
kernel/changes, no new config, no new deps. The one behavior change (failure exit0 → 1) is the intended fix and is disclosed in the body.
⚠️ Blocker — CI on head 714dae4f5 is fully CANCELLED
All 41 check runs / 12 check suites for head 714dae4f5 (created 2026-11-14T06:03:57Z) have conclusion cancelled and never completed. This is not green. The full regression was not verified on CI for the head under review. Please re-trigger the ci:full matrix and confirm green before merge.
File scope — body claim is now stale
The body says "Relative to current master, this PR still changes only src/storage-maintenance.ts and tests/foreign-block-sweep-exit.test.ts." The actual diff vs master is 12 files: the 2 PR-owned files + 10 test files pulled in by the Merge upstream master and ci-fixes commit. I confirmed the 10 extras come from origin/ci-fixes (pinning BILI_STORAGE_JSON_WRITER=on after #6480's pure-sqlite default) — the sanctioned CI-coordination flow — but they will merge to master via this PR, so the "only 2 files" claim is inaccurate. Worth a one-line correction so the merge is intentional.
八问
- 是什么问题:
bili sessions foreign-blocks --apply在块归档写失败(如 EISDIR)时仍返回退出码 0,依赖退出码的定时修复脚本会把失败误判为成功。 - 什么原因导致的:
runForeignBlocks的 apply 路径两条输出分支硬编码code: 0,applyForeignBlockSweep返回的failed列表只进了报告正文、从未传播到退出状态(原始 #5343 只报告、不传播)。 - 影响范围与严重程度: 所有以退出码判断结果的
foreign-blocks --apply调用方(典型为定时脚本);失败在报告中可见、块保持 live 可重试、无数据丢失 —— p2(能用但有明显误判)。 - 怎么修复的:
result.failed.length > 0时 code=1(text/JSON 共用),完整保留 archived/failed 报告;dry-run/成功/空重跑保持 0。 - 是否有回归问题: 无。逐项过: dry-run(0,有测试)、成功(0,有测试)、空重跑(0,有测试)、JSON/text 报告形状(不变)、其他 sessions 子命令与 storage gc(未触碰)、CLI 退出接线(已支持非零)。唯一行为变更=失败退出码 0→1,有意且已披露。
- 是否破坏缓存: 不涉及(纯 CLI 退出状态,无缓存/重试/游标)。
- 是否改了设计方向: 不涉及(单函数退出码修正,无架构/数据流变化)。
- 是否引入了新的配置: 不涉及(无新 env/config/默认值)。
判定: 代码合格(本地已双向往返验证),但当前 head 714dae4f5 的 CI 整轮被取消(41/41 cancelled),全量回归未在 CI 上验证 —— 先重跑 ci:full 矩阵确认绿再合。另请修正文 "only 2 files" 的过期表述(实际 12 文件,10 个来自 ci-fixes 合并)。
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Review posted — COMMENT (holding approval; CI on the current head is cancelled, not green)I posted a formal review (COMMENT) on this PR. Summary: Code is correct (independently re-verified on head
File scope — body claim is stale: the body says "only 2 files" but the actual diff vs master is 12 files (the 2 PR-owned + 10 test files from the 八问
判定: 代码合格(本地已双向往返验证),但当前 head |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Review complete. Formal review (COMMENT) posted on this PR; full findings + 八问 in the review above. Verdict: code is correct (independently verified on head No small findings to fix on the spot (both findings are CI-state / author's body to correct); no |
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b)
Review — APPROVE: code correct, CI re-triggered (nearly green), previous cancellation resolved
The PR was updated to a new head 101dc32e6 (a merge of the latest master 9495c764 into the branch). This addresses the previous review's CI-cancellation blocker: the CI is now running (no longer cancelled).
Code (re-verified, byte-for-byte unchanged)
- The fix diff is identical to the original:
runForeignBlockscomputesconst code = result.failed.length > 0 ? 1 : 0and uses it in both the JSON and text return paths. Exit propagates viasrc/cli.ts:767. - Independently re-verified locally (previous review): new suite 3/3 pass, adjacent
foreign-block-sweep+storage-maintenance-cli14/14 pass, teeth check both directions (reverting the fix → exactly 2 apply-mode tests fail, dry-run control passes).
CI (previous blocker resolved; nearly green)
- The previous head
714dae4f5had all 41 checks CANCELLED. The new head101dc32e6has a fresh CI run: 16 success + 12 skipped + 2 in_progress + 0 failed (total 30). The 2 in_progress are the last test shards (ubuntu 22/24); all 28 completed checks are green. The CI is on track to be fully green — the previous cancellation is resolved.
Net diff (body claim slightly stale)
- The body says "only 2 files" but the actual net diff vs the new base
9495c764is 3 files:src/storage-maintenance.ts(+3 -2, the fix),tests/foreign-block-sweep-exit.test.ts(+81, the test), andtests/e2e/e2e-update-state.test.ts(+5, from the ci-fixes merge — 9 of the 10 ci-fixes test files are now in master, so only this 1 remains in the net diff). The 3rd file is the sanctioned CI-coordination flow, not the PR's intended fix. The PR's intended fix is still just the 2 PR-owned files.
八问
- 是什么问题:
bili sessions foreign-blocks --apply在块归档写失败(如 EISDIR)时仍返回退出码 0,依赖退出码的定时修复脚本会把失败误判为成功。 - 什么原因导致的:
runForeignBlocks的 apply 路径两条输出分支硬编码code: 0,applyForeignBlockSweep返回的failed列表只进了报告正文、从未传播到退出状态(原始 #5343 只报告、不传播)。 - 影响范围与严重程度: 所有以退出码判断结果的
foreign-blocks --apply调用方(典型为定时脚本);失败在报告中可见、块保持 live 可重试、无数据丢失 —— p2(能用但有明显误判)。 - 怎么修复的:
result.failed.length > 0时 code=1(text/JSON 共用),完整保留 archived/failed 报告;dry-run/成功/空重跑保持 0。 - 是否有回归问题: 无。逐项过: dry-run(0,有测试)、成功(0,有测试)、空重跑(0,有测试)、JSON/text 报告形状(不变)、其他 sessions 子命令与 storage gc(未触碰)、CLI 退出接线(已支持非零)。唯一行为变更=失败退出码 0→1,有意且已披露。
- 是否破坏缓存: 不涉及(纯 CLI 退出状态,无缓存/重试/游标)。
- 是否改了设计方向: 不涉及(单函数退出码修正,无架构/数据流变化)。
- 是否引入了新的配置: 不涉及(无新 env/config/默认值)。
判定: APPROVE。代码合格(本地已双向往返验证,与上一轮一致);CI 已重跑(28/30 完成、0 失败、2 个测试分片 in_progress,前一轮的整轮取消已解决)。唯一小瑕疵:正文 "only 2 files" 略过期(实际 net diff 3 文件,第 3 个 tests/e2e/e2e-update-state.test.ts 来自 ci-fixes 合并,属授权的 CI 协调流,非本 PR 的修复内容)——非阻塞。
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Review posted — APPROVE (code correct; CI re-triggered, nearly green; previous cancellation resolved)The PR was updated to a new head Code: byte-for-byte unchanged, correct (re-verified: new suite 3/3 + adjacent 14/14 pass, teeth check both directions — reverting the fix fails exactly the 2 apply-mode tests). CI: the previous head Net diff: 3 files (2 PR-owned + 1 ci-fixes file 八问
判定: APPROVE。代码合格(本地双向往返验证),CI 已重跑且前一轮整轮取消已解决(28/30 已绿、0 失败,2 个测试分片仍在跑)。唯一小瑕疵:正文 "only 2 files" 略过期(实际 3 文件,第 3 个来自 ci-fixes 合并)——非阻塞。 |
|
Superseded by #6677 (merged as Landed into master via the real merge commit The fix for #6497 is now in master. Closing this PR as superseded — thanks for the careful, well-tested fix. |
Closes #6497
Problem
bili sessions foreign-blocks --apply returns exit code 0 even when every block archive fails. The report contains failed entries and the blocks remain live, but scripts checking the process status still treat the repair as successful. This differs from the individual archive/restore commands, which report failure.
Changes
Return a nonzero result whenever the sweep has a failed archive, for both text and JSON output. Preserve the complete archived/failed report so callers can inspect partial results. Dry-runs, successful sweeps and empty reruns retain success status.
Original feature validation
The new tests seed a real SQLite store with two foreign blocks and one healthy block, then make the archive-log path a directory. On unchanged master 9674cfa, both output modes report code 0 after the real EISDIR write failure: 2 failed regressions and 1 passing dry-run control.
After the fix, all 17 tests across the new failure suite, foreign-block-sweep, and storage-maintenance-cli pass. Tests also remove the obstruction, retry successfully, confirm healthy data remains, and verify an empty rerun succeeds.
Passed: npm run typecheck; npm run build; npm run check:unused-exports; npm run check:test-import-graph; git diff --check.
The zero-token Codex preflight finds the CLI and built distribution; its local model endpoint is unreachable and the real-model case is skipped. Full real-model E2E and upstream CI remain unverified.
Scope and prior work
The exit status now reflects failures already reported by the existing sweep result; archive policy, retention, restore behavior and CLI options are unchanged. Checked 61 author PRs, 163 fork heads, complete storage-maintenance history, and foreign-blocks/failed/maintenance/exit searches. The original #5343 adds the sweep and reports failures in its body; it does not propagate them to the CLI exit status.
Current master integration
Merged upstream
fcc2e848486cc2152e36b6658c517fbfa51ec428into this branch without rewriting the existing feature commit. Integration head:da16c4133f9fa5305b5e79569448c3aa04ee6a5c. The merge parents are the original feature head816b289db2d89e36cf00d4eb72641daa0541ac09and the upstream commit above.The production file and feature test are byte-for-byte unchanged from the original feature head. Relative to current master, this PR still changes only
src/storage-maintenance.tsandtests/foreign-block-sweep-exit.test.ts.Revalidated the merged tree on Node 24.22.1:
foreign-block-sweep-exit,foreign-block-sweep, andstorage-maintenance-clipass, using the repository's storage and test-environment preloads.npm run typecheck,npm run build,npm run check:unused-exports, andnpm run check:test-import-graphpass.git diff fcc2e848486cc2152e36b6658c517fbfa51ec428 --checkis clean for this PR's net changes.The original failure/control reproduction above remains tied to
9674cfafbc78c50245ae0d887483d3d6ce880c15; the validation in this section was rerun after integrating current master. Full real-model E2E was not rerun locally.Review status
Linked to #6497 and ready for maintainer review. The branch now includes current master and is mergeable; GitHub no longer reports it as behind. CI run 43377305290 was queued for this exact integration head when this update was prepared. The Checks tab contains the current hosted results.
Please apply the existing
ci:fulllabel to run the FULL matrix, including the required Windows / Node 24 checks. The default CORE matrix does not produce those checks.