Files
Pulse/internal/api
rcourtman 65fd8d38b4 Stop Docker actions reaching a same-named machine's agent (#3912)
Part of #2681. A Docker container start, stop, restart or update could
run on another machine that has the same hostname.

## What was wrong

`connectedDockerCommandAgentID` tried the host's agent ID, then
whichever agent held the hostname. A typed action runs on the daemon
local to the agent that receives it, so a namesake's agent would act on
its own daemon.

This was the main route, not an edge case. `resourceFromDockerContainer`
never copied `host.TokenID`, so every real container had an empty
`Docker.TokenID` and the token and identity branches never ran. A test
through the real registry shows `TokenID:""` on `main`.

Two groups relied on the hostname lookup:

- **Guest-discovered hosts.** Hosts Pulse finds inside a Proxmox LXC
have a synthetic `proxmox-lxc-docker:` agent ID that no session holds,
yet they advertise lifecycle capabilities. Any agent with the guest's
hostname could be selected.
- **Agents with a pinned ID.** A session can register under the
`commandAgentId` Pulse acknowledged, which differs from `Docker.AgentID`
under a pinned `--agent-id`. Removing the fallback alone would have cut
these agents off.

## The fix

- Container resources now carry their host's report token.
- A hostname alone no longer selects a session. A token hit counts only
if the session also holds the resource's agent ID or hostname, because a
module on another machine can report under the same token.
- A token miss still needs an exact agent ID and hostname match. A
resource with no token uses only its own agent ID.
- Guest-discovered hosts are refused with `no_command_agent` and a
reason that names the fix: install the agent inside the guest. A typed
action has no route through the node's `pct exec`.

## Verification

- New tests cover a tokenless namesake, a token held on another machine,
a rename, a pinned ID, and guest-discovered hosts, including a plan
request.
- Mutation checks on pulse-dev: the new tests fail if the hostname
fallback returns, the token hit loses its machine proof, the guest
refusal goes, or the adapter stops copying the token.
- A mock server on pulse-dev read `no_command_agent` with this text on
all 5 guest-discovered containers, and `command_agent_disconnected` on
the other Docker containers.

Mock mode refuses planning, so the refusal reaching the review dialog is
covered by the plan request test, not by a browser run.

## Known limits

- One token reused on two machines with one hostname still cannot be
told apart. This is narrower than before, when the hostname was enough
on its own.
- A pinned `--agent-id` with a separate `pulse-agent-runner` credential
now reads as disconnected, because neither the token nor the agent ID
links them. It used to reach the runner through the hostname lookup.

Both need a server-side link between Docker hosts and command hosts.

## Not changed

The Docker page keeps Stop and Restart enabled for refused actions, for
every container. Only the REST read attaches `actionReadiness`, and
websocket rows do not, so users see the refusal when they click.
2026-11-04 20:54:43 +00:00
..
2026-10-11 22:20:25 +01:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-08-31 19:47:01 +01:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-04-26 17:26:16 +01:00
2026-01-22 00:30:15 +00:00
2026-10-11 22:20:25 +01:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-03-18 16:06:30 +00:00
2026-09-01 01:02:17 +01:00
2026-03-18 16:06:30 +00:00

Internal API Package

This directory contains the API server implementation for Pulse.

Important Note About frontend-modern/

The frontend-modern/ subdirectory that appears here is:

  • AUTO-GENERATED during builds
  • NOT the source code - just a build artifact
  • IN .gitignore - never committed
  • REQUIRED BY GO - The embed directive needs it here

Frontend Development Location

👉 Edit frontend files at: ${PULSE_REPOS_DIR}/pulse/frontend-modern/src/

Why This Structure?

Go's //go:embed directive has limitations:

  1. Cannot use ../ paths to access parent directories
  2. Cannot follow symbolic links
  3. Must embed files within the Go module

This is a known Go limitation and our structure works around it.