fix(engine_cache): guard MEMORY_ENGINES with lock to prevent TOCTOU race #8265

Merged
HAL9000 merged 2 commits from fix/7566-engine-cache-toctou-race into master 2026-06-02 10:41:27 +00:00

2 Commits

Author SHA1 Message Date
HAL9000 9ae4e6c36e fix(tests): remove type: ignore and fix ruff format in toctou step file
CI / push-validation (pull_request) Successful in 22s
CI / build (pull_request) Successful in 29s
CI / lint (pull_request) Successful in 40s
CI / helm (pull_request) Successful in 40s
CI / quality (pull_request) Successful in 43s
CI / typecheck (pull_request) Successful in 1m13s
CI / security (pull_request) Successful in 1m20s
CI / unit_tests (pull_request) Successful in 5m31s
CI / integration_tests (pull_request) Successful in 8m17s
CI / docker (pull_request) Successful in 2m28s
CI / coverage (pull_request) Successful in 8m3s
CI / status-check (pull_request) Successful in 2s
Replace five # type: ignore comments with setattr() calls (for module
attribute monkey-patching) and an Any return type (for _get_memory_engines),
eliminating all type suppressions per project zero-tolerance policy.

Fix ruff format violations: collapse @when decorator to one line, reformat
raise...from split, and reformat assert message wrapping.

ISSUES CLOSED: #7566
2026-06-02 05:51:55 -04:00
HAL9000 d54ed1440c fix(engine_cache): guard MEMORY_ENGINES with lock to prevent TOCTOU race
Add MEMORY_ENGINES_LOCK to engine_cache.py and wrap the check-and-set
in UnitOfWork.engine with it to prevent concurrent threads from creating
duplicate in-memory SQLite engines. Also fix cache-hit bug where
self._engine was never assigned on a cache hit.

Closes #7566
2026-06-02 05:51:55 -04:00