Skip to content

I3098 — Waiting derives take the machine's derive lock in the order they arrived

Give lib/machine_lock.sh a queue: a waiting derive writes a ticket (arrival time, pid, branch) under <home>/.derive.queue, the lock goes to the oldest ticket whose pid is alive, a ticket whose pid is gone is reaped, and the priority marker still overrides the order; the waiting line names the position (\"2nd of 4, behind <branch>\") and the brief's derive row shows the queue.

VERIFY wave 0 · p1 · implementation profile · parallel safe

Part of development-runtime — The runtime has a development surface.

Implementation is complete and the required evidence is not. It stays here until every token below has a command behind it — completion is gated on evidence, not on a claim.

Objective

Give lib/machine_lock.sh a queue: a waiting derive writes a ticket (arrival time, pid, branch) under <home>/.derive.queue, the lock goes to the oldest ticket whose pid is alive, a ticket whose pid is gone is reaped, and the priority marker still overrides the order; the waiting line names the position (\"2nd of 4, behind <branch>\") and the brief's derive row shows the queue.

Why

On 2026-10-20 three derives of one session waited 40 to 150 minutes on the lock while derives that started later took it: the lock is a directory every waiter polls with mkdir every 15 s, so the next holder is whichever poll lands first after the holder leaves. Sessions asked the release seat to hand-edit .derive.priority to get a turn, which is the agreement the lock was written to replace.

Current state

machine_lock.sh takes <home>/.derive.lock by mkdir and polls every MAJORDOMUS_DERIVE_POLL seconds; there is no ticket, so arrival order is not kept, and the waiting line names only the holder.

Desired state

Waiters are served in arrival order unless the priority marker names a branch; each waiting line and `majordomus brief` say the position and who is ahead.

Scope

  • lib/machine_lock.sh
  • scripts/derive
  • test/cases
  • .ai/repo/project/issues/I3098.yaml

Out of scope

  • The offload queue on other machines (I2398)

Dependencies

None. This issue is a root of the graph.

Acceptance criteria

  • Two waiters that arrive in order A then B take the lock A then B, whichever polls first
  • A ticket whose pid has died is reaped and does not hold the queue
  • The priority marker still serves its branch first
  • The waiting line names the position and the branch ahead

Validation

  • env -u MAJORDOMUS_SHARE bash test/run.sh 1018

Evidence required

  • arrival_order_is_kept
  • dead_ticket_is_reaped

Evidence

None recorded. Every token above needs a command or an artifact behind it before this issue can be completed; narrative is refused.

Timeline

started
2026-10-21T00:49:21Z
verified
2026-10-21T00:50:10Z
completed
—

Those three fields, the evidence above and the state of the dependencies are all the status is made of. There is no status field to disagree with them.

Canonical record: .ai/repo/project/issues/I3098.yaml. Read it back with majordomus plan show I3098.

Searches the titles and descriptions of every page this site publishes.