test: repair the pre-existing compat-offline-core failures - #450
Open
genedna wants to merge 2 commits into
Open
Conversation
None of these are new. They accumulated because `cargo test --all` is fail-fast: once the lib suite started failing on 2026-07-28 every run aborted there, so nothing downstream was ever reported and each new breakage landed unseen on top of the last. - worktree_scope (0ce8f77): five tests call `std::env::set_current_dir` directly. `#[serial]` only orders them against other `#[serial]` tests, not against the CWD_LOCK every `ChangeDirGuard` holds, so they yanked the process cwd out from under whatever fixture was in flight — which is what took down the ai/hooks, rename_detect and utils::path tests with them. They now take that lock, and take it AFTER building their fixtures so a whole `libra init` does not run under a lock the rest of the suite waits on. `a_pinned_scope_survives_a_cwd_change` additionally pinned the ambient cwd, which `RequestScope::resolve` refuses outside a repository: it only ever passed by stealing a moment when another test had parked the cwd in someone else's fixture, which is the same moment it broke that test. It gets a real repository now. - ai/hooks/runtime (6da73c6): `CaptureScope` entered the ingest path and resolves `RepoIdentity`, but `ingest_fresh_conn` never wrote `libra.repoid`, so 14 tests failed deterministically — single-test runs included. Seed it, as `libra init` does. `ingest_fails_loud_when_table_missing` now drops one table from a complete schema instead of starting from a schema-less database, so it still tests the claim it makes rather than failing earlier on `config_kv`; the tombstone test asserts against the claim diagnostic that now carries the refusal. - utils/path: the commondir fixture's target lacked the repository database, so it no longer satisfies `is_terminal_common_storage`. - rename_detect (5c1b7bb, a26cc9a): the LFS classification resolves `working_dir()` infallibly on the pooled io thread, which panicked the worker outside a repository and reached the caller as an opaque `IoTimeout`. Both tests get a repository. A jammed pool reports `IoTimeout` too — the seam tests abandon reads that keep sleeping in a worker past their own end, and the pool is process-global — so the negative test drains the pool and retries. A seam that really fired would still blow every attempt, so the assertion keeps its teeth. - ai/web: `type_complexity` on a test-local adapter field, now a named alias that also records what the tuple's two halves mean. Verified with `cargo test --lib`: 4409 passed, 0 failed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`8f47a4c4` removed tests/data/ai_semantic/rust/{sample,tools_sample}.rs
but left tests/ai_semantic_{rust,tools}_test.rs, which `include_str!`
them. main therefore does not COMPILE under `--all-targets`:
error: couldn't read `tests/data/ai_semantic/rust/sample.rs`
error: could not compile `libra` (test "ai_semantic_rust_test")
This breaks `compat-clippy` for every open PR, not just this one.
Restored verbatim from 8f47a4c^ rather than deleting the orphaned
tests: the fixtures carry `Line numbers are pinned by that test` in
their own header, and the assertions still reference those lines, so
dropping the tests would silently retire live coverage on a judgement
that belongs to whoever made the deletion. Restoring is the reading
that keeps both halves consistent. `cargo fmt --all` leaves them
untouched — they are not in the module tree — so the pinned lines stay
put.
Verified: ai_semantic_rust_test 4 passed, ai_semantic_tools_test 5
passed, and `cargo clippy --all-targets --all-features -- -D warnings`
is clean again.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
这些失败都不是新的
它们是攒出来的。
cargo test --all是 fail-fast:自 2026-07-28 lib 套件开始失败后,每一次运行都在那里中止,下游从来没有被报告过,于是每个新的破坏都无声地叠在上一个之上。修复清单
1. 编译期断裂(阻塞所有 PR)
8f47a4c4删掉了tests/data/ai_semantic/rust/{sample,tools_sample}.rs,却留下include_str!它们的两个测试文件。main 当前在--all-targets下无法编译:这会让每一个开着的 PR 的
compat-clippy失败,不只是本 PR。选择从
8f47a4c4^原样恢复夹具,而非删掉这两个测试:夹具自己的头部写着Line numbers are pinned by that test,测试里的断言仍在引用那些行号,删测试等于依据一个本该由删除者定夺的判断悄悄退掉活跃覆盖。恢复才是让两半保持自洽的读法。cargo fmt --all不会碰它们(不在模块树里),钉死的行号安全。2.
worktree_scope的 cwd 锁(0ce8f77c)五个测试直接调
std::env::set_current_dir。#[serial]只与其他#[serial]测试互斥,与每个ChangeDirGuard持有的CWD_LOCK是两套锁,于是它们把进程 cwd 从正在运行的夹具下面抽走——这正是连带打死 ai/hooks、rename_detect、utils::path 那批测试的原因。现在它们持有那把锁,并且在建完夹具之后才持有,避免整个
libra init在一把全套件都在等的锁下运行。a_pinned_scope_survives_a_cwd_change另有一处:它 pin 的是环境 cwd,而RequestScope::resolve在非仓库目录下不装 pin——它此前只在「偶然抢到别的测试把 cwd 停在某个 libra 夹具里」的瞬间才通过,而那一刻恰恰就是它打死那个测试的一刻。现在给它一个真实仓库。3.
ai/hooks/runtime的libra.repoid(6da73c67)CaptureScope接入 ingest 路径后要解析RepoIdentity,但夹具ingest_fresh_conn从未写入libra.repoid,导致 14 条测试确定性失败——单条跑也挂。按libra init的做法补上种子。ingest_fails_loud_when_table_missing改为从完整 schema 里删掉一张表,而不是从无 schema 的空库开始:否则它会更早地栽在config_kv上,测不到它自己声称要测的东西。tombstone 测试则改为断言现在承载该拒绝的那条诊断信息。4.
utils/path的 commondir 夹具夹具的 commondir 目标缺少仓库数据库,已不再满足
is_terminal_common_storage。5.
rename_detect(5c1b7bb2、a26cc9ac)LFS 分类在池化 io 线程上调用不可失败的
working_dir(),在非仓库目录下直接 panic 掉 worker,传到调用方只剩一个语焉不详的IoTimeout。两个测试都给了真实仓库。另外池被占满时同样报
IoTimeout——seam 测试会放弃那些仍在 worker 里睡觉的读,槽位活得比测试本身长,而池是进程级的。所以那个反向测试改为先排空池再重试。真正触发了 seam 的话每次重试都会挂,断言的判别力没有削弱。6.
ai/web的type_complexity测试内部适配器字段的复杂类型,改为具名别名,顺带把元组两半的含义写下来。
验证
cargo test --lib:4409 passed / 0 failedai_semantic_rust_test4 passed、ai_semantic_tools_test5 passedcargo +nightly fmt --all --check干净cargo clippy --all-targets --all-features -- -D warnings干净不在本 PR 范围内
#447 的分片运行还暴露了若干产品与测试的契约不一致,例如只读 DB 导致的失败该报
LBR-IO-001(打开失败)还是LBR-IO-002(写失败)、过期租约该返回 403 还是 409。改断言能让它们变绿,但那是在替维护者决定契约,不适合由本 PR 单方面做。🤖 Generated with Claude Code
Note
Low Risk
Test-only and fixture changes with no production logic paths modified; risk is limited to CI signal quality if a fix masks a real bug.
Overview
Unblocks
cargo test --allby fixing compile breaks, flaky cross-test cwd interference, and outdated test fixtures—not product behavior changes.Restores deleted AI semantic fixtures (
tests/data/ai_semantic/rust/sample.rsandtools_sample.rs) so integration tests thatinclude_str!them and pin line numbers compile again.Serializes worktree scope tests that call
set_current_dirby takingChangeDirGuard'scwd_lock_guardafter fixtures are built (solibra initdoes not hold the suite-wide lock), and givesa_pinned_scope_survives_a_cwd_changea real repo so pinning is not a false pass on ambient cwd.Hardens rename_detect / status I/O tests: lightweight
repo_fixturefor LFS/working_dir()discovery;wait_for_idle_io_poolplus retry inslow_op_seams_are_ignored_without_the_harness_gateso a full global I/O pool is not mistaken for fired delay seams.Aligns AI hooks ingest tests with current contracts: seed
libra.repoidiningest_fresh_conn, drop a single table for the missing-table test, and assert tombstone errors via claim / erased diagnostics.Fixes
utils/pathlinked-worktree fixture by adding a stub repo DB so commondir targets satisfy terminal common storage. Minorai/webtest type alias for clippy.Reviewed by Cursor Bugbot for commit 4c8fd5b. Bugbot is set up for automated code reviews on this repo. Configure here.