Skip to content

Commit d2f2eb7

Browse files
committed
test(daemon): preserve direct-close completion guarantees
1 parent 5b28b28 commit d2f2eb7

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎packages/daemon/src/server/http/daemon-runtime-quiesce.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,9 @@ test('a detached daemon refuses a shutdown request and keeps serving', async ()
570570
null,
571571
);
572572
await daemon.runtime.close();
573+
expect(readDaemonShutdownRecord(resolveDaemonPaths(daemon.stateDir).baseDir).completion).toBe(
574+
null,
575+
);
573576
});
574577

575578
test('an embedded runtime outlives the idle window a detached daemon reaps itself on', async () => {

‎website/docs/docs/client-api.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ if ('cloudArtifacts' in result) {
9090

9191
A client talks to one local daemon per state directory. `daemonLifecycle` says who owns that daemon.
9292

93-
A host-owned daemon ends through its host's own close or an authenticated shutdown request over its registered local transport. Clients never signal the host. A `'managed'` client reuses a matching host-owned daemon. Takeover, drain, and timeout recovery ask the central retirement, which judges the record's owner once: a live host-owned or unrecognized owner is refused without a signal, while a record whose owner provably exited is retired like any abandoned one, so the state directory stays usable. `agent-device daemon stop --state-dir <path>` sends the shutdown request and waits for the close report. It can also ask a readable record with unrecognized ownership: an embedded runtime can close itself, but a detached answer fails with `daemon-not-embedded` and a record-repair hint, without signaling.
93+
A host-owned daemon ends through its host's own close or an authenticated shutdown request over its registered local transport. Clients never signal the host. A `'managed'` client reuses a matching host-owned daemon. Takeover, drain, and timeout recovery ask the central retirement, which judges the record's owner once: a live host-owned or unrecognized owner is refused without a signal, while a record whose owner provably exited is retired like any abandoned one, so the state directory stays usable. `agent-device daemon stop --state-dir <path>` sends the shutdown request and waits for the close report. It can also ask a readable record with unrecognized ownership: an embedded runtime can close itself, but a detached answer fails with `daemon-not-embedded` and a record-repair hint, without signaling. A host's direct close also records its result, so stops already waiting can confirm a clean release.
9494

9595
For these shutdown requests, stop fails with `daemon-embedded-stop-unreachable` when the record lacks usable transport or token, `daemon-shutdown-unconfirmed` when the close cannot be confirmed (including after connection failure), or, without `--clean`, `daemon-record-unreadable` when `daemon.json` cannot be read. These are `error.details.reason` values. A retained close returns `stopped: true`, warnings and `cleanupConfidence: 'unknown'` with exit 0: the runtime stopped serving, but resource cleanup is unconfirmed. Later stops can read that retained answer while the same host holds the registration.
9696

0 commit comments

Comments
 (0)