Accept reverted/failed device status reports #26

Merged
benvin merged 2 commits from benvin/status-reverted into main 2026-10-05 21:44:15 +11:00
Member

Agent mode will auto-revert a generation that cuts a device off from the API, but the status endpoint only accepts an applied generation, so reverts and failures are invisible.

  • accept {"generation":N,"status":"applied|reverted|failed","error":"..."}; generation-only payloads stay applied
  • reject unknown status values with 400
  • add migration storing last status, its generation, error and timestamp per device
  • advance reported_generation only on applied
  • expose agent_status on GET /devices/{name}

Refs unkin/tomswall#11

Agent mode will auto-revert a generation that cuts a device off from the API, but the status endpoint only accepts an applied generation, so reverts and failures are invisible. - accept `{"generation":N,"status":"applied|reverted|failed","error":"..."}`; generation-only payloads stay `applied` - reject unknown status values with 400 - add migration storing last status, its generation, error and timestamp per device - advance `reported_generation` only on `applied` - expose `agent_status` on `GET /devices/{name}` Refs unkin/tomswall#11
unkin-agent added 1 commit 2026-10-05 13:52:13 +11:00
Accept applied/reverted/failed in device status reports
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
f2197c2189
Author
Member
  • internal/store/store.go:288 — an applied report with an OLDER generation moves reported_generation backwards (unconditional = $3), and any older report overwrites status/status_generation of a newer one (late retry, replayed report) → use GREATEST(reported_generation, $3) for applied and guard the status columns with WHERE ... AND $3 >= status_generation (or equivalent); add a test posting applied N then applied N-1.
- internal/store/store.go:288 — an `applied` report with an OLDER generation moves `reported_generation` backwards (unconditional `= $3`), and any older report overwrites `status`/`status_generation` of a newer one (late retry, replayed report) → use `GREATEST(reported_generation, $3)` for applied and guard the status columns with `WHERE ... AND $3 >= status_generation` (or equivalent); add a test posting applied N then applied N-1.
unkin-agent added 1 commit 2026-10-05 13:56:26 +11:00
Ignore status reports older than the stored generation
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
7245ff6643
Author
Member

No findings.

No findings.
benvin merged commit 6ee47ab1c4 into main 2026-10-05 21:44:15 +11:00
benvin deleted branch benvin/status-reverted 2026-10-05 21:44:15 +11:00
Sign in to join this conversation.