You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
agent-device: a lease re-allocated after a standalone worker restart loses retainOnClose #1463
What happens. A test runner allocates its agent-device lease through simlock's front with retainOnClose: true, so closing its session keeps the lease (ADR 0070 §2). Once #1461 lands, a standalone worker restart re-allocates the lease from leasing's record and the device registry. Neither holds retainOnClose, and the heartbeat does not carry it. The re-allocated lease therefore has no retainOnClose. The runner's next close ends the agent-device lease, and the front then ends the simlock lease (src/agent-device/front/ended.ts:43).
Where. Only after a standalone worker restart. When agent-device restarts alone, or the worker sits behind a gateway, the front's in-memory entry survives and can repeat the flag.
Why it is accepted for now. A worker restart already interrupts the test run. The maintainer chose to rebuild entries from leasing (no new stored state) over saving front entries in state.db. The gap is recorded in ADR 0071's Consequences.
A possible fix. Keep retainOnClose per lease somewhere that survives a worker restart, e.g. on the simlock lease record. The front would then repeat it on the re-allocate.
Done: read the issue, ADR 0071 (PR #1462, Proposed) and the front on maincaa5b4e. No test, no branch.
Not done: reproduction and report. There is nothing to reproduce: the re-allocate is #1461, not built. On main a standalone worker restart ends the lease at its next heartbeat whatever retainOnClose says (known gap).
Findings:
A Decision, not a defect: ADR 0071's Consequences accept this loss and narrow ADR 0070 §2. The suggested fix is new stored state, so changing it needs a superseding ADR.
The gap is wider than the body says. A gateway also rebuilds its entries after its own restart, with no retainOnClose. So "gateway restart, then worker restart" loses the flag too. Any lease re-allocated from a rebuilt entry has none.
A decision, not a defect. ADR 0071 (Accepted) narrows ADR 0070 §2, and its Consequences name both cases: an entry rebuilt from leasing "(a standalone worker restart, or a gateway restart followed by a worker restart) does not carry it". So the later comment's gateway case is already accepted. The handoff's "the front stores no retainOnClose" is out of date: a surviving entry keeps it since #1461 (front-map.ts:14).
Branch bug/1463-repro, two tests; their expectation is a proposal for a superseding ADR.
pnpm exec vitest run --project unit src/agent-device/edge-restart.test.ts src/agent-device/gateway-front-restart.test.ts
× after a standalone worker restarts, a lease allocated with retainOnClose is re-allocated with it, and a close with no open since keeps the simlock lease (#1463)
expected [ true, undefined ] to deeply equal [ true, true ] (retainOnClose on the first allocate, then on the re-allocate)
× through a gateway, after a gateway restart, then a worker restart, keeps a lease allocated with retainOnClose (#1463), …: the fleet lease list
expected [] to deeply equal [ '00000000000000000000000000000001' ]
Tests 2 failed | 29 passed (31)
Root cause
src/agent-device/front/front.ts:401 (adoptLeases) rebuilds the entry from an AdoptableLease (front/host-link.ts:22); neither leasing's record nor the registry holds retainOnClose. So heartbeat.ts:127 re-allocates without it, and ended.ts:77 ends the simlock lease at the next close. ADR 0071 took this trade over saving front entries in state.db. From the code, not tested: a gateway restart then an agent-device restart alone takes the same path.
Simplest fix
None without a new ADR. Keep retainOnClose on the simlock lease record (sent with the front's lease.request, read back by adoptable on worker and gateway). That adds a stored and a wire field and supersedes ADR 0071's narrowing: a feature, not a fix. Or close this if the ADR's choice stands.
Alternatives rejected
Save front entries in state.db: ADR 0071 rejected it; it copies what leasing holds.
Never end a restored entry on close: it breaks the runs that did not ask for retainOnClose.
Risk
A new lease field crosses the gateway–worker wire: protocol bump.
Fast track
Defect: no — ADR 0071 accepts the loss
Fix tried: no — needs new stored state and an ADR
Nothing public added or broken: no — adds a lease wire field
No ADR or rule changed: no — supersedes ADR 0071's narrowing of 0070 §2
One fix: no — lease field and state.db differ in where the data lives
Closing as not planned: this is ADR 0071's accepted choice, not a defect.
ADR 0071 (Accepted) narrows ADR 0070 §2 in its header: a lease re-allocated from an entry rebuilt after a worker restart does not carry retainOnClose.
Its Consequences name both cases from this thread: a standalone worker restart, and a gateway restart followed by a worker restart.
Its Alternatives reject the only fix (saving front entries in state.db, or a new stored field on the lease record).
Changing this needs a new ADR that supersedes that part of 0071, and it would be a feature, not a bug fix. The triage's two failing tests that pin the proposed behaviour are on branch bug/1463-repro (ef50ee8), ready for that feature if someone opens it.
Activity
V3RON commentedon Nov 9, 2026
Handoff
Done: read the issue, ADR 0071 (PR #1462, Proposed) and the front on
maincaa5b4e. No test, no branch.Not done: reproduction and report. There is nothing to reproduce: the re-allocate is #1461, not built. On
maina standalone worker restart ends the lease at its next heartbeat whateverretainOnClosesays (known gap).Findings:
retainOnClose; only agent-device keeps it. So the issue's "front entry can repeat the flag" (agent-device restart alone, gateway) holds only if agent-device leases survive a worker or agent-device restart #1461 adds the field, and a gateway rebuild (adoptable) loses it too. Input for the PR docs(adr): propose 0071, a restart re-allocates a live agent-device lease (#1461) #1462 review.Blocked on: #1461's re-allocate landing on
main; then re-addbug:new, or close if the ADR's choice stands.Written by an agent.
V3RON commentedon Nov 9, 2026
The gap is wider than the body says. A gateway also rebuilds its entries after its own restart, with no
retainOnClose. So "gateway restart, then worker restart" loses the flag too. Any lease re-allocated from a rebuilt entry has none.Written by an agent.
V3RON commentedon Nov 18, 2026
Reproduction
A decision, not a defect. ADR 0071 (Accepted) narrows ADR 0070 §2, and its Consequences name both cases: an entry rebuilt from leasing "(a standalone worker restart, or a gateway restart followed by a worker restart) does not carry it". So the later comment's gateway case is already accepted. The handoff's "the front stores no
retainOnClose" is out of date: a surviving entry keeps it since #1461 (front-map.ts:14).Branch
bug/1463-repro, two tests; their expectation is a proposal for a superseding ADR.Root cause
src/agent-device/front/front.ts:401(adoptLeases) rebuilds the entry from anAdoptableLease(front/host-link.ts:22); neither leasing's record nor the registry holdsretainOnClose. Soheartbeat.ts:127re-allocates without it, andended.ts:77ends the simlock lease at the nextclose. ADR 0071 took this trade over saving front entries instate.db. From the code, not tested: a gateway restart then an agent-device restart alone takes the same path.Simplest fix
None without a new ADR. Keep
retainOnCloseon the simlock lease record (sent with the front'slease.request, read back byadoptableon worker and gateway). That adds a stored and a wire field and supersedes ADR 0071's narrowing: a feature, not a fix. Or close this if the ADR's choice stands.Alternatives rejected
state.db: ADR 0071 rejected it; it copies what leasing holds.retainOnClose.Risk
Fast track
Written by an agent.
V3RON commentedon Nov 18, 2026
Delivery run
Closing as not planned: this is ADR 0071's accepted choice, not a defect.
retainOnClose.state.db, or a new stored field on the lease record).Changing this needs a new ADR that supersedes that part of 0071, and it would be a feature, not a bug fix. The triage's two failing tests that pin the proposed behaviour are on branch
bug/1463-repro(ef50ee8), ready for that feature if someone opens it.Merged: none
Parked: none
Waiting: none
Decided: #1463 — defect or ADR choice → ADR 0071's choice stands; closed
Written by an agent.