Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(storage): preserve lease regression without seed files

Steven Enamakelf607c8817047
diff --git a/.gitignore b/.gitignore
index 6595c3ad0b..e06ee82bba 100644
--- a/.gitignore
+++ b/.gitignore
@@ -156,3 +156,5 @@ diff-coverage.md
ci-out/
ci-out-ex63/
+# Proptest failures are promoted to named unit tests.
+proptest-regressions/
diff --git a/crates/openhuman-core/proptest-regressions/storage/lease_model_tests.txt b/crates/openhuman-core/proptest-regressions/storage/lease_model_tests.txt
deleted file mode 100644
index f40e0e21ec..0000000000
--- a/crates/openhuman-core/proptest-regressions/storage/lease_model_tests.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-# Seeds for failure cases proptest has generated in the past. It is
-# automatically read and these particular cases re-run before any
-# novel cases are generated.
-#
-# It is recommended to check this file in to source control so that
-# everyone who runs the test benefits from these saved cases.
-cc 0a42ad3732baaf6285f7bd8e5793b4a4181e09b7b0684d572d5536026ae7aa43 # shrinks to (nodes, steps) = (2, [Acquire(0), Advance(1000), Acquire(0)])
diff --git a/crates/openhuman-core/src/core/runtime/tenant_proptest_tests.rs b/crates/openhuman-core/src/core/runtime/tenant_proptest_tests.rs
index 9d9b4dca31..1ba4b64ccb 100644
--- a/crates/openhuman-core/src/core/runtime/tenant_proptest_tests.rs
+++ b/crates/openhuman-core/src/core/runtime/tenant_proptest_tests.rs
@@ -45,6 +45,11 @@ fn normalized(t: &Tenant) -> Tenant {
}
proptest! {
+ #![proptest_config(ProptestConfig {
+ failure_persistence: None,
+ ..ProptestConfig::default()
+ })]
+
#[test]
fn tenant_key_is_injective(a in tenant(), x in part(), b in tenant(), y in part()) {
let same = tenant_key(&a, &x) == tenant_key(&b, &y);
diff --git a/crates/openhuman-core/src/profiles/gateway_proptest_tests.rs b/crates/openhuman-core/src/profiles/gateway_proptest_tests.rs
index 35c19568ce..3dd62779be 100644
--- a/crates/openhuman-core/src/profiles/gateway_proptest_tests.rs
+++ b/crates/openhuman-core/src/profiles/gateway_proptest_tests.rs
@@ -170,6 +170,11 @@ fn is_valid_for(user: &str, header: &str) -> bool {
}
proptest! {
+ #![proptest_config(ProptestConfig {
+ failure_persistence: None,
+ ..ProptestConfig::default()
+ })]
+
/// `verify` never panics, and accepts a header only when its `v1` is the
/// full HMAC of `<t>.<user>` for a `t` inside the window.
#[test]
diff --git a/crates/openhuman-core/src/profiles/surface_proptest_tests.rs b/crates/openhuman-core/src/profiles/surface_proptest_tests.rs
index c3f09d133d..cd03b36786 100644
--- a/crates/openhuman-core/src/profiles/surface_proptest_tests.rs
+++ b/crates/openhuman-core/src/profiles/surface_proptest_tests.rs
@@ -99,6 +99,11 @@ fn scope() -> impl Strategy<Value = Scope> {
}
proptest! {
+ #![proptest_config(ProptestConfig {
+ failure_persistence: None,
+ ..ProptestConfig::default()
+ })]
+
/// With the operator-plane tag the registry would give the name, a user
/// scope admits exactly `USER_METHODS`, the operator scope exactly the
/// operator plane, and a missing scope nothing.
@@ -195,6 +200,11 @@ fn in_documented_charset(id: &str) -> bool {
}
proptest! {
+ #![proptest_config(ProptestConfig {
+ failure_persistence: None,
+ ..ProptestConfig::default()
+ })]
+
/// A user may mint exactly the documented charset; anything accepted
/// carries no reserved prefix in any case and no colon of any script.
#[test]
diff --git a/crates/openhuman-core/src/profiles/types_proptest_tests.rs b/crates/openhuman-core/src/profiles/types_proptest_tests.rs
index b0fda71217..e0ebf7fe3a 100644
--- a/crates/openhuman-core/src/profiles/types_proptest_tests.rs
+++ b/crates/openhuman-core/src/profiles/types_proptest_tests.rs
@@ -97,6 +97,11 @@ fn is_one_segment_under(users: &std::path::Path, dir: &std::path::Path, id: &str
}
proptest! {
+ #![proptest_config(ProptestConfig {
+ failure_persistence: None,
+ ..ProptestConfig::default()
+ })]
+
/// `for_user` refuses exactly the documented inputs and otherwise yields an
/// id in the charset, with no separator, that parses back to itself.
#[test]
@@ -190,6 +195,7 @@ proptest! {
proptest! {
#![proptest_config(ProptestConfig {
+ failure_persistence: None,
// Each case touches the filesystem.
cases: ProptestConfig::default().cases.min(256),
..ProptestConfig::default()
diff --git a/crates/openhuman-core/src/security/policy/proptest_tests.rs b/crates/openhuman-core/src/security/policy/proptest_tests.rs
index 2f4725d627..096aac4fb1 100644
--- a/crates/openhuman-core/src/security/policy/proptest_tests.rs
+++ b/crates/openhuman-core/src/security/policy/proptest_tests.rs
@@ -9,6 +9,11 @@ use super::types::{CommandClass, SecurityPolicy};
use proptest::prelude::*;
proptest! {
+ #![proptest_config(ProptestConfig {
+ failure_persistence: None,
+ ..ProptestConfig::default()
+ })]
+
/// The classifier + allowlist must never panic, regardless of shell
/// metacharacters, redirects, pipes, or embedded control characters.
#[test]
diff --git a/crates/openhuman-core/src/storage/lease_model_tests.rs b/crates/openhuman-core/src/storage/lease_model_tests.rs
index 490d652ca3..bf44501b64 100644
--- a/crates/openhuman-core/src/storage/lease_model_tests.rs
+++ b/crates/openhuman-core/src/storage/lease_model_tests.rs
@@ -319,8 +319,19 @@ fn scenario() -> impl Strategy<Value = (usize, Vec<Op>)> {
(2usize..=4).prop_flat_map(|nodes| (Just(nodes), prop::collection::vec(ops(nodes), 1..80)))
}
+#[tokio::test]
+async fn reacquiring_at_expiry_advances_epoch_and_marks_previous_holder_unclean() {
+ run(2, vec![Op::Acquire(0), Op::Advance(1_000), Op::Acquire(0)])
+ .await
+ .unwrap();
+}
+
proptest! {
- #![proptest_config(ProptestConfig::with_cases(256))]
+ #![proptest_config(ProptestConfig {
+ cases: 256,
+ failure_persistence: None,
+ ..ProptestConfig::default()
+ })]
#[test]
fn leases_match_the_model_and_never_double_grant((nodes, steps) in scenario()) {
diff --git a/gitbooks/developing/testing-strategy.md b/gitbooks/developing/testing-strategy.md
index 42b82b9abf..bf4fc31501 100644
--- a/gitbooks/developing/testing-strategy.md
+++ b/gitbooks/developing/testing-strategy.md
@@ -53,6 +53,14 @@ A spec that asserts only the happy path is incomplete.
---
+## Property-test regressions
+
+Core proptests set `failure_persistence: None` in their `ProptestConfig`; they do not write seed files. When a property fails, keep the seed from the failure output to reproduce it, then promote the shrunk input to a named unit test beside the property test. Confirm that the explicit case fails against the faulty implementation and passes with the fix before shipping it.
+
+For example, the lease model retains the expired-holder reacquisition case as `reacquiring_at_expiry_advances_epoch_and_marks_previous_holder_unclean`, with two nodes and the steps `Acquire(0), Advance(1000), Acquire(0)`.
+
+---
+
## Mock policy
- Use no real network in unit, integration or E2E tests. Use the shared mock backend (`scripts/mock-api-core.mjs`, `scripts/mock-api-server.mjs`, `app/test/e2e/mock-server.ts`).