Repository navigation
fix(runner): record a run for the life of its engine - #355
Merged
Merged
Conversation
A berthd that restarted while a pinned or training engine was alive could grant a second whole-card lease. The runner wrote its record only after it noticed the lost socket, so a run that was stopped, or slow to read EOF, left the new daemon nothing to see, and it granted at once. #354 has the reproducer. The record now covers the whole life of the engine. It is written when the child starts, rewritten with the reason when the daemon goes away, cleared when the run re-attaches, and removed when the child exits. berthd counts every live record it has no lease for as due back, so the card stays held until the run re-attaches or the window closes. A training still holds with no timer, and a keep-up record holds nothing because that drain freed the card on purpose. The new tests failed before the change: TestLiveRunHoldsTheCardUntilItReattaches, TestRecordForALeasedRunHoldsNothing, the two-record table in TestTrainingLocksTheCardUntilItReattaches, and the reattach e2e, which now asserts the record before the daemon stops and its cleared state after the re-attach. One interval remains: a daemon that dies between the grant and the child start. No process exists there for a runner record to describe, so closing it needs a durable grant record in berthd.
T-Crypt
force-pushed
the
T-Crypt/run-record-covers-the-run
branch
from
November 20, 2026 20:55
f37bfc8 to
54425cd
Compare
This was referenced Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the overlapping whole-card grant in #354.
What changed
berth runandberth trainwrite their record when the engine starts and keep it for the life of the engine, instead of writing it only after the wrapper notices the lost daemon.berth statusstill lists only records whose engine is unleased.Why
In #354 the first runner was stopped, so it never read EOF and never wrote a record. The new daemon saw nothing, granted a second whole-card lease, and the first runner re-attached successfully afterwards, leaving two live leases on the card.
Proof
Four checks fail on the parent commit and pass here:
TestLiveRunHoldsTheCardUntilItReattachesTestRecordForALeasedRunHoldsNothingTestTrainingLocksTheCardUntilItReattaches, for a record with and without the lost reasonTestReattachAfterDaemonRestart, which now asserts the record exists before the daemon stops and is cleared after the re-attachThe full proof is green except the runner park tests, which this host also fails on the untouched base: memory pressure on aphotic is around 60 percent and the broker evicts parked engines above 10. With the pressure gate raised for the test daemon, the runner package passes.
Still open
A daemon that dies between the grant and the child start still has no durable trace, because no process exists yet. Closing that needs a grant record written by berthd, which is a separate change.
Refs #354.