Skip to main content

Module adopt

Module adopt 

Source
Expand description

Adoption of attempts that were built but never landed.

A run that is interrupted, or a lease that lapses while the work waits for the gate, leaves an attempt that its worker finished: the branch carries the unit’s Built stamp and the trace it was built from. Sending that unit back to a worker would pay for a model session to write what is already written. Instead the attempt is adopted: the scheduler claims the unit again, relabel makes the attempt’s work the new claim’s branch, and the unit goes straight to the gate with no worker session.

An attempt is adoptable (adoptable) when

  • its worker is gone — the run that made it ended or died. That is the caller’s to decide: this module only looks at git;
  • its branch — the newest attempt branch of the unit since the unit was last verified — carries a Built stamp for the unit, with a recorded trace, at its tip;
  • that trace still matches the unit’s reading set at the current mainline head: nothing it was built from has moved.

An attempt the gate (or its worker) already judged is not adopted: one set aside as rejected-gate, rejected-write-set, ownership-conflict, blocked or released would only be judged the same way again, and a rejected adoption — set aside on the new claim’s branch — would otherwise be adopted again, forever. Those go to a worker, as today. An attempt that changed paths outside the unit’s write-set is not adopted either: the gate would reject it, and its files go to the next worker as a draft instead.

§Re-labelling

The attempt’s own commit cannot simply be given the new claim’s branch name. It forked from the old claim’s commit, and mainline has rewritten the unit’s fencing fields twice since (the release, the new claim), next to the status line the attempt changed: the gate’s merge would conflict in the unit’s own front matter. relabel therefore builds the new claim’s branch the way a worker would have: forked from the new claim’s commit, with one commit that carries the attempt’s work — the files the unit owns that the attempt changed, as the attempt left them, and the unit’s handoff fields (status, built, trace) from its Built stamp. Nothing else is carried, so the branch is exactly the attempt’s work, relative to the new claim.

Fencing holds. The token is the claim sequence the branch name carries; the old claim’s branch keeps the old sequence, which the gate’s fencing check rejects, and only the deliberate new claim’s branch — made by relabel, which refuses an existing name — can land. The gate then runs as for any attempt: fencing, the write-set check against the new claim, the input check, every row. Adoption skips the model, never the gate.

Structs§

Attempt
An attempt that can go to the gate without a worker.

Enums§

Refusal
Why a unit has no adoptable attempt.

Functions§

adoptable
The adoptable attempt of unit, or why there is none. inst is the SDD as the current mainline head holds it, loaded from the checkout at root (checked out at that head); git reads the repository’s branches (any checkout of it will do). The caller has established that no worker of a live run holds the attempt.
relabel
Re-label attempt as the work of the new claim new_seq, whose claim transaction made claim_commit: create the branch sdd/<slug>/<unit>/c<new_seq> at claim_commit and commit on it the attempt’s work (see the module doc), in a scratch worktree at scratch — where the new claim’s worker would have worked (Layout::unit_worktree) — that is removed again. Returns the branch.