The workstream lease
The lease is a file named .lease in a workstream’s folder. While it exists, a run is working in that workstream. Each run takes the lease of its own workstream before it writes any artifact there, and gives it back when it finishes. A run that only adds items to the backlog takes no lease.
Contents
Section titled “Contents”The lease holds one key: value line per key, in this order:
session: a random token, written once.acquired: the time the lease was taken, written once.heartbeat: the time of the latest refresh.stage: the stage the run begins next, orupkeeponce only the end-of-run bookkeeping remains.artefact: the ID of the artifact that stage works on.task,task_titleandtask_started: the number, title and start time of the task now running. Only the refresh before a child task or a task with no children sets them, and every other refresh writes them empty.note: one line on progress inside the stage.
Times are ISO 8601 in UTC. A lease held by a run in this repository:
session: b954b247-bc89-4695-a1f3-c28a14234c9eacquired: 2026-10-30T05:01:21.679Zheartbeat: 2026-10-30T05:15:34.080Zstage: execute-tasksartefact: TL-39-m8dnlotask: 3.4task_title: Write the task and run-safety pagestask_started: 2026-10-30T05:15:34.053Znote: parent task 3 of 6, subtask 3.4How a run uses it
Section titled “How a run uses it”Acquire. Once the workstream folder exists, FlowCharge creates .lease with an exclusive create, which fails only if a lease already exists. It keeps the session token for the rest of the run.
Contention. If a lease already exists, its age runs from its heartbeat, or from acquired when it has none. Under 60 minutes, the run halts and reports the holding session and the lease’s age, without waiting or retrying. At 60 minutes or older, the lease is stale: the run deletes it, retries the create once, and goes on.
Refresh. The run rewrites the lease right after it acquires it, after every stage, when execution starts, and before each child task or task with no children. It writes a temporary file in the same folder and renames it into place, so a reader never sees a half-written lease. If the file is missing or no longer holds this run’s token, the run no longer holds the workstream and halts.
Release. At the end of a run, and when a run halts, FlowCharge deletes .lease, but only if its session line still matches this run’s token. Otherwise another run has taken the workstream over, and the lease stays.
Stale leases. The generator reports a lease more than 60 minutes old as stale, and never deletes it.
Lease files are kept out of git. See What Core keeps out of git.
Checked against FlowCharge Core v0.6.0.
