rogue_machines 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/Cargo.lock +3 -2
- data/ext/rogue_machines_native/core/Cargo.toml +2 -2
- data/ext/rogue_machines_native/ffi/Cargo.toml +13 -1
- data/ext/rogue_machines_native/ffi/src/lib.rs +36 -38
- data/ext/rogue_machines_native/ffi/src/registry.rs +8 -13
- data/lib/rogue_machines/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c2fd4172fc4b5d0916de7b314c5fb63734eaca6322081e9a765dcdf603f5f3c2
|
|
4
|
+
data.tar.gz: '063865c73fa28cde9bf8dde2431a01b51cb216a08f928447b462849700272e7d'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b60b14e47a1babc34a59493f52e2c68622360a6b51723c23fcb6a30257bbc4da24c983f8b169f05dd2cc14d9c6dedff8b026c78dde8ce11e59d8060f6150a0c
|
|
7
|
+
data.tar.gz: 676a7fd1e0d8917f7d7d09c61ef2676693b8415ba9dfc90d91458796919f9d63a7bc14b54e69d08a0e15aa87353a8ea595b61785e8ba5bab93602e413f9df5e3
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.3](https://github.com/seuros/rogue_machines/compare/rogue_machines/v0.1.2...rogue_machines/v0.1.3) (2026-11-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* extract arg_error and range error helpers in ffi ([ee6ccf4](https://github.com/seuros/rogue_machines/commit/ee6ccf4ef0caef9f5ef7b4496ee0ccdb633ddc1e))
|
|
9
|
+
* keep test modules out of the packaged crate ([425cf81](https://github.com/seuros/rogue_machines/commit/425cf81b4e94ea2abd8de21ec74426c71338c11c))
|
|
10
|
+
|
|
11
|
+
## [0.1.2](https://github.com/seuros/rogue_machines/compare/rogue_machines/v0.1.1...rogue_machines/v0.1.2) (2026-11-01)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* a republished platform gem is skipped, not fatal ([1190768](https://github.com/seuros/rogue_machines/commit/119076835e9e41d77fee67e40e0cc1646a8f9354))
|
|
17
|
+
* enable the rb-sys compiled fallback so new Rubies can build ([c36ad72](https://github.com/seuros/rogue_machines/commit/c36ad72c622ee5c3b526776351968e18df83c722))
|
|
18
|
+
|
|
3
19
|
## [0.1.1](https://github.com/seuros/rogue_machines/compare/rogue_machines-v0.1.0...rogue_machines/v0.1.1) (2026-11-01)
|
|
4
20
|
|
|
5
21
|
|
data/Cargo.lock
CHANGED
|
@@ -228,13 +228,14 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
|
|
228
228
|
|
|
229
229
|
[[package]]
|
|
230
230
|
name = "rogue-machines"
|
|
231
|
-
version = "0.2.
|
|
231
|
+
version = "0.2.1"
|
|
232
232
|
|
|
233
233
|
[[package]]
|
|
234
234
|
name = "rogue_machines_native"
|
|
235
|
-
version = "0.1.
|
|
235
|
+
version = "0.1.2"
|
|
236
236
|
dependencies = [
|
|
237
237
|
"magnus",
|
|
238
|
+
"rb-sys",
|
|
238
239
|
"rogue-machines",
|
|
239
240
|
]
|
|
240
241
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "rogue-machines"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.1"
|
|
4
4
|
edition.workspace = true
|
|
5
5
|
rust-version.workspace = true
|
|
6
6
|
authors = ["Abdelkader Boudih <oss@seuros.com>"]
|
|
@@ -10,7 +10,7 @@ repository = "https://github.com/seuros/rogue_machines"
|
|
|
10
10
|
keywords = ["fault-injection", "chaos-engineering", "resilience", "testing", "no-std"]
|
|
11
11
|
categories = ["no-std", "development-tools::testing"]
|
|
12
12
|
readme = "README.md"
|
|
13
|
-
|
|
13
|
+
exclude = ["src/**/tests.rs", "tests/"]
|
|
14
14
|
[lib]
|
|
15
15
|
name = "rogue_machines"
|
|
16
16
|
crate-type = ["lib"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "rogue_machines_native"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.2"
|
|
4
4
|
edition.workspace = true
|
|
5
5
|
rust-version.workspace = true
|
|
6
6
|
authors = ["Abdelkader Boudih <oss@seuros.com>"]
|
|
@@ -17,3 +17,15 @@ workspace = true
|
|
|
17
17
|
[dependencies]
|
|
18
18
|
rogue-machines = { workspace = true, features = ["std"] }
|
|
19
19
|
magnus = { version = ">= 0.9.3", default-features = false, features = ["io"] }
|
|
20
|
+
# Nothing here calls rb-sys directly: this is the compiled fallback that
|
|
21
|
+
# implements the stable API for a Ruby rb-sys has no pre-generated bindings
|
|
22
|
+
# for, such as a preview. magnus asks for "stable-api" without it, and
|
|
23
|
+
# default-features = false drops the default that would have supplied it, so
|
|
24
|
+
# removing this line breaks the build on every future Ruby.
|
|
25
|
+
# Nothing here calls rb-sys directly: this is the compiled fallback that
|
|
26
|
+
# implements the stable API for a Ruby rb-sys ships no pre-generated bindings
|
|
27
|
+
# for, such as a preview. magnus asks for "stable-api" without it, and its
|
|
28
|
+
# default-features = false drops the default that would have supplied it, so
|
|
29
|
+
# dropping this line breaks the build on every Ruby newer than rb-sys.
|
|
30
|
+
rb-sys = { version = ">= 0.9.130", default-features = false, features = ["stable-api-compiled-fallback"] }
|
|
31
|
+
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
mod injection;
|
|
11
11
|
mod registry;
|
|
12
12
|
|
|
13
|
+
use std::borrow::Cow;
|
|
14
|
+
use std::fmt::Display;
|
|
13
15
|
use std::sync::OnceLock;
|
|
14
16
|
|
|
15
17
|
use magnus::value::Opaque;
|
|
@@ -38,15 +40,15 @@ pub(crate) const LONGEST_DELAY: f64 = 5.0 * 60.0;
|
|
|
38
40
|
#[expect(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
|
|
39
41
|
pub(crate) fn duration(ruby: &Ruby, name: &str, seconds: f64, longest: f64) -> Result<u64, Error> {
|
|
40
42
|
if !seconds.is_finite() || seconds <= 0.0 || seconds > longest {
|
|
41
|
-
return Err(
|
|
42
|
-
ruby
|
|
43
|
+
return Err(arg_error(
|
|
44
|
+
ruby,
|
|
43
45
|
format!("{name} must be above 0 and at most {longest} seconds, got {seconds}"),
|
|
44
46
|
));
|
|
45
47
|
}
|
|
46
48
|
let nanoseconds = seconds * f64::from(NS_PER_SECOND);
|
|
47
49
|
if nanoseconds < 1.0 {
|
|
48
|
-
return Err(
|
|
49
|
-
ruby
|
|
50
|
+
return Err(arg_error(
|
|
51
|
+
ruby,
|
|
50
52
|
format!("{name} of {seconds} is below the one nanosecond resolution"),
|
|
51
53
|
));
|
|
52
54
|
}
|
|
@@ -59,15 +61,9 @@ pub(crate) fn duration(ruby: &Ruby, name: &str, seconds: f64, longest: f64) -> R
|
|
|
59
61
|
/// range: magnus would reject that with its own `RangeError`, which would
|
|
60
62
|
/// leak out of a protected call site as something the gem never documents.
|
|
61
63
|
pub(crate) fn reading(ruby: &Ruby, name: &str, value: Value) -> Result<u64, Error> {
|
|
62
|
-
whole(ruby, name, value)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
format!(
|
|
66
|
-
"{name} must be a non-negative Integer of at most {}",
|
|
67
|
-
u64::MAX
|
|
68
|
-
),
|
|
69
|
-
)
|
|
70
|
-
})
|
|
64
|
+
whole(ruby, name, value)?
|
|
65
|
+
.to_u64()
|
|
66
|
+
.map_err(|_| above(ruby, name, u64::MAX))
|
|
71
67
|
}
|
|
72
68
|
|
|
73
69
|
/// A draw below [`PER_MILLION`].
|
|
@@ -76,14 +72,14 @@ pub(crate) fn reading(ruby: &Ruby, name: &str, value: Value) -> Result<u64, Erro
|
|
|
76
72
|
/// `rand` returns a Float would inject on every call instead of none.
|
|
77
73
|
pub(crate) fn draw(ruby: &Ruby, value: Value) -> Result<u32, Error> {
|
|
78
74
|
let drawn = whole(ruby, "draw", value)?.to_u32().map_err(|_| {
|
|
79
|
-
|
|
80
|
-
ruby
|
|
75
|
+
arg_error(
|
|
76
|
+
ruby,
|
|
81
77
|
format!("draw must be a non-negative Integer below {PER_MILLION}"),
|
|
82
78
|
)
|
|
83
79
|
})?;
|
|
84
80
|
if drawn >= PER_MILLION {
|
|
85
|
-
return Err(
|
|
86
|
-
ruby
|
|
81
|
+
return Err(arg_error(
|
|
82
|
+
ruby,
|
|
87
83
|
format!("draw must be below {PER_MILLION}, got {drawn}"),
|
|
88
84
|
));
|
|
89
85
|
}
|
|
@@ -92,51 +88,53 @@ pub(crate) fn draw(ruby: &Ruby, value: Value) -> Result<u32, Error> {
|
|
|
92
88
|
|
|
93
89
|
/// A generation tag.
|
|
94
90
|
pub(crate) fn counted(ruby: &Ruby, name: &str, value: Value) -> Result<u32, Error> {
|
|
95
|
-
whole(ruby, name, value)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
91
|
+
whole(ruby, name, value)?
|
|
92
|
+
.to_u32()
|
|
93
|
+
.map_err(|_| above(ruby, name, u32::MAX))
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/// Refuses an Integer that is negative or larger than `max`.
|
|
97
|
+
fn above(ruby: &Ruby, name: &str, max: impl Display) -> Error {
|
|
98
|
+
arg_error(
|
|
99
|
+
ruby,
|
|
100
|
+
format!("{name} must be a non-negative Integer of at most {max}"),
|
|
101
|
+
)
|
|
104
102
|
}
|
|
105
103
|
|
|
106
104
|
fn whole(ruby: &Ruby, name: &str, value: Value) -> Result<Integer, Error> {
|
|
107
|
-
Integer::from_value(value).ok_or_else(|| {
|
|
108
|
-
Error::new(
|
|
109
|
-
ruby.exception_arg_error(),
|
|
110
|
-
format!("{name} must be an Integer"),
|
|
111
|
-
)
|
|
112
|
-
})
|
|
105
|
+
Integer::from_value(value).ok_or_else(|| arg_error(ruby, format!("{name} must be an Integer")))
|
|
113
106
|
}
|
|
114
107
|
|
|
115
108
|
/// A share of calls, rejecting one outside a whole or too small to express.
|
|
116
109
|
#[expect(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
|
|
117
110
|
pub(crate) fn share(ruby: &Ruby, given: f64) -> Result<Fraction, Error> {
|
|
118
111
|
if !given.is_finite() || !(0.0..=1.0).contains(&given) {
|
|
119
|
-
return Err(
|
|
120
|
-
ruby
|
|
112
|
+
return Err(arg_error(
|
|
113
|
+
ruby,
|
|
121
114
|
format!("share must be between 0 and 1, got {given}"),
|
|
122
115
|
));
|
|
123
116
|
}
|
|
124
117
|
let millionths = given * f64::from(PER_MILLION);
|
|
125
118
|
if given > 0.0 && millionths < 1.0 {
|
|
126
|
-
return Err(
|
|
127
|
-
ruby
|
|
119
|
+
return Err(arg_error(
|
|
120
|
+
ruby,
|
|
128
121
|
format!("share of {given} is below the one millionth resolution"),
|
|
129
122
|
));
|
|
130
123
|
}
|
|
131
124
|
let millionths = millionths.round() as u32;
|
|
132
125
|
Fraction::new(millionths).ok_or_else(|| {
|
|
133
|
-
|
|
134
|
-
ruby
|
|
126
|
+
arg_error(
|
|
127
|
+
ruby,
|
|
135
128
|
format!("share of {millionths} millionths is not a whole"),
|
|
136
129
|
)
|
|
137
130
|
})
|
|
138
131
|
}
|
|
139
132
|
|
|
133
|
+
/// An `ArgumentError` carrying `message`.
|
|
134
|
+
pub(crate) fn arg_error(ruby: &Ruby, message: impl Into<Cow<'static, str>>) -> Error {
|
|
135
|
+
Error::new(ruby.exception_arg_error(), message)
|
|
136
|
+
}
|
|
137
|
+
|
|
140
138
|
pub(crate) fn error(ruby: &Ruby, message: String) -> Error {
|
|
141
139
|
ERROR.get().map_or_else(
|
|
142
140
|
|| {
|
|
@@ -8,7 +8,9 @@ use magnus::{Error, RArray, RHash, RModule, Ruby, Value, function, method, prelu
|
|
|
8
8
|
use rogue_machines::{Decision, EXPERIMENTS, Experiment, Fault, Rogue, Slot};
|
|
9
9
|
|
|
10
10
|
use crate::injection::injection;
|
|
11
|
-
use crate::{
|
|
11
|
+
use crate::{
|
|
12
|
+
LONGEST_DELAY, LONGEST_EXPERIMENT, arg_error, counted, draw, duration, error, reading, share,
|
|
13
|
+
};
|
|
12
14
|
|
|
13
15
|
/// The core registry, and the names standing in for its slot indices.
|
|
14
16
|
#[magnus::wrap(class = "RogueMachines::Rogue", free_immediately, size)]
|
|
@@ -105,10 +107,7 @@ impl Wrapper {
|
|
|
105
107
|
LONGEST_EXPERIMENT,
|
|
106
108
|
)?)
|
|
107
109
|
.ok_or_else(|| {
|
|
108
|
-
|
|
109
|
-
ruby.exception_arg_error(),
|
|
110
|
-
"expires_in puts the expiry past the end of the clock",
|
|
111
|
-
)
|
|
110
|
+
arg_error(ruby, "expires_in puts the expiry past the end of the clock")
|
|
112
111
|
})?;
|
|
113
112
|
let fraction = share(ruby, given_share)?;
|
|
114
113
|
let fault = fault(ruby, &named, delay)?;
|
|
@@ -254,18 +253,14 @@ fn fault(ruby: &Ruby, named: &str, delay: Option<f64>) -> Result<Fault, Error> {
|
|
|
254
253
|
"raise" => Ok(Fault::Raise),
|
|
255
254
|
"garble" => Ok(Fault::Garble),
|
|
256
255
|
"delay" => {
|
|
257
|
-
let seconds =
|
|
258
|
-
|
|
259
|
-
ruby.exception_arg_error(),
|
|
260
|
-
"a :delay fault needs delay: in seconds",
|
|
261
|
-
)
|
|
262
|
-
})?;
|
|
256
|
+
let seconds =
|
|
257
|
+
delay.ok_or_else(|| arg_error(ruby, "a :delay fault needs delay: in seconds"))?;
|
|
263
258
|
Ok(Fault::Delay {
|
|
264
259
|
ns: duration(ruby, "delay", seconds, LONGEST_DELAY)?,
|
|
265
260
|
})
|
|
266
261
|
}
|
|
267
|
-
other => Err(
|
|
268
|
-
ruby
|
|
262
|
+
other => Err(arg_error(
|
|
263
|
+
ruby,
|
|
269
264
|
format!("fault must be :raise, :delay or :garble, got {other:?}"),
|
|
270
265
|
)),
|
|
271
266
|
}
|