Expand description
The owner record inside every owner-lock directory.
What:
The owner record inside every owner-lock directory (owner.json,
schema version 1):
its strict parser,
its exact encoding,
and the owner-liveness rule.
Why:
The landing,
reservation,
hook,
capture and push locks are directories holding this
record.
The incumbent and its hook dispatcher write and read the same record
(src/owner-lock/owner-lock-record.ts),
so both wrappers contend on one lock and each
retires the other’s dead lock.
In TS you’d write (pseudocode):
const record = parseOwnerLockRecord(text); const alive = await ownerLockHolderIsAlive(record);Structs§
- Owner
Lock Record - What:
The durable owner of one published lock.
A
structgroups named fields;Option<String>is “text or nothing”. Why: The token distinguishes this acquisition from every other; the PID and birth identity prove liveness; the reservation lock also names its transaction.
Enums§
- Owner
Record Error - What: Why a lock’s record could not be judged. Why: A malformed or unreadable record must stop the acquirer: it might belong to a live owner, and the wrapper never deletes a lock it cannot prove dead.
- Published
Owner - What:
What reading a published lock found.
Busymeans the lock vanished while it was read, so the caller must look again. Why: A release or retirement renames the directory away at any moment; that is a race to retry, not corruption.
Constants§
- OWNER_
LOCK_ RECORD_ FILENAME - Owner record filename inside a published lock directory.
- OWNER_
LOCK_ RECORD_ LIMIT - Largest owner record read; a record is about 150 bytes, so anything near this is corrupt.
- OWNER_
LOCK_ SCHEMA_ VERSION - Owner-lock record schema version.
Functions§
- encode_
owner_ lock_ record - What:
Encode an owner record exactly as the incumbent’s
writeCandidatedoes: compact JSON in field order, with a trailing newline. Why: Records written by either wrapper are byte-identical for the same values. - owner_
lock_ holder_ is_ alive - What:
Whether a recorded owner still runs with the same process birth.
Why:
A PID that names no process,
a zombie,
or a younger process reusing the PID is a
dead owner.
The incumbent’s
ownerLockHolderIsAlivecompares identities only. - parse_
owner_ lock_ record - What:
Parse an owner record’s text,
or nothing when it is malformed.
Why:
The incumbent’s
parseOwnerLockRecordaccepts exactly: schema version 1, a non-empty token, a safe-integer PID of at least 1, a non-empty birth identity, and an optional non-empty transaction ID. Anything else is malformed. - read_
owner_ lock_ record - What:
Read the owner of a published lock directory.
Why:
A missing record or directory means the lock vanished (
ENOENT,ENOTDIR), which the incumbent reports as busy so the caller retries.