From c0acdda1b4fbb0ecd5aa507564068b3171c72def Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Mon, 12 Oct 2026 16:03:16 +0200 Subject: [PATCH 1/2] test: list cleanup-reaper and nuke as device.deleted initiators (#481) --- src/bus/index.test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/bus/index.test.ts b/src/bus/index.test.ts index 1a247e5d9..5781d5e21 100644 --- a/src/bus/index.test.ts +++ b/src/bus/index.test.ts @@ -290,6 +290,26 @@ describe("EventBus", () => { }, ); + it.each(["docs/internal/EVENTS.md", "docs/EVENTS.md"])( + "lists cleanup-reaper among the device.deleted initiators in %s", + (doc) => { + const markdown = readFileSync(join(REPO_ROOT, doc), "utf8"); + const row = markdown.split("\n").find((line) => line.startsWith("| `device.deleted` |")); + expect(row).toBeDefined(); + expect(row).toContain("`cleanup-reaper`"); + }, + ); + + it.each(["docs/internal/EVENTS.md", "docs/EVENTS.md"])( + "lists nuke among the device.deleted initiators in %s", + (doc) => { + const markdown = readFileSync(join(REPO_ROOT, doc), "utf8"); + const row = markdown.split("\n").find((line) => line.startsWith("| `device.deleted` |")); + expect(row).toBeDefined(); + expect(row).toContain("`nuke`"); + }, + ); + it("types every event's payload as an object", () => { expectTypeOf().toMatchTypeOf>(); }); From fb3bab79f57a47e9aa07bc925584f3f95b714178 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Mon, 12 Oct 2026 16:04:20 +0200 Subject: [PATCH 2/2] docs(events): list cleanup-reaper and nuke as device.deleted initiators (#481) Both EVENTS catalogs now name cleanup-reaper and nuke in the device.deleted initiator list, matching src/core/cleanup-executor.ts and nuke-service.ts. 3 failing -> 0 failing (the two new tests, each in both catalogs, plus the existing tests still green: 19/19). --- docs/EVENTS.md | 2 +- docs/internal/EVENTS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/EVENTS.md b/docs/EVENTS.md index 872c58a73..5d31de8a3 100644 --- a/docs/EVENTS.md +++ b/docs/EVENTS.md @@ -47,7 +47,7 @@ the gateway's own lease index before any worker is ever contacted. `lease-id-tak | `device.quarantine-abandoned` | device id, attempts | a quarantined device exhausted its configured retry budget (`warmPool.quarantine.maxRetries`) — purge retries, or delete retries for a `fresh` device — and was destroyed, or, for a physical device, unenrolled: Simlock never destroys a physical device | QuarantineCoordinator | implemented | | `device.quarantine-stranded` | device id, attempts, stable error summary | a quarantined device exhausted its retry budget (purge or delete retries) and the destroy that should have retired it also failed; it stays `quarantined` with no further retry until an operator intervenes | QuarantineCoordinator | implemented | | `device.shutdown` | device id, initiator (rule/command; `warm-pool` when the warm pool shut an idle device down, over the running limit, with `warmPool.enabled: false`, to keep `warmPool.reserveRunning` running slots free, or because a ready device that never served a lease and that no `warmPool.targets` entry keeps has been idle past `idle.shutdownAfterMs`) | device stopped, still on disk | Registry; the reclaim coordinator for interrupted reclaim recovery | implemented | -| `device.deleted` | device id, initiator (`lease-end` when a `fresh` device's lease ended and its delete completed, including a delete retried from quarantine; `doctor` when `doctor --fix`, or a daemon start that found a leased device gone from its platform, marked it missing; `operator` when `device remove` unenrolled a physical device; `quarantine` when a physical device's retries ran out and it was unenrolled; `lease-engine` when a device that failed to boot for a lease was destroyed in cleanup), physical (`true` for an enrolled physical device, `false` for a simulator or emulator) | device removed from the registry, and from disk for a simulator or emulator; a physical device is only forgotten, nothing on it changes | Registry | implemented | +| `device.deleted` | device id, initiator (`lease-end` when a `fresh` device's lease ended and its delete completed, including a delete retried from quarantine; `doctor` when `doctor --fix`, or a daemon start that found a leased device gone from its platform, marked it missing; `operator` when `device remove` unenrolled a physical device; `quarantine` when a physical device's retries ran out and it was unenrolled; `lease-engine` when a device that failed to boot for a lease was destroyed in cleanup; `cleanup-reaper` when the cleanup reaper destroyed a device; `nuke` when `nuke` destroyed it), physical (`true` for an enrolled physical device, `false` for a simulator or emulator) | device removed from the registry, and from disk for a simulator or emulator; a physical device is only forgotten, nothing on it changes | Registry | implemented | | `device.enrolled` | device id, platform, driver device id (the canonical ID), model, OS version, class (phone/tablet), app count, reenrolled | `device add` wrote a physical device `ready`; `reenrolled` is `true` when the device already had a record, which kept its device id and took a fresh read of its model, OS version, class and apps | Registry | implemented | | `device.absence-detected` | device id, previous state (ready/leased/reclaiming), absent reason (locked/untrusted/not-present) | an enrolled physical device became `absent`: it was not present for the grace period (`health.stableObservations` reads in a row, `health.probeIntervalMs` apart), or its reclaim failed while it was not present. For a leased device `lease.released` (device-lost) comes first | Registry; ReclaimCoordinator | implemented | | `device.returned` | device id, OS version | an `absent` physical device was read present again and its reclaim started; `device.reclaimed` follows when it ends, and the device is `ready` | Registry | implemented | diff --git a/docs/internal/EVENTS.md b/docs/internal/EVENTS.md index 30bf51f33..d566be9b3 100644 --- a/docs/internal/EVENTS.md +++ b/docs/internal/EVENTS.md @@ -85,7 +85,7 @@ worker is ever contacted. `lease-id-taken` (ADR 0020; widens a published vocabul | `device.quarantine-abandoned` | device id, attempts | a quarantined device exhausted its configured retry budget (`warmPool.quarantine.maxRetries`) — purge retries, or delete retries for a spent `fresh` device — and was destroyed, or, for a physical device, unenrolled: Simlock never destroys one (safety rule 2, ADR 0022 §4) | QuarantineCoordinator | implemented | | `device.quarantine-stranded` | device id, attempts, stable error summary | a quarantined device exhausted its retry budget (purge or delete retries) and the destroy that should have retired it also failed; it stays `quarantined` with no further retry until an operator intervenes | QuarantineCoordinator | implemented | | `device.shutdown` | device id, initiator (rule/command; `warm-pool` when the warm pool shut an idle device down, over the running limit, with `warmPool.enabled: false`, to keep `warmPool.reserveRunning` running slots free, or because a ready device that never served a lease and that no `warmPool.targets` entry keeps has been idle past `idle.shutdownAfterMs`) | device stopped, still on disk | Registry; ReclaimCoordinator for interrupted reclaim recovery | implemented | -| `device.deleted` | device id, initiator (`lease-end` when a `fresh` device's lease ended and its delete completed — from ReclaimCoordinator, at startup convergence, or retried from quarantine; #75. `doctor` when `doctor --fix` marked a missing device, or startup's lease reconciler found a leased device absent from a platform it could read and ended the lease in the same write, ADR 0019 §2. `operator` when `device remove` unenrolled a physical device, ADR 0022 §2. `quarantine` when a physical device's quarantine retries ran out and it was unenrolled, ADR 0022 §4; `lease-engine` when a device that failed to boot for a lease was destroyed in cleanup), physical (the record's own flag: `true` for an enrolled physical device, `false` for a simulator or emulator; additive, events rule 6) | device removed from the registry, and from disk for a virtual device; a physical device is only forgotten and nothing is sent to it | Registry | implemented | +| `device.deleted` | device id, initiator (`lease-end` when a `fresh` device's lease ended and its delete completed — from ReclaimCoordinator, at startup convergence, or retried from quarantine; #75. `doctor` when `doctor --fix` marked a missing device, or startup's lease reconciler found a leased device absent from a platform it could read and ended the lease in the same write, ADR 0019 §2. `operator` when `device remove` unenrolled a physical device, ADR 0022 §2. `quarantine` when a physical device's quarantine retries ran out and it was unenrolled, ADR 0022 §4; `lease-engine` when a device that failed to boot for a lease was destroyed in cleanup; `cleanup-reaper` when the cleanup reaper destroyed a device; `nuke` when `nuke` destroyed it), physical (the record's own flag: `true` for an enrolled physical device, `false` for a simulator or emulator; additive, events rule 6) | device removed from the registry, and from disk for a virtual device; a physical device is only forgotten and nothing is sent to it | Registry | implemented | | `device.enrolled` | device id, platform, driver device id (the canonical ID), model, OS version, class (phone/tablet), app count, reenrolled | an admin's `device add` wrote a physical device `ready` (ADR 0022 §2). `reenrolled` is `true` when the device already had a `ready`, `quarantined` or `absent` record, which kept its registry ID and took a fresh read of model, OS version, class and apps | Registry | implemented | | `device.absence-detected` | device id, previous state (ready/leased/reclaiming), absent reason (locked/untrusted/not-present) | an enrolled physical device became `absent` (ADR 0022 §2, §7, §8): the `PhysicalDeviceWatcher` read it not present `health.stableObservations` times in a row (a leased device's lease ends first, `lease.released` device-lost, in the same write), or `ReclaimCoordinator` found it not present after a failed reclaim (`reclaiming → absent`, no `device.purge-failed`, no `device.quarantined`). Emitted after the commit | Registry (the watcher's writes, the reclaim's failure path) | implemented | | `device.returned` | device id, OS version | the watcher read an `absent` physical device present, and the return reclaim it started committed `absent → reclaiming` with the OS version the read reports (ADR 0022 §7). Emitted after that commit; the reclaim then emits `device.reclaimed` | Registry (written by `ReclaimCoordinator`'s return reclaim) | implemented |