-
Notifications
You must be signed in to change notification settings - Fork 0
feat(core): fail closed on browser runtime revision drift #110
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 10 commits into
feat/originweave-protocol-version-binding
from
feat/browser-protocol-runtime-revision-check
Aug 26, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
66f6ad7
test(core): require exact runtime browser revisions
seonghobae 03f7b18
style(core): apply canonical runtime revision test formatting
seonghobae e7c3e3e
feat(core): validate browser runtime revisions
seonghobae 4b1ce55
feat(core): export browser runtime revision error
seonghobae f0fc8f9
style(core): apply canonical runtime revision formatting
seonghobae 04c4759
merge: align runtime revision checks with current protocol parser
seonghobae d5c7bd5
merge: align runtime revision checks with current protocol parser
seonghobae 8f1c022
chore(core): align runtime revision checks with current protocol parser
seonghobae e183163
chore(core): align runtime revision checks with current protocol parser
seonghobae 415b886
docs: record runtime revision boundary
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
96 changes: 96 additions & 0 deletions
96
crates/originweave-core/tests/browser_protocol_runtime_revision.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,96 @@ | ||
| use std::error::Error; | ||
|
|
||
| use originweave_core::{ | ||
| BrowserProtocolAdapterDescriptor, BrowserProtocolCapability, BrowserProtocolKind, | ||
| BrowserProtocolRuntimeRequirementError, 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], | ||
| )?) | ||
| } | ||
|
|
||
| #[test] | ||
| fn exact_runtime_revisions_are_required_before_adapter_use() -> Result<(), Box<dyn Error>> { | ||
| let descriptor = descriptor()?; | ||
| assert_eq!( | ||
| descriptor.require_runtime_revisions(PROTOCOL_REVISION, BROWSER_REVISION), | ||
| Ok(()) | ||
| ); | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn runtime_revision_drift_fails_closed() -> Result<(), Box<dyn Error>> { | ||
| let descriptor = descriptor()?; | ||
| assert_eq!( | ||
| descriptor.require_runtime_revisions("webdriver-bidi-wd-2026-07-01", BROWSER_REVISION), | ||
| Err(BrowserProtocolRuntimeRequirementError::ProtocolRevisionMismatch) | ||
| ); | ||
| assert_eq!( | ||
| descriptor.require_runtime_revisions(PROTOCOL_REVISION, "chromium-r1639811"), | ||
| Err(BrowserProtocolRuntimeRequirementError::BrowserRevisionMismatch) | ||
| ); | ||
| assert_eq!( | ||
| descriptor.require_runtime_revisions("webdriver-bidi-wd-2026-07-01", "chromium-r1639811"), | ||
| Err(BrowserProtocolRuntimeRequirementError::ProtocolRevisionMismatch) | ||
| ); | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn malformed_runtime_revision_evidence_fails_before_comparison() -> Result<(), Box<dyn Error>> { | ||
| let descriptor = descriptor()?; | ||
| assert_eq!( | ||
| descriptor.require_runtime_revisions("webdriver bidi current", BROWSER_REVISION), | ||
| Err(BrowserProtocolRuntimeRequirementError::InvalidProtocolRevision) | ||
| ); | ||
| assert_eq!( | ||
| descriptor.require_runtime_revisions(PROTOCOL_REVISION, "chromium/current"), | ||
| Err(BrowserProtocolRuntimeRequirementError::InvalidBrowserRevision) | ||
| ); | ||
| assert_eq!( | ||
| descriptor.require_runtime_revisions("", ""), | ||
| Err(BrowserProtocolRuntimeRequirementError::InvalidProtocolRevision) | ||
| ); | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn runtime_requirement_errors_are_stable_and_source_free() { | ||
| let cases = [ | ||
| ( | ||
| BrowserProtocolRuntimeRequirementError::InvalidProtocolRevision, | ||
| "runtime browser protocol revision must be a bounded ASCII metadata token", | ||
| ), | ||
| ( | ||
| BrowserProtocolRuntimeRequirementError::InvalidBrowserRevision, | ||
| "runtime browser revision must be a bounded ASCII metadata token", | ||
| ), | ||
| ( | ||
| BrowserProtocolRuntimeRequirementError::ProtocolRevisionMismatch, | ||
| "runtime browser protocol revision does not match the pinned adapter revision", | ||
| ), | ||
| ( | ||
| BrowserProtocolRuntimeRequirementError::BrowserRevisionMismatch, | ||
| "runtime browser revision does not match the pinned adapter browser revision", | ||
| ), | ||
| ]; | ||
|
|
||
| for (error, expected) in cases { | ||
| assert_eq!(error.to_string(), expected); | ||
| assert!(error.source().is_none()); | ||
| } | ||
| } |
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
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.