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
The agent-device front ends a lease for good when one lease.list answer leaves it out #750
The agent-device front marks a lease ended by simlock whenever one `lease.list` answer does not contain it:
`src/agent-device/front/token-devices.ts:26` (a `devices` call or a device-list rule)
`src/agent-device/front/front-map.ts:148` (`refresh`, on allocate)
Nothing undoes it: renewals stop (`front/renewals.ts:54`, `:100`, `:127`) and heartbeats answer "ended by host" (`front/heartbeat.ts:128`). The simlock lease then runs out its TTL.
On a gateway, `lease.list` leaves out leases that are still live: entries whose view is missing for a moment ("a race with a reconnect rebuild", `src/gateway/dispatcher.ts:427-439`), and every lease on a starting worker (#405). The gateway's own rule is that only a worker's relayed fact or answer ends a lease (`src/gateway/AGENTS.md`, Rules). Fixing #405 removes one cause, not this one.
Defect, confirmed through a gateway. The issue names two sites; there are four. renewLease also reads lease.list, so a renewal tick or a heartbeat that misses the lease ends it too.
src/agent-device/gateway-front.test.ts: "a lease the gateway's lease.list leaves out of one answer, read by a devices call, an allocate, a renewal while a command runs, or a heartbeat, is not ended: the next heartbeat succeeds and renews the simlock lease".
pnpm exec vitest run --project unit src/agent-device/gateway-front.test.ts -t "is not ended"
src/agent-device/front/token-devices.ts:26, front-map.ts:148 and renewals.ts:24 (returns gone, then renewals.ts:130 and heartbeat.ts:87 call markEnded). All four treat "not in this lease.list answer" as "ended by simlock". On a worker that is true: the list is the source. On a gateway it is not: dispatcher.ts:436 skips an indexed lease whose view is missing. The gateway's lease index (FleetPort.leaseOf) only drops a lease on the worker's fact, but the front never asks it. The symptom shows later: heartbeat.ts:128, the renewal guards.
Simplest fix
Add an optional HostLink method, e.g. stillHeld?(leaseId). RelayHostLink answers fleet.leaseOf(leaseId) !== undefined. The worker link leaves it out, so a missing lease stays final. At the four sites, a lease missing from the list is ended only when stillHeld is false. Otherwise: devices leaves it out of this answer, refresh skips it, and renewLease returns failed (try again).
Alternatives rejected
Gateway lease.list returns indexed leases with no view: it has no deadline to report, and the dispatcher skips them on purpose.
Activity
V3RON commentedon Oct 20, 2026
Reproduction
Defect, confirmed through a gateway. The issue names two sites; there are four.
renewLeasealso readslease.list, so a renewal tick or a heartbeat that misses the lease ends it too.src/agent-device/gateway-front.test.ts: "a lease the gateway'slease.listleaves out of one answer, read by adevicescall, an allocate, a renewal while a command runs, or a heartbeat, is not ended: the next heartbeat succeeds and renews the simlock lease".Root cause
src/agent-device/front/token-devices.ts:26,front-map.ts:148andrenewals.ts:24(returnsgone, thenrenewals.ts:130andheartbeat.ts:87callmarkEnded). All four treat "not in thislease.listanswer" as "ended by simlock". On a worker that is true: the list is the source. On a gateway it is not:dispatcher.ts:436skips an indexed lease whose view is missing. The gateway's lease index (FleetPort.leaseOf) only drops a lease on the worker's fact, but the front never asks it. The symptom shows later:heartbeat.ts:128, the renewal guards.Simplest fix
Add an optional
HostLinkmethod, e.g.stillHeld?(leaseId).RelayHostLinkanswersfleet.leaseOf(leaseId) !== undefined. The worker link leaves it out, so a missing lease stays final. At the four sites, a lease missing from the list is ended only whenstillHeldis false. Otherwise:devicesleaves it out of this answer,refreshskips it, andrenewLeasereturnsfailed(try again).Alternatives rejected
lease.listreturns indexed leases with no view: it has no deadline to report, and the dispatcher skips them on purpose.lease.listbefore ending: a starting worker can outlast any retry.Risk
devicesmust still hide an unlisted lease's device in that answer.fleet.leaseOf, not the link's routing memory. That memory keeps dropped leases forlease.maxTtlMs.edge.test.ts).Written by an agent.
fix(agent-device): drop the unneeded devices filter for a lease the l…
fix(agent-device): devices leaves out a lease the gateway's list omit…
fix(agent-device): a lease the gateway's list omits is not ended (#750)…
V3RON commentedon Oct 20, 2026
Delivery run
Merged: #753 (#750)
Parked: none
Waiting: none
Decided: none
Written by an agent.