Skip to main content

Module lease

Module lease 

Source
Expand description

One computer at a time for a part of Sioul’s work (docs/database.md, “Leases”): reminding medicines, numbering invoices. Two computers doing either at once is a harm: a dose reminded again after it was taken, two invoices with one number.

Through the sharing folder: each computer writes its own claim on a part, sealed like the records (leases/<part>/<computer>.lease), one writer per file so the sync never makes conflicted copies; renewed each minute while Sioul runs, alive five minutes after its last renewal, taken out when Sioul quits, or is put away on a phone: then it says so (close) with how far it wrote its records, so the others know it marks nothing until it is back (docs/health.md, “Knowing”). Every computer reads the same claims the same way:

  • a part that follows you (medicines) is kept by the live claim used most recently: the computer you are at;
  • a part that stays put (invoices) is kept by the live claim taken last, on purpose (“make invoices here”), else the oldest.

A computer acts on a part only once it has kept it for the settling time: the others’ claims have had time to come through the sync. A sync that stopped can still hide a claim; what must never happen twice also wants the others heard from lately (Keeper::others_heard).

Structs§

Claim
A computer’s claim on a part, in seconds.
Keeper
Who keeps a part now.

Enums§

Rule
Who keeps a part, as the claims say.

Constants§

ALIVE
How long a claim lives after its last renewal.
SETTLING
How long a computer keeps a part before acting on it.
UNCLOSED
How long a claim on a part that stays put (invoices) still holds it once lapsed, unless it says it closed: a computer whose sync stopped, or whose claims a phone’s sync app brings half an hour late, may still be numbering (review of 5 October 2026, F7); one gone without closing (a crash, a computer given away) holds it a day, then no more.

Statics§

KEPT 🔒
Since when this computer keeps each part, as seen here: (part → (keeper, since)).

Functions§

bound 🔒
choose 🔒
The keeper among the claims that hold the part (holds), by the part’s rule; ties go to the smaller id.
claims
Every claim on part that reads, live or not.
close
This computer’s claim on part closed: Sioul quits, or is put away on a phone. It keeps nothing, and says how far it wrote its records, so the others know everything it marked before it closed.
folder_of 🔒
holds 🔒
Whether a claim holds its part now: alive; for a part that stays put, lapsed but not closed, within UNCLOSED of its last renewal too.
host_name
This computer’s name, as people call it: its host name, asked once. On a Mac no file holds it and a program tells it: started at each claim (three a minute), it also held for a moment a copy of every file Sioul had open, the sharing’s lock among them (share::exchange_lock).
keeper 🔒
look
Who keeps part, as read now, without claiming it.
read 🔒
The claims on part: of one fetched from the server too (remote::overlay), the later renewed of the two copies; the folder’s on a tie.
read_in 🔒
renew
This computer’s claim on part, renewed (made the first time): active is when you were last at this computer, take takes the part on purpose, wrote how far it wrote its records. Returns who keeps it now.
started
When this process began, as the lease first asked (Unix seconds).
write 🔒
A claim sealed into its file, its size changed from the one there (share::pad_for).