Repository navigation
fix(plugin): synchronize the InvokeWithExecutor reverse-server handoff (data race) - #74
Conversation
…f (data race) grpcProvider.InvokeWithExecutor stands up the host ExecutorService on the go-plugin broker for the duration of a deploy/step/check Invoke. The reverse gRPC server was held in a plain `var srv *grpc.Server`: the AcceptAndServe callback (broker-accept goroutine) WROTE it while the deferred Stop() (the InvokeWithExecutor goroutine, after Invoke returns) READ it — an unsynchronized cross-goroutine handoff the -race detector flags (WRITE plugin_grpc.go:170 vs READ :187), exercised by the substrate-lifecycle e2e reverse-channel round-trip. Root-cause fix: srv becomes an atomic.Pointer[grpc.Server] — the callback Stores the server it built, the deferred Load reads it (or nil if the plugin never dialed back). A real happens-before edge, NOT a serialize-to-hide or a -race suppression; behaviour otherwise unchanged. R2: opened as its own immediate cutover after the scaffold PR's full -race run surfaced the RCA. Verified: go test -run TestSubstrateLifecycle_PrepareVenueDescriptorRoundTrip -race -count=10 (0 data-race reports, was a hard DATA RACE); full go test ./charly/... green; golangci-lint 0 issues; gofmt clean. Assisted-by: Claude (analysed on a live system) Claude-Session: https://claude.ai/code/session_01R8UGGr3ui1959oTb5JuSif
…sion The #74 grpc-race CHANGELOG placeholder collided with the filename retention #73 finalized to at its merge (v2026.193.1414). Renamed to 2026.193.1422 (content unchanged; the validator re-finalizes to the merge-time CalVer anyway). Keeps #73's landed 2026.193.1414.md intact. Assisted-by: Claude (documentation reviewed) Claude-Session: https://claude.ai/code/session_01R8UGGr3ui1959oTb5JuSif
pr-validator — APPROVED ✅Change class: charly/sdk Go (in-process concurrency fix — data race) A genuine root-cause fix: Checklist
Independently-derived race proof (my runs)Note: Decision: the fix eliminates a real data race with the correct synchronization primitive, behaviour unchanged, all gates green, reproduced-then-cleared under Assisted-by: Claude (analysed on a live system) |
Merge-time version stamp for the InvokeWithExecutor reverse-server data-race fix. Assisted-by: Claude (analysed on a live system)
…hoc cleanup + snapshot pluginSchemas Addresses the PR #76 CHANGES-REQUESTED verdict (R3 + R1): the seam commit b802371 claimed it 'replaces the ad-hoc delete(...) cleanups (ONE reset pattern)' but its diff deleted nothing — apk_format_test.go's TestRunPlan_StampsStepOrigin kept an ad-hoc registry-only delete(providerRegistry.byKey/origins) cleanup, so two reset patterns coexisted and the claim was false. - Convert TestRunPlan_StampsStepOrigin to t.Cleanup(snapshotProviderState()) as its first line and DELETE the ad-hoc delete-block. The diff now SHOWS the deletion and 'ONE reset pattern' is TRUE. git grep 'delete(providerRegistry\.' returns nothing (R5). - Extend snapshotProviderState() to also snapshot/restore the process-wide plugin schema set (pluginSchemas: sources/inputDefs/unified). This resolves the validator's non-blocking note by REMOVING the reliance, not merely confirming it: the append-only sources slice no longer grows under -count>N and the seam stops leaning on 'identical defs unify + no two tests share a def name'. Verification: go test ./charly/... -count=2 green; go test -race -count=20 on all 47 registering e2e tests — 0 races, 0 duplicate-registration failures (rebased onto main #74, so substrate-lifecycle passes full -race too); golangci-lint 0; gofmt + fmt --diff clean. Assisted-by: Claude (analysed on a live system) Claude-Session: https://claude.ai/code/session_01LnxJjgvxzR2WePdDhAp7Wb
/#72/#74) Evaluator-generated CalVer stamp for the gate-infrastructure batch cutover (vm-destroy false-success #69, makepkg sibling-branch fetch #72, unstamped-binary bed-runner guard #74). Renames the placeholder CHANGELOG to CHANGELOG/2026.195.0802.md and stamps its H1 to match; folded into the squash-merge. Assisted-by: Claude (fully tested and validated)
…ch fetch (#72), unstamped-binary bed-runner guard (#74) Gate-infrastructure thematic batch — three independently-non-blocking bed/gate reliability fixes, one squash. #69 — `charly vm destroy` backend-mismatch false-success + `bundle del` domain-teardown owner. `destroyVmDomain` probes libvirt authoritatively (regardless of the configured/default backend), tears the domain down from whichever backend holds it, VERIFIES it is gone, and hard-errors "no such VM" when nothing was torn; `vmPostTeardown` fires `vm destroy <entity> --domain <domain> --keep-deploy` as `bundle del`'s domain-teardown owner. + regression tests. #72 — makepkg update-phase fetch scoping. The arch localpkg `build_template`'s `makepkg -sf` now sets `GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=fetch.recurseSubmodules GIT_CONFIG_VALUE_0=false`, so a worktree-shared superproject fetch no longer on-demand-recurses into a sibling branch's unpushed sdk gitlink ("not our ref"). Applied to BOTH `//go:embed` copies (R3); deb/rpm unaffected (no makepkg/git+file://). #74 — bed-runner precondition. `CheckBinaryStamped` refuses `charly check run` on an unstamped ("unknown") binary, pointing at `task build:binary`; scoped to `run` via `commandPathKey` + os.Args; `charly version` also exits non-zero when unstamped. + unit tests. Found + registered while landing: #76 (word-keyed plugin cache races across worktrees) → next bed-infra batch. Validated by a fresh, independent pr-validator: golangci-lint 0 (charly / plugin-vm / plugin-deploy-vm), gofmt/vet/build/targeted-test clean; R10 beds corroborated (check-builder-vm 9/9 ok, check-local-vm 7/7 ok with the makepkg update phase ok:true under the live 4-sibling-gitlink state); placement CORRECT. Assisted-by: Claude (fully tested and validated)
Fix a data race in the F10 reverse-channel
InvokeWithExecutorA pre-existing concurrency bug I surfaced running the full suite under
-race(its own immediate cutover per R2).grpcProvider.InvokeWithExecutorstands up the host'sExecutorServiceon the go-plugin broker for the duration of a deploy/step/check Invoke, so an out-of-process plugin can dial back to run shell/SSH ops on the host's real venue.The race
The reverse gRPC server was held in a plain
var srv *grpc.Server: theAcceptAndServecallback (running on the broker-accept goroutine) WROTE it, while the deferredStop()(running on theInvokeWithExecutorgoroutine, after Invoke returns) READ it — an unsynchronized cross-goroutine handoff.-raceflags it (WRITEplugin_grpc.go:170vs READ:187), exercised by the substrate-lifecycle e2e reverse-channel round-trip.Root-cause fix
srvbecomes anatomic.Pointer[grpc.Server]: the callbackStores the server it built, the deferredLoadreads it (or nil — if the plugin never dialed back, the callback never ran, so nothing to stop). A real happens-before edge — not a serialize-to-hide and not a-racesuppression. Reverse-channel behaviour is otherwise unchanged (+16/−7 in one file).Verification (against current main, incl. P8b #70 merged)
go test -run TestSubstrateLifecycle_PrepareVenueDescriptorRoundTrip -race -count=10— 0 data-race reports (was a hard DATA RACE failing the test under-race).go test ./charly/...green (no regression); build clean;golangci-lint0 issues;gofmtclean.Flagged separately (NOT dragged into this cutover)
The full
-racerun surfaced TWO more, unrelated pre-existing races inTestRunWithPhaseResync_*(check_runner_cmd.go:403/408vscheck_phase_resync_test.go:118, check-runner subsystem) — routed to their owner. Also:-count>1on provider-registering e2e tests hits a broad "provider already registered" test-isolation limitation (no unregister API) — a separate concern. Neither is this cutover's scope.Assisted-by: Claude (analysed on a live system)