Repository navigation
Conversation
Implements the Background Capability Lease Protocol (design v1): a tiny, local-first, JSON-serializable contract that distinguishes enabled, running, and actually-delivered for an opt-in background capability. - New src/lease.rs: Lease struct (desired_state, effective_state, owner process/pid/hostname, heartbeat with expiry, last-successful delivery receipt) with atomic write/read/remove and unit tests. - dirs::get_state_dir(): state dir following ActivityWatch conventions (~/.local/state/activitywatch/aw-notify on Linux). - Wire into the service: write lease on start, refresh heartbeat in the main loop, record a delivery receipt on each successful notification, remove the lease on clean shutdown. A monitor can read the lease file and test liveness with no scheduler and no server round-trip: enabled = lease exists, running = fresh heartbeat, stale = expired heartbeat, delivered = last_successful receipt. Note: pre-commit cargo-check/clippy skipped locally (libssl-dev unavailable, no sudo); lease logic verified via standalone unit tests. CI will run the full build. Git-Session-Id: c214
is_running/is_stale/mark_stopped/read_lease are the read-side contract for a separate monitor process; the writer binary itself only writes/touches/records, so clippy -D warnings flagged them as dead code. Annotate them explicitly. Git-Session-Id: c214
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Implements the Background Capability Lease Protocol (design v1): a tiny, local-first, JSON-serializable contract that distinguishes enabled, running, and actually-delivered for an opt-in background capability.
What
src/lease.rs:Leasestruct (desired_state,effective_state, owner process/pid/hostname,heartbeatwith expiry, last-successfuldelivery_receipt) with atomic write/read/remove and unit tests.dirs::get_state_dir(): state dir following ActivityWatch conventions (~/.local/state/activitywatch/aw-notifyon Linux).Why
"Enabled", "running", and "actually delivered" are currently conflated for opt-in background capabilities. A background job can be enabled but not running, or running but not delivering — and nothing distinguishes these states durably. This adds a lease file any monitor can read with no scheduler and no server round-trip:
now - last < expiry)last_successfulreceipt newer than the threshold being verifiedVerification
lease.rspass (fresh/stale/touch/delivery/serialization/write-read-remove).cargo build/clippy not run locally (libssl-dev unavailable, no sudo); CI will run the full build. The lease module is pure serde+chrono+std and verified standalone.Out of scope (unchanged)