FileSessionLeaseStore class final

File-backed ownership lease over an ExecutionEnv: the _owner.json sidecar next to the session JSONL. All failures are fail-open (E4): a lease that cannot be read is no lease; nothing here ever blocks opening a session for reading.

Constructors

FileSessionLeaseStore({required ExecutionEnv env, DateTime now()?, Duration staleAfter = const Duration(seconds: 15)})
Creates the store. now and staleAfter are injectable for tests; the heartbeat cadence lives with the owners (CLI ~4s on the inbox tick, app 5s timer) — the store only judges staleness.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
staleAfter → Duration
How old a lease's last heartbeat may be before its owner is dead.
final

Methods

acquire({required String sessionFilePath, required String sessionId, required String host, required String bootId, required int pid, String? sessionName}) → Future<LeaseAcquire>
Attempts to acquire the lease for a drive-open. A live lease is never seized — the caller becomes a viewer (LeaseBlocked). A free or expired lease is (re-)acquired atomically (temp + rename, E5); the write is verified by re-reading: a racer that renamed last owns it, the loser sees a foreign bootId and stands down.
heartbeat(String sessionFilePath, String bootId) → Future<bool>
Refreshes the heartbeat of OUR lease: a no-op (returning false) when the sidecar moved on — the caller lost the lease and must demote.
inspect(String sessionFilePath) → Future<LeaseInspect>
Reads and classifies the current lease for sessionFilePath. Corrupt/unreadable sidecar → free (E4, with the file simply overwritten by the next acquire).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
release(String sessionFilePath, String bootId) → Future<void>
Graceful release: the sidecar is deleted — only when it is still OURS (a viewer exiting never deletes the owner's lease).
sidecarPath(String sessionFilePath) → String
The sidecar path for a session JSONL path: <timestamp>_<sessionId>.jsonl → <timestamp>_<sessionId>.owner.json.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

newBootId() → String
A random per-process boot id (E3: recycles PIDs never match).