The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
docs(storage): document driver-enforced lease fencing
Steven Enamakel0a0573948230
diff --git a/crates/openhuman-core/src/profiles/README.md b/crates/openhuman-core/src/profiles/README.mdindex 9835c6af61..93ff6b3903 100644--- a/crates/openhuman-core/src/profiles/README.md+++ b/crates/openhuman-core/src/profiles/README.md@@ -260,10 +260,13 @@ The lease drives the rest:Known limits:-- The fence check and the write are two operations: a holder paused for- longer than the skew margin right after a passing check can still land one- write after a takeover. Closing that needs a driver-enforced conditional- write (see `storage/README.md`).+- On drivers with `Capability::Fencing` (memory, SQLite, file, MongoDB+ replica sets) the driver re-checks the lease record atomically with each+ write, so a takeover cuts off a paused holder's writes at storage. Where it+ cannot (MongoDB without transactions, MongoDB blobs, named databases) the+ host check and the write are two operations: a holder paused for longer+ than the skew margin right after a passing check can still land one write+ after a takeover (see `storage/README.md`).- Only writes through the storage ports are fenced. Files a profile writesdirectly under `<root>/users/<id>/` (the memory job queue, the classicon-disk stores) are not; on a shared volume, stopping turns and jobs ondiff --git a/crates/openhuman-core/src/storage/README.md b/crates/openhuman-core/src/storage/README.mdindex a0e29700fd..9d53eae661 100644--- a/crates/openhuman-core/src/storage/README.md+++ b/crates/openhuman-core/src/storage/README.md@@ -110,28 +110,41 @@ change. A scope with one runs `LeaseFence::check` first:unreleased and unexpired; a moved record latches the fence, anunreadable one refuses the write without latching.+A write the host check admits then goes to the driver through+`StorageBackend::for_scope_fenced` with `LeaseFence::driver_fence`: the lease+record (`cluster` scope, `leases` collection, id = the profile) must still+match `epoch`, `owner` = this node and `released = false`. The driver checks+it in the same statement or transaction as the write (tinystoragedrivers+v0.5.0, `Capability::Fencing`), so a holder paused between its check and+its write cannot land the write after a takeover. The driver answers+`ErrorKind::Fenced`, and the host re-reads the record, latches the fence+and returns `FenceError::Superseded`.+A refusal is a `StorageError` of kind `Backend` (not retryable, so CAS loopsdo not spin) whose source is the typed `FenceError`; `fence::fence_error`recovers it. The lookup is per write rather than per bound scope becausethe session store caches its handles across a profile's open, fence andre-open.-What it cannot do on the current ports: make the write itself conditional-on the lease. `atomic_batch` is optional (`Capability::Transactions`, only-MongoDB replica sets), it has no read-only guard op, and leases live in the-`cluster` scope while the guarded data lives in the profile's; streams and-blobs take no precondition at all. So a holder that passes the check and is-then paused past the margin can still land one write. Closing that is-upstream work in tinystoragedrivers: a fencing token on the ports (for-example a `Precondition::Fence { scope_doc, epoch }` or a `WriteOp::Check`-guard op, enforced by each driver in the same statement or transaction as-the write, with an `ErrorKind::Fenced`).+The write runs after the host check alone (and the paused-holder race stays+open) where the driver cannot fence it:++- a driver without `Capability::Fencing`: MongoDB without transactions (a+ standalone server);+- a write the driver answers `Unsupported(Fencing)`: MongoDB blob writes+ (GridFS cannot join a transaction);+- a named database (`StorageBackend::database`), which cannot see the lease+ records in the default database;+- a lease store with no record in the ports (`LocalLeases`).Tests: `fence_tests.rs` (matching, local expiry, latch, record checks,registry replace/retire/prune), `fenced_backend_tests.rs` (node A loses thelease to node B by a clock advance: A's writes on every port are refused,B's succeed; a paused node refuses its own writes inside the margin; named-databases; a fence over `LocalLeases`).+databases; a fence over `LocalLeases`; and the paused-holder race on the+memory and SQLite drivers: A's check passes, B takes over, and the driver+refuses A's write, plus the fallbacks for named databases and drivers+without fencing).## Consumers