-
Notifications
You must be signed in to change notification settings - Fork 0
feat(core): validate browser protocol use atomically #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
seonghobae
merged 16 commits into
feat/browser-protocol-capability-requirement
from
feat/browser-protocol-use-validation
Aug 26, 2026
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9f987ae
test(core): require atomic browser protocol use validation
seonghobae e5a5598
style(core): apply canonical browser protocol validation formatting
seonghobae 8d8e9b9
feat(core): validate browser protocol use prerequisites atomically
seonghobae d39cbf5
feat(core): export browser protocol use validation types
seonghobae 72c4c33
test(core): cover browser protocol validation error evidence
seonghobae 6346164
test(core): require runtime browser protocol kind binding
seonghobae de107ca
test(core): bind all validated uses to runtime protocol kind
seonghobae 3294f27
feat(core): bind validated use to runtime protocol kind
seonghobae 9aed5ae
docs(changelog): record browser protocol use validation
seonghobae f42c3c2
merge: align atomic browser protocol validation with current runtime …
seonghobae d4e22cd
merge: align runtime protocol-kind binding with current atomic valida…
seonghobae 2f5bb55
merge: align atomic protocol validation with current runtime prerequi…
seonghobae c2b572f
merge: align runtime-kind binding with current atomic validation
seonghobae 2c9ab91
chore(core): align protocol use validation with current runtime checks
seonghobae d534f72
Merge pull request #112 from ContextualWisdomLab/feat/browser-protoco…
seonghobae 4ca4c71
Merge remote-tracking branch 'origin/feat/originweave-protocol-versio…
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
185 changes: 185 additions & 0 deletions
185
crates/originweave-core/tests/browser_protocol_use_validation.rs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,185 @@ | ||
| use std::error::Error; | ||
|
|
||
| use originweave_core::{ | ||
| BrowserProtocolAdapterDescriptor, BrowserProtocolCapability, | ||
| BrowserProtocolCapabilityRequirementError, BrowserProtocolKind, | ||
| BrowserProtocolRuntimeRequirementError, BrowserProtocolUseValidationError, | ||
| BrowserProtocolVersionRequirementError, OriginWeaveProtocolVersion, | ||
| }; | ||
|
|
||
| const ORIGINWEAVE_PROTOCOL_VERSION: OriginWeaveProtocolVersion = | ||
| OriginWeaveProtocolVersion::new(0, 1); | ||
| const ADAPTER_VERSION: &str = "originweave-bidi-v1"; | ||
| const PROTOCOL_REVISION: &str = "webdriver-bidi-wd-2026-06-01"; | ||
| const BROWSER_REVISION: &str = "chromium-r1639810"; | ||
|
|
||
| fn descriptor() -> Result<BrowserProtocolAdapterDescriptor, Box<dyn Error>> { | ||
| Ok(BrowserProtocolAdapterDescriptor::new( | ||
| BrowserProtocolKind::WebDriverBiDi, | ||
| ORIGINWEAVE_PROTOCOL_VERSION, | ||
| ADAPTER_VERSION, | ||
| PROTOCOL_REVISION, | ||
| BROWSER_REVISION, | ||
| &[ | ||
| BrowserProtocolCapability::Navigation, | ||
| BrowserProtocolCapability::TypedInput, | ||
| ], | ||
| )?) | ||
| } | ||
|
|
||
| #[test] | ||
| fn validated_use_binds_all_required_adapter_metadata() -> Result<(), Box<dyn Error>> { | ||
| let descriptor = descriptor()?; | ||
| let validated = descriptor.validate_use( | ||
| ORIGINWEAVE_PROTOCOL_VERSION, | ||
| BrowserProtocolKind::WebDriverBiDi, | ||
| PROTOCOL_REVISION, | ||
| BROWSER_REVISION, | ||
| BrowserProtocolCapability::Navigation, | ||
| )?; | ||
|
|
||
| assert_eq!(validated.kind(), BrowserProtocolKind::WebDriverBiDi); | ||
| assert_eq!( | ||
| validated.originweave_protocol_version(), | ||
| ORIGINWEAVE_PROTOCOL_VERSION | ||
| ); | ||
| assert_eq!(validated.adapter_version(), ADAPTER_VERSION); | ||
| assert_eq!(validated.protocol_revision(), PROTOCOL_REVISION); | ||
| assert_eq!(validated.browser_revision(), BROWSER_REVISION); | ||
| assert_eq!( | ||
| validated.capability(), | ||
| BrowserProtocolCapability::Navigation | ||
| ); | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn protocol_generation_mismatch_precedes_runtime_and_capability_checks() | ||
| -> Result<(), Box<dyn Error>> { | ||
| let descriptor = descriptor()?; | ||
| let wrong_generation = OriginWeaveProtocolVersion::new(0, 2); | ||
|
|
||
| assert_eq!( | ||
| descriptor.validate_use( | ||
| wrong_generation, | ||
| BrowserProtocolKind::ChromeDevToolsProtocol, | ||
| "runtime revision with spaces", | ||
| "browser/revision", | ||
| BrowserProtocolCapability::NetworkObservation, | ||
| ), | ||
| Err(BrowserProtocolUseValidationError::ProtocolVersion( | ||
| BrowserProtocolVersionRequirementError::ProtocolVersionMismatch { | ||
| required: wrong_generation, | ||
| actual: ORIGINWEAVE_PROTOCOL_VERSION, | ||
| } | ||
| )) | ||
| ); | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn runtime_protocol_kind_mismatch_precedes_revision_and_capability_checks() | ||
| -> Result<(), Box<dyn Error>> { | ||
| let descriptor = descriptor()?; | ||
|
|
||
| let error = descriptor.validate_use( | ||
| ORIGINWEAVE_PROTOCOL_VERSION, | ||
| BrowserProtocolKind::ChromeDevToolsProtocol, | ||
| "runtime revision with spaces", | ||
| "browser/revision", | ||
| BrowserProtocolCapability::NetworkObservation, | ||
| ); | ||
|
|
||
| assert_eq!( | ||
| error, | ||
| Err(BrowserProtocolUseValidationError::ProtocolKindMismatch { | ||
| descriptor_kind: BrowserProtocolKind::WebDriverBiDi, | ||
| runtime_kind: BrowserProtocolKind::ChromeDevToolsProtocol, | ||
| }) | ||
| ); | ||
| let error = error.err().ok_or("expected protocol kind mismatch")?; | ||
| assert_eq!( | ||
| error.to_string(), | ||
| "runtime browser protocol kind does not match the pinned adapter kind" | ||
| ); | ||
| assert!(error.source().is_none()); | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn runtime_revision_validation_precedes_capability_check() -> Result<(), Box<dyn Error>> { | ||
| let descriptor = descriptor()?; | ||
|
|
||
| assert_eq!( | ||
| descriptor.validate_use( | ||
| ORIGINWEAVE_PROTOCOL_VERSION, | ||
| BrowserProtocolKind::WebDriverBiDi, | ||
| "webdriver-bidi-wd-2026-07-01", | ||
| BROWSER_REVISION, | ||
| BrowserProtocolCapability::NetworkObservation, | ||
| ), | ||
| Err(BrowserProtocolUseValidationError::RuntimeRevision( | ||
| BrowserProtocolRuntimeRequirementError::ProtocolRevisionMismatch, | ||
| )) | ||
| ); | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn undeclared_capability_cannot_produce_validated_use() -> Result<(), Box<dyn Error>> { | ||
| let descriptor = descriptor()?; | ||
|
|
||
| assert_eq!( | ||
| descriptor.validate_use( | ||
| ORIGINWEAVE_PROTOCOL_VERSION, | ||
| BrowserProtocolKind::WebDriverBiDi, | ||
| PROTOCOL_REVISION, | ||
| BROWSER_REVISION, | ||
| BrowserProtocolCapability::NetworkObservation, | ||
| ), | ||
| Err(BrowserProtocolUseValidationError::Capability( | ||
| BrowserProtocolCapabilityRequirementError::UnsupportedCapability( | ||
| BrowserProtocolCapability::NetworkObservation, | ||
| ), | ||
| )) | ||
| ); | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn validation_errors_preserve_stable_typed_sources() { | ||
| let wrong_generation = OriginWeaveProtocolVersion::new(0, 2); | ||
| let cases = [ | ||
| ( | ||
| BrowserProtocolUseValidationError::ProtocolVersion( | ||
| BrowserProtocolVersionRequirementError::ProtocolVersionMismatch { | ||
| required: wrong_generation, | ||
| actual: ORIGINWEAVE_PROTOCOL_VERSION, | ||
| }, | ||
| ), | ||
| "browser protocol adapter targets originweave/0.1 but originweave/0.2 is required", | ||
| ), | ||
| ( | ||
| BrowserProtocolUseValidationError::RuntimeRevision( | ||
| BrowserProtocolRuntimeRequirementError::ProtocolRevisionMismatch, | ||
| ), | ||
| "runtime browser protocol revision does not match the pinned adapter revision", | ||
| ), | ||
| ( | ||
| BrowserProtocolUseValidationError::Capability( | ||
| BrowserProtocolCapabilityRequirementError::UnsupportedCapability( | ||
| BrowserProtocolCapability::NetworkObservation, | ||
| ), | ||
| ), | ||
| "browser protocol adapter does not declare required network-observation capability", | ||
| ), | ||
| ]; | ||
|
|
||
| for (error, expected) in cases { | ||
| assert_eq!(error.to_string(), expected); | ||
| assert_eq!( | ||
| error.source().map(ToString::to_string).as_deref(), | ||
| Some(expected) | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.