fix(concurrency): add thread safety to InvariantService #11086

Merged
HAL9000 merged 9 commits from bugfix/m3-invariant-service-thread-safety into master 2026-06-18 03:13:38 +00:00

9 Commits

Author SHA1 Message Date
controller-ci-rerun ddca14c066 chore: re-trigger CI [controller]
CI / load-versions (pull_request) Successful in 17s
CI / push-validation (pull_request) Successful in 26s
CI / build (pull_request) Successful in 39s
CI / lint (pull_request) Successful in 46s
CI / quality (pull_request) Successful in 59s
CI / typecheck (pull_request) Successful in 1m9s
CI / security (pull_request) Successful in 1m8s
CI / helm (pull_request) Successful in 45s
CI / unit_tests (pull_request) Successful in 5m45s
CI / docker (pull_request) Successful in 1m32s
CI / integration_tests (pull_request) Successful in 10m17s
CI / coverage (pull_request) Successful in 11m44s
CI / status-check (pull_request) Successful in 3s
2026-06-17 22:50:12 -04:00
CleverAgents Bot e2f7142d74 ci: rerun invariant thread safety gates
CI / load-versions (pull_request) Successful in 16s
CI / push-validation (pull_request) Successful in 26s
CI / unit_tests (pull_request) Failing after 42s
CI / lint (pull_request) Successful in 45s
CI / build (pull_request) Successful in 37s
CI / quality (pull_request) Successful in 1m2s
CI / security (pull_request) Successful in 1m10s
CI / typecheck (pull_request) Successful in 1m13s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / helm (pull_request) Failing after 39s
CI / integration_tests (pull_request) Successful in 10m27s
CI / status-check (pull_request) Failing after 3s
2026-06-17 22:36:33 -04:00
controller-ci-rerun 10bea28b91 chore: re-trigger CI [controller] 2026-06-17 22:36:33 -04:00
controller-ci-rerun af5bb283d5 chore: re-trigger CI [controller] 2026-06-17 22:36:33 -04:00
HAL9000 957c6c622e fix(tests): correct ScenarioOutline syntax and step parameter mismatches
Replace {col}/{col:d} curly-brace column refs with Behave-required <col>
angle-bracket syntax in all ScenarioOutline step text. Rename ambiguous
given step to avoid duplicate step definition conflicts. Fix min_ -> min_count
parameter mismatch, move _error_mutex init before thread start to eliminate
lock race, apply ruff format wraps, and add get_invariant() call in snapshot
step to cover invariant_service.py:560-561.

ISSUES CLOSED: #7524
2026-06-17 22:36:33 -04:00
controller-ci-rerun 6ec7479c2e chore: re-trigger CI [controller] 2026-06-17 22:36:33 -04:00
controller-ci-rerun b87827f351 chore: re-trigger CI [controller] 2026-06-17 22:36:33 -04:00
HAL9000 50098eada7 fix(concurrency): add thread safety to InvariantService (lint and Behave fixes)
Address all review feedback from HAL9001:
- Remove unused 'from typing import cast' import (F401)
- Replace unused variables with _ prefix (F841)
- Use contextlib.suppress(Exception) instead of try/except/pass (SIM105)
- Fix ScenarioOutline decorators to use curly-brace {param:d} syntax
- Convert And-Then steps to proper Then/assertion steps for Behave compatibility
- Rename branch from pr_fix/8209 to bugfix/m3-invariant-service-thread-safety

Fixes: resolves PR #11051 review comments
2026-06-17 22:36:33 -04:00
HAL9000 7470f98155 fix(concurrency): add thread safety to InvariantService
Add threading.RLock to InvariantService to protect shared state
(_invariants dict, _enforcement_records list) from concurrent access
by multiple threads during parallel plan execution. Prevents
RuntimeError: dictionary changed size during iteration and data
corruption in multi-threaded environments.

Changes:
- Added self._lock = RLock() in __init__
- Wrapped all public methods (add_invariant, list_invariants,
  remove_invariant, get_effective_invariants, enforce_invariants)
  with lock acquisition via context managers
- Added helper read methods: get_enforcement_records(), get_invariant(),
  get_invariants_snapshot() -- all thread-safe
- Added BDD tests for concurrent access patterns
- Updated CHANGELOG.md and CONTRIBUTORS.md

ISSUES CLOSED: #7524
2026-06-17 22:36:33 -04:00