Skip to content

test(memdir): serialize hosted-memory path tests against the home env lock - #174

Merged
BunsDev merged 1 commit into
mainfrom
fix/hosted-memory-env-race
Jul 31, 2026
Merged

test(memdir): serialize hosted-memory path tests against the home env lock#174
BunsDev merged 1 commit into
mainfrom
fix/hosted-memory-env-race

Conversation

@BunsDev

@BunsDev BunsDev commented Jul 31, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the intermittent CI failure in memdir::tests::hosted_memory_ignores_local_checkout_path (Actions run 30271680167; Cave bead cave-r78ad): the test — plus two sibling hosted-path tests — resolved home-dependent memory paths without holding COVEN_HOME_ENV_LOCK, so a parallel test's COVEN_CODE_TEST_HOME set_var/remove_var could flip the home between two resolutions and break equal-path assertions.

The audit found every mutator already holds the lock (including claudemd's), and CONFIG_HOME_ENV_LOCK is a re-export of the same mutex — one lock covers all; these three were the only unlocked readers. Each now takes the shared lock and pins a private tempdir home for its duration (restored after), matching the module's mutating-test convention, so the assertions are hermetic as well as serialized.

Verification

  • memdir:: module: 41/41 across repeated runs.
  • cargo fmt --check clean.

🤖 Generated with Claude Code

… lock

hosted_memory_ignores_local_checkout_path (and two sibling hosted-path
tests) resolved home-dependent memory paths without holding
COVEN_HOME_ENV_LOCK, so a parallel test's COVEN_CODE_TEST_HOME
set_var/remove_var could flip the home between two resolutions and make
equal-path assertions fail intermittently in CI (observed in Actions
run 30271680167). Every mutator already held the lock; these were the
only unlocked readers — and the config alias CONFIG_HOME_ENV_LOCK is a
re-export of the same mutex, so one lock covers all.

Each test now takes the shared lock and pins a private tempdir home for
its duration (restored after), matching the module's mutating-test
convention, so assertions are hermetic as well as serialized.

Verified: memdir:: module 41/41 across repeated runs.

Cave bead cave-r78ad.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 31, 2026 16:31
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Jul 31, 2026 4:32pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses intermittent CI flakiness in memdir hosted-memory path tests by serializing home-directory resolution against other tests that mutate COVEN_CODE_TEST_HOME, ensuring path resolution and assertions run against a stable, test-private home.

Changes:

  • Added COVEN_HOME_ENV_LOCK acquisition around hosted-memory path resolution in three tests.
  • Pinned COVEN_CODE_TEST_HOME to a private tempdir for the duration of each affected test (restoring afterward).
  • Documented the race scenario and why serialization is required.
Suppressed comments (2)

src-rust/crates/core/src/memdir.rs:1142

  • COVEN_CODE_TEST_HOME is restored after the assertions. If an assertion panics, the env var stays set and can affect other tests that run after this one. Restore the env var before assertions (or use a Drop guard) so failures don’t leak process-global state.
        match original_test_home {
            Some(value) => std::env::set_var("COVEN_CODE_TEST_HOME", value),
            None => std::env::remove_var("COVEN_CODE_TEST_HOME"),
        }

src-rust/crates/core/src/memdir.rs:1244

  • COVEN_CODE_TEST_HOME is restored only after assertions. If an assertion panics, the env var stays set and can leak into other tests. Restore the env var before running assertions so failures don’t contaminate subsequent tests.
        match original_test_home {
            Some(value) => std::env::set_var("COVEN_CODE_TEST_HOME", value),
            None => std::env::remove_var("COVEN_CODE_TEST_HOME"),
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1075 to +1078
match original_test_home {
Some(value) => std::env::set_var("COVEN_CODE_TEST_HOME", value),
None => std::env::remove_var("COVEN_CODE_TEST_HOME"),
}
@BunsDev
BunsDev merged commit 122f5a6 into main Jul 31, 2026
5 checks passed
@BunsDev
BunsDev deleted the fix/hosted-memory-env-race branch July 31, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants