-
Notifications
You must be signed in to change notification settings - Fork 0
Retire EnvLock rather than restore its synchronisation unit tests #321
Copy link
Copy link
Closed
Labels
concurrencyConcurrency, parallelism, and synchronization work, including races and deadlocks.Concurrency, parallelism, and synchronization work, including races and deadlocks.mediumRoadmap items to schedule within the current quarter. Clear scope, normal review cycles.Roadmap items to schedule within the current quarter. Clear scope, normal review cycles.refactorBehaviour-preserving restructuring that improves code health.Behaviour-preserving restructuring that improves code health.testingTest coverage, test infrastructure, and verification tooling work.Test coverage, test infrastructure, and verification tooling work.
Description
Activity
Metadata
Metadata
Assignees
Labels
concurrencyConcurrency, parallelism, and synchronization work, including races and deadlocks.Concurrency, parallelism, and synchronization work, including races and deadlocks.mediumRoadmap items to schedule within the current quarter. Clear scope, normal review cycles.Roadmap items to schedule within the current quarter. Clear scope, normal review cycles.refactorBehaviour-preserving restructuring that improves code health.Behaviour-preserving restructuring that improves code health.testingTest coverage, test infrastructure, and verification tooling work.Test coverage, test infrastructure, and verification tooling work.
Rescoped 2026-08-01
This issue originally asked to restore unit tests covering
ensure_env_lock()idempotency andDrop-based CWD restoration, removed in #273. That work is no longer wanted: AGENTS.md now forbids in-process environment mutation in tests and explicitly disqualifies process-wide locks as a fallback. Adding coverage forEnvLockwould entrench the mechanism being retired.The original text is preserved below for the record.
Required work
Retire
EnvLockrather than test it.test_support/src/env_lock.rsis astatic ENV_LOCK: Mutex<()>plus a thread-local re-entrancy depth counter. Its purpose is to serializestd::env::set_varandstd::env::set_current_dircalls across the suite.mockable::Envin production signatures, so no test needs to mutate global state and no lock is required.This issue now stands for the decision — that
EnvLockis retired rather than hardened — and closes when #494 closes.Why the synchronisation properties no longer need coverage
The two properties named in the original issue are properties of the lock, not of Netsuke. Once the lock has no callers,
ensure_env_lockidempotency is vacuous and CWD restoration is handled by the scenarios that no longer change the working directory at all (#492).Original issue text
Summary
PR #273 removed the
#[cfg(test)] mod testsblock fromtests/bdd/fixtures/mod.rsthat previously validatedensure_env_lock()andDropCWD restoration behaviour. This leaves theEnvLockguard untested at the unit level, which is a risk given that BDD tests rely on it for process-wide environment isolation.Context
The removed block validated:
ensure_env_lock()is idempotent when the lock is already heldDropimplementation restores the original working directoryThese are synchronisation correctness properties and should be covered by dedicated unit tests.
Proposed work
ensure_env_lockidempotency testDrop-based CWD restoration testensure_env_lockandrestore_environment_lockedsemantics introduced in PR Complete CLI config struct implementation with OrthoConfig (0.8.0) (3.11.1) #273Backlinks