feat(ruby): M4 — validation hardening, strict unions, RBS sigs, thread soak - #2851
Draft
filip-michalsky wants to merge 1 commit into
Draft
feat(ruby): M4 — validation hardening, strict unions, RBS sigs, thread soak#2851filip-michalsky wants to merge 1 commit into
filip-michalsky wants to merge 1 commit into
Conversation
|
…k (M4)
- wire: closed protocol unions decode strictly (WireError when no variant
matches); the generator now marks unions that had scalar/null variants as
open so nullable/scalar cases keep passing through; structural mismatches
(object/array where the other was expected) raise, JSON null passes
- validation.rb: port of Python _validation.py — screenshot cross-field
rules (fullPage+clip, quality only for jpeg), OTLP trace endpoint must end
with /v1/traces, cache config (true/false/{threshold:}), create-config
scalar constraints (non-empty strings, booleans, positive integers,
string maps)
- client: create() gains telemetry: and cache: (parity with Python's
create signature); per-call cache options validated too
- sig/stagehand.rbs: public API signatures, validated by `rake rbs`
(in the default rake task); shipped in the gem
- test/test_thread_soak.rb: concurrent senders vs out-of-order responses vs
inbound llm.generate (with nested RPC calls from the handler) vs
notifications, plus close-under-fire; SOAK=n scales the load (verified at
SOAK=100: ~22k requests in 0.4s, no losses)
- 120 runs / 803 assertions; live-checked context_and_response.rb and
custom_llm.rb on local Chrome after the strict-union change
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Aug 29, 2026
filip-michalsky
changed the base branch from
filipmichalsky/ap-2857-spike-effort-scoping-for-ruby-in-stagehand-v4
to
filipmichalsky/ruby-sdk-m3
August 29, 2026 21:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the AP-2857 parity stack:
Stack: #2820 (spike) ← #2854 (M1–M2) ← #2855 (M3) ← this PR (M4)
Validation hardening
WireErrorwhen no variant matches); the generator marks unions that had scalar/null variants as open, so nullable/scalar cases keep passing through; structural mismatches (object/array where the other was expected) raise, JSON null passes everywherevalidation.rb(port of Python_validation.py): screenshot cross-field rules (fullPage+clip,qualityonly for jpeg), OTLP trace endpoint must end with/v1/traces, cache config (true/false/{threshold:}), create-config scalar constraintsStagehand.creategainstelemetry:andcache:for signature parity with Python; per-call cache options validated tooRBS signatures
sig/stagehand.rbstypes the public API surface; validated byrake rbs(part of the default rake task) and shipped in the gem. Generated wire models stayuntypeddeliberately (their shape is owned by the protocol JSON).Thread soak
llm.generate(handlers making nested RPC calls) × notifications, plus close-under-fireSOAK=nscales the load; verified at SOAK=100 (~22k requests in 0.4 s, zero lost responses/replies/notifications, linear scaling)Verification
sig/)context_and_response.rbfor nullable navigation unions,custom_llm.rbfor the now-strict LLM unions)Remaining in the roadmap (future PRs on this stack)
webmcp.rbcanonical example (needs a WebMCP-enabled target page)🤖 Generated with Claude Code