fix(handlers): synchronize fakeCPProv to eliminate TestProxyA2A data races (#1117) #3163
Reference in New Issue
Block a user
Delete Branch "fix/core-1117-proxy-test-races"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes molecule-core#1117.
Problem
Platform(Go) -racefailed onTestProxyA2A_Upstream502_TriggersContainerDeadCheckandTestProxyA2A_Upstream502_AliveAgent_PropagatesAsIsbecause thefakeCPProvtest double mutated shared state (calls,stopCalls,startCalls,running) without synchronization.IsRunning/Stop/Startcan run on detached restart goroutines while the test goroutine reads the counters.Fix
sync.MutextofakeCPProv.Calls(),StopCalls(),StartCalls()and settersetRunning().Verification
go test ./internal/handlers/ -count=1passesgolangci-lint run ./internal/handlers/cleanCo-Authored-By: Claude noreply@anthropic.com
🤖 Generated with Claude Code
Independent 2nd-genuine review for molecule-core#3163 @
f0f104ab78.REQUEST_CHANGES pending required verification. Code review of workspace-server/internal/handlers/a2a_proxy_test.go is clean: fakeCPProv now guards calls/stopCalls/startCalls/running with a mutex, all post-construction reads use Calls()/StopCalls()/StartCalls(), the only runtime write uses setRunning(), and remaining struct-literal initializations happen before concurrent use. The accessor refactor preserves the dead-check and access-check assertions that exposed the original TestProxyA2A races.
Blocker: I cannot confirm the requested Platform(Go) -race proof on this head. The current-head status set does not include a CI / Platform (Go) context; observed red contexts are qa-review/security-review approval gates and sop-checklist, with E2E API still pending. I also attempted a local focused
go test -race -count=50 ./internal/handlers -run TestProxyA2A_...onf0f104a, but this container has no go binary, so I cannot supply the local fallback proof.Approve path: get CI / Platform (Go) on
f0f104agreen, or provide an equivalent same-head race run artifact. No code-level blocker found.5-axis review complete on head
f0f104ab78.Correctness: the fakeCPProv synchronization directly addresses the TestProxyA2A race: calls, stopCalls, startCalls, and running are now accessed through a mutex-backed API, with test assertions moved to the getters and the runtime mutation moved to setRunning.
Robustness: the existing async restart goroutine can now race safely with assertions; the struct literals only seed initial state before concurrent use.
Security/performance: test-only change; no production behavior, token handling, or runtime path changes. Mutex cost is irrelevant in tests.
Readability: the helper API makes the concurrency contract explicit without broadening the fixture scope.
CI discipline: own-head CI / Platform (Go) is success on
f0f104ab78.Independent re-review for molecule-core#3163 @
f0f104ab78.APPROVE. The prior verification-only RC is resolved: CI / Platform (Go) is success on this exact head (run 394068, job 546752).
Code review remains clean. fakeCPProv guards the shared calls, stopCalls, startCalls, and running fields with a mutex; test assertions use Calls()/StopCalls()/StartCalls(); the only runtime mutation uses setRunning(); remaining struct literal writes are pre-concurrency setup. The accessor refactor preserves the original dead-check and access-check assertions while removing the restart-goroutine/test-goroutine race. Test-only change; no production behavior or security surface change.