fix(actor): fix TOCTOU race condition in ensure_default_mock_actor() #10627

Merged
HAL9000 merged 2 commits from fix/v360/actor-service-toctou into master 2026-04-27 09:14:24 +00:00

2 Commits

Author SHA1 Message Date
HAL9000 abbb8547f7 fix(test): revert a2a SDK test to check for Client class not A2AClient
CI / build (push) Successful in 48s
CI / benchmark-publish (push) Failing after 46s
CI / lint (push) Successful in 1m6s
CI / helm (push) Successful in 38s
CI / push-validation (push) Successful in 34s
CI / typecheck (push) Successful in 1m41s
CI / security (push) Successful in 1m40s
CI / quality (push) Successful in 1m46s
CI / integration_tests (push) Failing after 3m33s
CI / e2e_tests (push) Successful in 5m5s
CI / unit_tests (push) Successful in 5m20s
CI / docker (push) Successful in 1m29s
CI / coverage (push) Successful in 10m54s
CI / status-check (push) Failing after 3s
CI / lint (pull_request) Successful in 56s
CI / build (pull_request) Successful in 53s
CI / typecheck (pull_request) Successful in 1m34s
CI / quality (pull_request) Successful in 1m44s
CI / benchmark-publish (pull_request) Has been skipped
CI / security (pull_request) Successful in 1m48s
CI / push-validation (pull_request) Successful in 34s
CI / helm (pull_request) Successful in 36s
CI / integration_tests (pull_request) Failing after 3m54s
CI / e2e_tests (pull_request) Successful in 4m29s
CI / unit_tests (pull_request) Successful in 5m7s
CI / docker (pull_request) Successful in 1m49s
CI / coverage (pull_request) Successful in 11m21s
CI / status-check (pull_request) Failing after 3s
The a2a.client module exposes Client, not A2AClient. The PR incorrectly changed the TDD scenario to check for A2AClient which does not exist in the installed a2a SDK, causing the unit_tests CI gate to fail.
2026-04-27 08:57:27 +00:00
HAL9000 4e37da2471 fix(concurrency): make ensure_default_mock_actor atomic to prevent TOCTOU race
Merge the two separate database transactions in ensure_default_mock_actor()
into a single atomic transaction to prevent Time-of-Check-Time-of-Use (TOCTOU)
race conditions in concurrent environments (e.g., parallel test workers).

The original implementation had a gap between checking for an existing default
actor and creating a new mock actor. In concurrent scenarios, multiple threads
could both observe no default and attempt to create one, leading to potential
constraint violations or inconsistent state.

The fix consolidates both operations into a single transaction, ensuring that
the check and creation are atomic and safe for concurrent callers.

Added BDD test scenarios to verify idempotency and concurrent safety:
- Idempotency: calling ensure_default_mock_actor multiple times produces same result
- Existing default safety: respects existing default actors
- Single actor creation: ensures only one mock actor is created

Closes #8448
2026-04-27 08:57:27 +00:00