Skip to content

fix(daemon-client): match a spawned daemon's server mode to an explicit http transport - #5136

Merged
thymikee merged 4 commits into
mainfrom
t3/http-transport-server-mode
Nov 27, 2026
Merged

thymikee merged 4 commits into
mainfrom
t3/http-transport-server-mode

Conversation

@thymikee

@thymikee thymikee commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Summary

A client that asked for --daemon-transport http with no --daemon-server-mode started a daemon in the socket-only default. That daemon opens no HTTP listener and publishes no httpPort, so the client never observed it as ready, retired it, and failed every call with daemon_endpoint_unavailable.

resolveTransportClientSettings now derives the spawn server mode from an explicitly requested transport, as it already did for dual: http starts its daemon in http mode. An explicit --daemon-server-mode or AGENT_DEVICE_DAEMON_SERVER_MODE still wins; auto and socket keep the socket-only default.

Where the mode opens no listener the client will call, in either direction, the pair is refused before anything is started, retired or quiesced. serverModeAnswersTransport decides it once, in the module owning both vocabularies; each route asks it where a daemon would next be changed — before a takeover retires what it found, and before the first launch. A daemon already serving that endpoint is reused.

Before / after

$ agent-device session list --daemon-transport http        # fresh state dir
base: Error (COMMAND_FAILED): Daemon HTTP endpoint is unavailable.
head: { "sessions": [] }                  # daemon.json: httpPort 54096

$ agent-device session list --daemon-transport socket --daemon-server-mode http
base: Error (COMMAND_FAILED): Daemon HTTP endpoint is unavailable.
head: Error (INVALID_ARGS): ...server mode "http" serves no socket endpoint...  [state dir empty]

Validation

Head 279a05e722. daemon-client-lifecycle-server-mode.test.ts (18 cases) covers the derivation per transport and source, explicit-mode precedence, socket/auto unchanged, a remote base URL, both refusal directions with no spawn, the refusal before a takeover on both routes, reuse of a reachable daemon, the hint's wording, and a control proving a usable pair reaches the counted launch mock. Each guard was checked by removing it and reading the failure.

vitest run --project unit-core packages/daemon-client/src/__tests__: 43 files, 434 passed. src/host, daemon-entrypoint, daemon-contracts, reason-tables passed. typecheck, build, oxfmt and oxlint clean.

Reason renamed daemon_server_mode_serves_no_client_transport; error-reasons.md regenerated. No changeset: unreleased. CI owns the remaining gates.

…it http transport

An explicit http transport derived no server mode, so the daemon a managed client started stayed
in socket mode: no HTTP listener, no published httpPort. The client retired the daemon it could not
observe over the endpoint it needed, and every call failed at an unavailable endpoint. Derive the
mode from the transport, and refuse a launch that would serve none before the first spawn.
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.64 MB 6.64 MB +1.1 kB
Package (unpacked) 6.64 MB 6.64 MB +1.1 kB
Package (download) 2.03 MB 2.03 MB +450 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 21.5 ms 24.9 ms +3.3 ms
CLI --help 49.4 ms 49.5 ms +0.1 ms

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 11b5097. The verdict and the full list are in the summary comment.

…fore any takeover

A client judged the pair of its own transport and the server mode it would start only where it was
about to spawn. Both routes that take over a registered daemon retired or quiesced that daemon first,
and the check named only one direction: a socket client naming an http-only server mode still started
a daemon with no socket listener and retired it.

`serverModeAnswersTransport` decides the pair once, in the module that owns both vocabularies. Each
route asks it where a daemon would next be changed — before the takeover retires what it found, and
before the first launch — so a reachable daemon stays reusable and an unusable configuration ends
nothing. The refusal names both override sources, since one socket value left behind still decides the
mode.
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 279a05e

Since the review of 11b5097: 0 new · 0 still open · 1 no longer raised (1 marked fixed)

No open findings.

🔧 1 finding marked fixed in their threads
Finding Fixed by Where
Refusal can land after the caller already retired a running daemon for takeover thymikee a28f44b · reply

2 findings below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (3e0814c574f5).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 279a05e, with no code changes required.

Not blocking, and fine to take or leave: since an explicit http transport now starts an http-only daemon, could a later explicit socket client on the same state dir replace it and start a back-and-forth takeover (if so, derive dual or note it in a follow-up issue), and could the comments that repeat the guard rule at call sites shrink to one line each, with the full doc kept on assertServerModeAnswersClientTransport?

Three earlier threads no longer apply and can be resolved: the guard now runs before retirement, a socket preference with http mode is now refused, and the hint now says to clear both --daemon-server-mode and AGENT_DEVICE_DAEMON_SERVER_MODE.

The only failing checks are four cancelled Body rules runs, superseded by later pushes or edits. This is likely unrelated to the code, which that job does not exercise. A fresh green Body rules run is needed before merge.

Not verified here: the before/after CLI transcript and the guard-removal mutations were not re-run. It was also not traced whether an http-only daemon loses any socket-only internal route, such as lease beat or stop; it was only confirmed that auto clients accept any advertised transport.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 26, 2026
@thymikee
thymikee merged commit adc68ae into main Nov 27, 2026
22 of 26 checks passed
@thymikee
thymikee deleted the t3/http-transport-server-mode branch November 27, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant