Skip to content

Harden provider startup handshake protocol#30

Merged
writeameer merged 5 commits into
mainfrom
harden-handshake-protocol
Apr 5, 2026
Merged

Harden provider startup handshake protocol#30
writeameer merged 5 commits into
mainfrom
harden-handshake-protocol

Conversation

@writeameer
Copy link
Copy Markdown
Contributor

Summary

  • Process-exit detection: waitForReady now races 3 signals (modeled after Terraform's go-plugin): first stdout line, process exit, and timeout. Previously a crashed provider would block for the full 30s timeout.
  • Stderr capture: Provider stderr is captured via io.MultiWriter during startup and included in error messages, so crash diagnostics are immediately visible.
  • 10 unit tests covering handshake and post-handshake failure scenarios
  • CI workflow added to run tests on push/PR to main
  • Removed accidentally committed dstream binary artifact

Test cases

Test Scenario
ProviderSendsReady Happy path — provider emits {"status":"ready"}
ProviderSendsError Validation failure — provider emits error signal
ProviderCrashes Process exits before handshake — detected instantly, not after 30s
ProviderHangs_TimesOut No response — times out at configured duration
LegacyProvider No handshake — backward compatible, first line treated as data
CrashWithStderrContext Crash with stderr — last 10 lines included in error
ProviderCrashMidStream Provider dies during data flow — broken pipe detected
ProviderEchoRelay Data relay works correctly after handshake
GracefulShutdownOnStdinClose Provider exits cleanly when stdin closes
ProviderStderrDuringNormalOperation Stderr logging doesn't interfere with data

Closes #24, closes #25, closes #26

Test plan

  • All 10 tests pass locally
  • CI workflow runs on this PR and passes

🤖 Generated with Claude Code

writeameer and others added 5 commits April 5, 2026 18:41
…capture, and tests

- waitForReady now races 3 signals (like Terraform go-plugin): stdout line, process exit, timeout
- Stderr captured via io.MultiWriter and included in error messages for diagnostics
- Remove committed binary artifact (dstream)
- Add CI workflow for unit tests
- 10 tests covering: ready, error, crash, timeout, legacy, stderr context,
  mid-stream crash, data relay, graceful shutdown, stderr during operation

Closes #24, closes #25, closes #26

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@writeameer writeameer merged commit 6d6cdfc into main Apr 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add failure scenario and edge case tests Add tests for provider startup handshake Review and harden provider startup handshake protocol

1 participant