test(skill-install): serialize harness tests around the home env vars - #293
Merged
Merged
Conversation
hermes_skills_dir_honors_hermes_home_env overrode the process-wide HERMES_HOME without any lock, while detects_hermes_from_home_layout and skills_dirs_match_harness_spec resolved Hermes through that variable on other libtest threads: the detection test read the override's temp directory and failed about six times in thirty runs. The Kimi tests took kimi_env_lock, but skills_dirs_match_harness_spec read KIMI_CODE_HOME without it, leaving the same failure latent there. Widen that lock to harness_env_lock, take it in every test that reads or writes HERMES_HOME or KIMI_CODE_HOME, and replace the two SAFETY comments whose invariant did not hold: the hazard is a concurrent reader, not only another writer.
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.
Fixes #292.
Problem
hermes_skills_dir_honors_hermes_home_envoverrides the process-wideHERMES_HOMEwithout holding any lock, whiledetects_hermes_from_home_layoutandskills_dirs_match_harness_specresolve Hermes through that same variable on other libtest threads. Onmain(d04c752),cargo test -p bsk --lib skill_installfailed 6 times in 30 runs, alwaysdetects_hermes_from_home_layoutreading the other test's temp directory:The Kimi Code tests already share
kimi_env_lock, butskills_dirs_match_harness_specreadsKIMI_CODE_HOMEwithout taking it, so the same failure was latent there. Bothunsafeblocks carried SAFETY comments whose stated invariant did not hold: the hazard is any concurrent reader, not only another writer, which is also why edition 2024 marksset_varunsafe.Change
Test-only.
kimi_env_lockbecomesharness_env_lock, covering both variables, with alock_harness_env()helper; all five tests that read or writeHERMES_HOME/KIMI_CODE_HOMEnow take it, and the two SAFETY comments state the invariant the lock actually provides.Validation
cargo test -p bsk --lib skill_install, 30 runs on the same machine: 6 failures before, 0 after.cargo test -p bsk --lib, 30 runs after the change: 0 failures. The same race hitskills_dirs_match_harness_specthere at roughly 1 run in 10 before.cargo test --workspace --lockedpasses. One unrelated failure appeared once during validation,daemon::probe::readiness_tests::readiness_retries_pid_mismatch_and_discovery_changes(probe_tests.rs:177), and did not recur in 30 further runs; I did not investigate it here.cargo fmt --all -- --checkandcargo clippy --workspace --all-targets --locked -- -D warningspass.Possible follow-up
The lock covers this module. Tests elsewhere in the crate reach these variables only by iterating
HarnessId::ALL(for examplesync_installed_harnesses) and none of them assert on the resolved home, but they do still callgetenvwhile an override is installed. Removing theunsafemutation entirely — resolvers taking an explicit override argument, with the environment read at the call site — would close that window too. Happy to send it if you want that shape.