feat: add extheartbeat shared heartbeat watchdog#150
Conversation
action-kit and preflight-kit each carried an identical copy of a channel-based heartbeat monitor — which recently required the same concurrency fix (idempotent Stop, non-blocking closed-safe RecordHeartbeat) to be applied twice. Extract it here as extheartbeat so both SDKs can share one implementation and it can't diverge again. extension-kit is already a dependency of both SDKs, so this adds no new module coupling.
|
Claude finished @joshiste's task in 2m 20s —— View job Claude finished reviewing this PR
SummaryThis is a clean, faithful port of the already-fixed heartbeat watchdog from Concurrency review of
Other observations (not blocking, not new to this PR):
Verification note: I was not able to execute No blocking issues found — LGTM. |
|
Re: the "blocks forever if a caller never reads from
Also confirmed the Windows build (the CI job is gated to Leaving as-is; if we want to harden the no-reader case it should be a separate, deliberate PR with its own tests. |
Why
action_kit_sdkandpreflight_kit_sdkeach carried a byte-identicalheartbeatpackage (a channel-based watchdog:Monitor+Notify+RecordHeartbeat/Stop). That duplication recently caused the same concurrency bug to be fixed twice — action-kit#457 and preflight-kit#52 both had to makeStopidempotent andRecordHeartbeata non-blocking, closed-safe send. That's the textbook signal to deduplicate.What
Add
extheartbeathere — the (already-fixed) concurrency-safe watchdog — so both SDKs can share one implementation and it can't diverge again.extension-kitis already a dependency of both SDKs, so this adds no new module coupling.The API is unchanged from the copies both SDKs already use:
Notify(ch, interval, timeout) *Monitor,(*Monitor).RecordHeartbeat(),(*Monitor).Stop().Follow-up (after this is tagged)
Two SDK PRs will bump to the new
extension-kit, switch their internals toextheartbeat, and delete their localheartbeatpackages (clean removal — no external consumers). The action-kit PR will also fold in the same re-Start monitor-leak fix that preflight-kit#52 got.Verification
go build,go vet,go test -race ./extheartbeat/pass — includes the concurrency test (concurrent RecordHeartbeat vs repeated Stop) plus the original timeout tests.