Skip to content

feat(agent-device): an unreachable worker answers try again, and a gateway restart keeps the agent's device - #539

Merged
V3RON merged 7 commits into
task/516from
task/517
Oct 14, 2026
Merged

V3RON merged 7 commits into
task/516from
task/517

Conversation

@V3RON

@V3RON V3RON commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #517

Status

Implement: done (20/20 green) Review: round 1 passed, 3 text fixed unreviewed Hardware: n/a Gate: waiting for the stack
Next: none — waits in the #511 stack. CI Static checks fails on comment-lint in files outside this diff (stack behind main); the stack sync before the gate clears it.

Done when

  • Every Tests line passes. Checked: src/agent-device and src/ports 615/615; the audit's 8 mutations (start window, asked set, requester, refreshed, connected, target class, device key, reconnected-but-unread) each fail a named test.
  • docs/HTTP-API.md (/v1/agent-device/*) describes the unreachable answer and that a gateway restart keeps the agent's device. Checked: edited in green; the claims review found no false line there.

Assumptions

  • Assumption: how a test closes one worker's socket — a test-only closeWorkerLink(workerId) on the uplink listener, handed over by a test-only gatewayUplinks start option, the smallest hook that matches the existing gatewayRelay one.
  • Assumption: a lease id the front asked for that never reached the index (a request that failed before the grant) — it stays in the link's in-memory asked set for the life of the process, a short string each, since dropping it could let a late grant be adopted.
  • Assumption: the existing test "a command with no device selector naming a lease id another token holds..." now advances the fake clock 60 s before the unknown lease, since the spec makes an unknown lease within 60 s of start answer "try again"; its assertions are unchanged.
  • Assumption: the restarted helper in the new restart tests waits 8 s of fake time instead of 2 s, because the worker's redial delay doubles with each restart in a row; assertions are unchanged.
  • Assumption: a command answered workerUnreachable() because the uplink dropped keeps its lease renewals running until the run limit or the CLI hangs up, since the command may still run on the worker (the renewal-tick test needs the timer to stay).

Review

Spec review: 1 blocking, 1 fixed, 1 notes. Code review: 2 blocking, 1 fixed, 2 notes. Claims review: 1 blocking, 1 fixed, 0 notes.
Rounds: 1. Tokens: 21.6M.

Rejected:

  • code: src/agent-device/front/front.ts:169 renewals run to maxRunMs after a WORKER_UNREACHABLE answer — recorded as Assumption 5; the renewal-tick spec test needs the timer to stay

Fixed unreviewed: spec: gateway-front.test.ts:1936 link-memory test now runs past the 60 s window; code: gateway-front.test.ts:1972 lease.list keeps the disconnected worker's lease, proven; claims: host-link.ts:34 comment on the worker's map.

Written by an agent.

@V3RON

V3RON commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Review notes

Not blocking, not verified. Each is one reviewer's claim.

  • spec: src/agent-device/front/front.ts:170 a command answered "try again" keeps renewing its lease until the run limit, so the device stays held after the agent gives up (Assumption 5 and spec tests 4 and 8 force this)
  • code: src/agent-device/front/front.ts:93 two paths decide whether devices is unreachable from different lease sets (notRunning uses unfiltered liveOf, devicesThroughGateway uses tokenDevices); their answers can differ
  • code: src/agent-device/front/relay-host-link.ts:198 the relay's 330 s deadline also throws WORKER_UNREACHABLE, so a long command on a connected worker gets "not connected; try again" and a retry can run it twice

Written by an agent.

@V3RON
V3RON marked this pull request as ready for review October 14, 2026 06:28
@V3RON
V3RON added this pull request to stack #522 October 14, 2026 06:28
@V3RON

V3RON commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Review notes

Not blocking, not verified. Each is one reviewer's claim.

  • claims (fix-check): src/agent-device/front/relay-host-link.ts the tenant comment says only refused characters and the dot are escaped, but _ is escaped too (tok_a becomes tok_5f_a); ADR 0026 section 6 repeats this

Written by an agent.

@V3RON
V3RON merged commit a39c129 into main Oct 14, 2026
34 checks passed
@V3RON
V3RON deleted the task/517 branch October 14, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(agent-device): a disconnected worker is not an ended lease, and a gateway restart keeps the device

1 participant