Separate user-editable host metadata writes from administrator command
execution policy so monitoring:write callers cannot toggle or clear
commandsEnabled. Require Docker container action dispatch to verify
live session ownership and full 64-character lowercase container IDs,
and refuse dispatch when a single token reports multiple Docker hosts
for the target identity.
Verify Proxmox node action runner routing against the live session
hostname and prevent automatic host-report node links from stealing a
node held by another reporting agent. Gate command details on agent
resource-context, changes, and events routes behind action capability
checks, and withhold probe credentials from agents using other tokens.
Contract-Neutral: Security hardening for agent action routing, metadata authority, and command/probe disclosure without changing public API contracts.
Close read-only AI tool escapes, device-open hazards, DNS exfiltration, and unbounded allocation:
- Deny lsblk --sysroot in the shared agentexec policy and restrict lsblk, lscpu, and lsmem in the pulse_read classifier to allowlisted options.
- Confine auto-approved df, fdisk -l, and file -s operands to explicit directories or kernel block device names so character devices like /dev/watchdog cannot be opened without approval, and add a targeted df refusal hint.
- Fix BSD/macOS ps environment option parsing in psPrintsEnvironment so dash-prefixed options are never skipped as values and dashless clusters reject uppercase E.
- Turn ssFilterNamesHost into an allowlist over keywords, literals, and comparison values, drop -F/--filter, and validate prefix lengths in isLiteralNetworkHost to block DNS exfiltration.
- Stop preallocating the pulse_query search result slice by the caller-supplied limit so huge limits cannot trigger an unrecoverable out-of-memory crash.
Contract-Neutral: Security hardening of AI tool sandboxing, agentexec sessions, and Patrol/Assistant authorization without public contract delta
Close command-channel session hijacking, transport stalls, and read-only policy bypasses across agentexec and hostagent:
- Always qualify agentexec session keys with the organization ID (including default), reject control characters in agent IDs, and verify organization ownership on session lookup.
- Enforce a 10s write deadline on agentexec text writes and close timed-out connections so a non-reading agent cannot pin the session write lock and block action admission.
- Refuse first-use install-token command bindings when another unexpired token of the organization holds the live command session, monitor host record, or durable token binding for that agent ID.
- Confine auto-approved host log reads beneath /var/log via os.Root and /dev/fd descriptors to prevent symlink escapes, and require approval for guest (container/vm) log reads where host confinement does not apply.
- Restrict auto-approved pvesh get commands to listed non-credential API subtrees and restrict docker/podman format templates to direct field selections so output masking cannot be stripped.
Contract-Neutral: Security hardening of AI tool sandboxing, agentexec sessions, and Patrol/Assistant authorization without public contract delta
Docker operators need to diagnose service failures and change one image
without losing the source that owns a running application. Bind approved
updates to the registered Compose file or Git base, then show the running
image and fresh HTTP evidence after rollout. Keep log access opt-in, mute
container alerts per runtime, and connect the Docker installer and demo
to the application workflow.
The update read the pull progress stream and threw it away. The daemon
reports most pull failures (rate limits, denied access, missing
manifests) inside that stream, and a pull cut off by its two-minute
timeout just ends early, so a failed pull went on to stop the container,
recreate it on the old image and report a verified update.
Read the stream to its end and fail the update on a reported error, a
broken stream or an expired deadline, before anything is stopped. Give
the pull its own eight-minute limit so large images on slow links can
finish inside the fifteen-minute update window.
When the pulled tag resolves to the image the container already runs,
refuse with image_unchanged instead of restarting the service for
nothing.
Name each step that stops an update before any change with a typed
reason code (inspection, precondition, image pull, unchanged image,
stop, rename). Field telemetry showed every pre-change failure from
current agents counted as "uncoded", which reads as agents awaiting the
typed refusal vocabulary. The new codes fill the existing prerequisite
and target_changed counters, so the telemetry schema is unchanged.
A failed stop or rename call is no longer taken as proof that nothing
changed, since the daemon may have acted before its response was lost.
The container is read back: a stopped or renamed original gets its name
back and is started again, and the result reports that as a rollback and
whether it worked.
The live Compose integration test now starts its services on an older
image under the tag the update pulls, so each update is a real image
change, and checks that a second update is refused as unchanged without
restarting the container.
The default command policy approves a list of inspection programs
without a human. Those rules match the start of the command, so the
same programs also ran their other forms without approval: ip and
ifconfig changes, find -delete/-exec/-fprint, du --files0-from,
file -f/-m/-d, sar -o, ss -K, journalctl --vacuum-*/--cursor-file,
ps environments and similar.
After a pattern matches, autoApprovedArgsSafe now splits the command
into shell words after quote removal (refusing anything the shell would
expand) and, for find, du, file, last, blkid, ss, lsof, journalctl,
systemctl, apt-cache, sar, ps, ip, ifconfig, dpkg, pvesh and podman,
refuses options that change the host, write files or read another
file's contents. ip, ifconfig, dpkg and podman use allowlists; the rest
deny the risky options, including getopt_long abbreviations and short
option clusters. Programs that read meaning from the number of operands
refuse unquoted globs. Several patterns are anchored, and service
status takes a plain service name.
Commands without an approval or the Trusted flag also no longer inherit
variables that change how sh, grep, ps, blkid or apt-cache read the
command line (BASH_FUNC_*, BASH_ENV, ENV, SHELLOPTS, BASHOPTS, PS4,
GREP_OPTIONS, PS_FORMAT, PS_PERSONALITY, CMD_ENV, BLKID_FILE,
BLKID_CONF, APT_CONFIG).
Display forms Patrol and operators use keep running without approval;
the tests list both sides. The agent environment test used ps e as its
auto-approved read, which is now refused, so it prints the environment
the shell received through a swapped executable instead. The
agent-lifecycle contract records the rule.
The default command policy approves `cat`, `head`, `tail` and `grep`
without a human for log reads. Those rules were prefix matches, so the
whole command was approved as long as one word named a `/var/log/` (or
`/log/`) path. This change checks every argument instead.
- Words must be plain, single-quoted or simply double-quoted. Options
must be known for each program, take checked values and come before the
first operand. Every file operand must be a path under `/var/log`, with
no parent segment and no glob that could expand to one.
- grep options that open another file or follow every symlink need
approval. So does a recursive grep whose only operands are globs.
- A single `&` now counts as a command separator, and the
`/etc/os-release` rule takes no extra operands.
- Behaviour change: tail, head and grep on log directories outside
`/var/log` now need approval.
Tests cover the allowed forms, including the single-quoted path that
`pulse_read` builds for tail, and the refused ones. The agent-lifecycle
contract records the rule.
The default command policy approved cat, head, tail and grep without a
human when the command started with the program name and any word
mentioned /var/log/ (or /log/ for head, tail and grep). Extra file
operands elsewhere, and parent segments, passed with it. The server
dispatch gate and the agent both rely on this policy for commands sent
with no approval, which includes AI read-only commands.
Log reads are now checked word by word: plain, single-quoted or simple
double-quoted words only; known options per program with checked
values, all before the first operand; at least one file operand; and
every file operand a path under /var/log with no parent segment and no
glob that could expand to one. grep options that open another file or
follow every symlink are left to approval, and a recursive grep needs
one literal operand so it cannot fall back to the current directory.
Paths under other log directories now need approval too.
The shell-operator check now treats a single & as a separator, and the
/etc/os-release rule no longer accepts extra operands.
pulse_read never sends an approval, so any command the agent's policy
will not auto-approve fails every time, and the policy never
auto-approves a piped or chained command. The model learned this only
from a bare "command execution failed: command requires approval". On
the third replay of the full-disk fault Patrol chose a piped `du`, then
a chained `du; ls`, by itself; three of its ten evidence calls went to
refusals and it ran out one level into the camera folders.
The agent server now returns a named ErrCommandRequiresApproval, with
the same message text, and pulse_read turns it into an APPROVAL_REQUIRED
refusal with a hint: piped, chained or substituted commands always need
approval, run each part on its own, for example `du -xh -d 3
<directory>`. The command parameter also says one command per call.
Other execution failures are reported as before. The hint test now
covers this hint's suggested form too, against all three gates.
The first commit on this branch let a node's own Pulse agent start a
stopped Proxmox guest, and chose that agent by hostname. Another
machine can hold a node's name, and the same VMID there is a different
guest. A second review of the branch found that and the faults below.
Which agent. A start now needs all of this, or it is refused with
guest_start_agent_unconfirmed: exactly one agent tied to the node, the
node on the guest's own Proxmox connection under the guest's own node
name, the agent carrying the node's name with no other monitored node
of that name, and an address on one of the agent's own interfaces that
Proxmox lists for that node and for no other. The link Pulse makes on a
matching name is not evidence, nor the address Pulse dials, which can be
a proxy, nor the agent's configured report address. This is evidence and
not proof: a machine Pulse does not monitor as a node, with the node's
name and one of its addresses, is not ruled out. An agent Pulse cannot
confirm is not told to switch commands on either, because the start
would still be refused.
Runner routes. A route planned on the action runner now demands a runner
at dispatch. A collector that took the runner's place under the same
agent ID is refused, so its answer is never judged by the runner's rule.
Agent side. The service check is the exact cgroup
/system.slice/pulse-agent.service, so a user manager's unit of that name
no longer passes. Every command client of one state directory shares one
containment, so a client created when commands are switched cannot
prepare again while an old client's start is finishing. A registration
waits five seconds for the containment probe, not fifteen, and a later
change is restated on the live session with an agent_capabilities
message.
Mock data. Every mock node listed the same address and its agent
reported an unrelated one, so the new rule refused every mock node's
agent as unconfirmed. Mock nodes now have their own addresses and each
node's agent reports them, as on a real node.
Docs said more than the code did in several places. They now match.
Pulse could start, stop or restart a Proxmox guest only through a
separately enrolled action runner. Getting one takes five steps, needs
HTTPS and turns command access off on the node. So when a container
died, Patrol handed it back even on a node whose owner had ticked
"Allow Pulse to run commands on this host".
A node's own Pulse agent can now start a stopped guest, after an admin
approves. It starts and does nothing else: stop, shutdown and reboot
stay with the action runner, refused on an agent session by the server
gate, by the executor and by the agent itself.
The agent could not run a typed command at all. Its transient systemd
unit was bound to the runner's service, used the runner's state
directory and started a launcher only the runner binary serves. The
collector now serves that launcher for its own catalog (the containment
probe, a status read and a start), binds the unit to its own service and
uses its own state directory. Every other unit property is the
runner's. The runner's path is unchanged.
The server decides from what the agent reports at registration, never
from a version. The agent reports it only with commands enabled, as
root, running as pulse-agent.service on a Proxmox node, with durable
receipts and a passed containment probe. Otherwise it gives a closed
reason and Pulse says which it is: commands off, agent too old, not a
systemd service, or containment not set up.
A start an agent session ran is confirmed only by Pulse's own Proxmox
check. The agent's readback stays as evidence and no longer confirms.
No installer change, no default change, no new scope, no telemetry.
Close the deferred-save process-restart gap with a synchronous approval publication barrier serialized against normal saves. Refuse command authority on a failed encode or write and retain the conservative spent local decision without exposing storage paths.
Recheck expiry and request cancellation after the persistence barrier. Exercise no-Flush reload, unchanged saved bytes, in-memory compatibility, the real saved verifier and synthetic signed agent transport, and zero-grant cancellation/deadline exits.
Change-source: pulse-maintainer
Two Proxmox installations that reuse a node name or a VM name could not
both hold a command channel. The command server admitted one session per
hostname per tenant, so the second agent was refused on every retry and its
actions read "not connected". After a Pulse restart, whichever agent came
back first won, which dropped the other node's LXC Docker containers.
That rule came from c41edb65a0. Before it, a hostname lookup took the first
map match, so two same-named sessions meant a random machine. The rule fixed
the tie but not the cause. A hostname still does not name a machine: the
first token to connect held the name and locked the real machine out, and a
lone holder answered for a same-named machine that was offline.
Sessions are now keyed by tenant and agent ID alone. One agent ID from two
hostnames stays refused. The server has no lookup by hostname any more, and
each route that picked a session by name now asks by identity:
- Proxmox guest actions and Patrol probes start from the guest's own record.
A typed lifecycle action carries only a VMID, so a runner chosen by node
name could have changed another machine's guest with the same VMID.
- The legacy Assistant route and its cluster peer lookup took whichever agent
a hostname map held last, and now refuse a tie.
- The connections ledger no longer falls back to the hostname, so a machine
with no session stops reading as connected through its namesake's.
- A name lookup never reads an agent ID as a name, since a token holder picks
its own first ID.
A proven node agent with no session yet now dispatches nothing instead of
counting as a node failure. Those failures opened the node breaker while
agents reconnected after a restart, and the node's LXC containers then left
the Docker page for the backoff window.
Refs #2681
No Router built by the internal/api tests was ever freed. At the end of a run
all 1,358 were still reachable, with 26,000 goroutines and 2.86 GiB live, so
peak memory grew with every new test until the release correctness job ran out
of memory on its 7 GiB runner.
Most test sites never stopped their Router's workers. The few that did were
pinned anyway, because the setup-token cleanup worker in ConfigHandlers had no
way to stop and holds callbacks back into the Router. That worker now joins
the Router's shutdown, and package tests build Routers through newTestRouter,
which stops them with the test. Two new tests fail if a Router stays reachable
after shutdown or a package test calls NewRouter directly.
Default command policies now share one compiled pattern set. A private copy
cost 230 KiB and 1.4 ms per call and is now 2.2 KiB and 1.6 us. It accounted
for a quarter of the live test heap. In production each organization's AI
service holds one, so this also saves about 230 KiB per organization.
Measured on pulse-dev at 88c2a21f65 with the same go test -count=1 -p 1 run:
peak RSS of the largest child 6.41 GiB before, 2.44 GiB after. That largest
child is now the compiler: a cold test build alone peaks at 2.34 GiB and the
test binary alone at 1.48 GiB. All package tests pass. CPU time fell about 5%;
wall clock followed the host's load and is not comparable between these runs.
Contract-Neutral: Stops test Router workers and shares compiled policy patterns; no API, policy decision or storage change.
AI Discovery ran a separate model-backed service scanner beside Patrol
and the Assistant: its own store, scheduler, model route, API, tool and
drawer UI. No telemetry counter ever measured its use (the telemetry
discovery_enabled flag OR'd it with network subnet discovery), the
maintainer judged it a flop, and the context it produced is already
available to the models through pulse_query, pulse_read and the
unified-resource context sections.
This deletes internal/servicediscovery, internal/ai/infradiscovery, the
pulse_discovery tool, the /api/discovery routes, the mock Discovery
fixtures, the Discovery tabs in the resource, guest, node and Docker host
drawers, the identified-service cards, readiness badges, provenance
markers, suggested web-interface URLs, the Workloads AI Context column,
the chat "Discovery is off" hint and the AI Service Context settings page.
The old settings route redirects to Assistant settings. The model-bound
sanitizer allow-list existed only to pass Discovery context through, so it
goes too, along with the CopyableCodeRow primitive that only the
Discovery tab used.
Network subnet discovery (/api/discover, the Infrastructure discovery
settings) and the discoveryTarget agent coordinates are separate features
and stay. Stored discovery_enabled, discovery_interval_hours and
discovery_model AI settings are ignored on load; the settings API decoder
is lenient, so older frontends saving those fields still succeed.
Require local current-node lock evidence and registered guard support before QGA execution. Serialise VM probes, stop on deferral, retain actual in-flight outcomes and saved Discovery evidence, and pause uncertain completion without replay. Config checks do not reserve QGA or prove native thaw; the existing backup monitoring-outage precaution remains.
Change-source: pulse-maintainer
The agentexec read loop removed a dead session from the agent map but never
closed its done channel, so any dispatch already sent on that session kept
waiting for a result that could never arrive and only returned at its
operation timeout. That's what made the Proxmox cancellation replay test
flaky on the shared CI runner. The restarted action runner dropped its first
session right after registering, the replay had already been sent there,
and the server waited the full 30s while the runner sat reconnected on a
new session.
The read loop now signals the session done on exit, so in-flight typed
dispatches and commands report the disconnect straight away. The
integration test sends the same request again on the runner's next
session when that happens, which is the same durable replay it is there
to prove, still with exactly one mutation. It also keeps the runner's log
and prints it on failure so the cause of any future drop is visible.
Agent removal occurs inside read-loop cleanup before the handler releases
its per-IP connection slot. The flood test could observe the first state
and retry while the slot was still occupied, causing a spurious rejection.
Wait for the guarded admission count to reach zero before reconnecting,
while preserving rejection at capacity and successful registration after
release.
The regression temporarily replaces zerolog's global logger. A prior WebSocket
handler can still be finishing after its own test returns, so joining only this
probe's handler does not prevent a race with that earlier log write. Run the
hook in a bounded child invocation of the same race-instrumented test binary.
Change-source: pulse-maintainer
A session was discoverable before its registration acknowledgement reserved the write lock. An immediate dispatch could therefore become the first frame, which the unified client rejects while awaiting registration. Reserve the new connection write lock under the session-map lock so no dispatcher can overtake the handshake.
The deterministic publication-window regression fails before the repair. Agentexec package race tests and real unified-agent typed receipt replay/cancellation tests pass after it; no timeout thresholds or admission checks are relaxed.
Change-source: pulse-maintainer
Proxmox planning and dispatch now require a unique credential-admitted typed
runner with durable receipts. Development authentication preserves explicit
bearer identity so runner activation keeps its tenant and credential scope.
Preserve observer and receiver timestamps from their separate clocks instead
of rejecting or rewriting valid evidence. Keep completed execution separate
from stale or inconclusive verification, and label independent observations
accurately in action reviews.
Verified with targeted race suites, action-review tests and frontend build,
plus a real Assistant start plan and approved VM110 start/stop with independent
Proxmox confirmation. Final action reviews passed Playwright at 1440, 900 and
390 pixels, including retained completed, rejected and expired history.
The guest Docker socket probe hung minipc hard enough to need a power
cycle (2026-08-20): ~100 orphaned pct exec children, load 133, sshd and
pveproxy starved. Three bugs chained, each fixed here:
1. Dispatcher re-issued a probe while the previous one was still
executing. The poll cycle's enrichment context had expired, so
ExecuteCommand dispatched, returned the context error 50ms later,
and the next 3s cycle sent the identical command again — unbounded
concurrency against a host that was slow to begin with. The
monitoring dispatcher now takes a per-guest in-flight claim before
dispatching probe or inventory commands (completed probes release
it; abandoned ones hold it for a 2-minute window), and both dispatch
paths bail out under a dead context.
2. The host agent never got the July process-leak fix: 45480a5cc
landed only on pulse/v6-release, so main-line agents killed just the
direct shell on timeout, orphaning pct exec → lxc-attach children
and blocking Wait on their inherited pipes (10s timeouts reported as
300s+ durations). Port it: run each command in its own process
group, SIGKILL the group on cancel, bound Wait with WaitDelay, and
treat ErrWaitDelay after a clean exit as success.
3. Server-side abandonment never reached the agent. ExecuteCommand and
ReadFile now refuse to dispatch under an already-expired context,
and send a best-effort cancel_command when they stop waiting; the
agent cancels the in-flight execution (killing its process group)
and reports "command canceled". Older agents ignore the unknown
message type.
Also add a per-node circuit breaker: three consecutive command failures
on one node suspend all Docker probe/inventory dispatch to it on the
existing 1m→30m backoff schedule, so a host-level stall (NFS flapping)
stops the probing entirely instead of failing guest by guest.
Regression tests simulate the storm without hardware: a never-returning
executor is not re-issued across poll cycles, an expired context
dispatches nothing and records no failure, abandoned probes hold their
claim, the breaker blocks new guests on a failing node, and the agent
kills the whole process group on timeout and on server-issued cancel.
Contract-Neutral: monitor.go delta is three private struct fields holding Docker probe dispatch state; host-agent deletion/re-enrollment lifecycle untouched — contracts and all other proofs are staged
Eight new branch-coverage tests taking thirty-one previously unreached
functions from zero to covered, with no source or existing test touched.
internal/kubernetesagent: twenty-one pure report helpers, including the pointer
converters proved non-aliasing in both directions, the ingress host and address
collectors across their trim, dedupe and insertion-order arms, the endpoint
slice readiness count where a nil Ready field counts as ready, and the target
role predicate.
internal/agentexec: the sudo long-option value gate over the real option list
including the inline equals form, and the approval grant verification error
unwrapped through errors.Is.
internal/alerts: the alert config alias normalization across the nil config
guard, the empty threshold early return, the blank type-key continue arm and
the legacy-delete versus supported-keep split, asserting both maps stay
independent.
internal/alerts/specs: the resource incident rollup evidence validation, each
failure arm asserted on its concrete error and the check order pinned when
several fields are invalid at once.
internal/cloudcp/docker: the not-found predicate through a wrapped error, the
route host label precedence, and the Traefik host rule parser across quoting
styles, combined matchers, multiple host clauses and malformed input.
internal/cloudcp/portal: the anonymous bootstrap builder, asserting no tenant
or user identity field is ever populated on the anonymous result.
internal/config: the legacy OIDC environment provider, including the arm where
an already-configured provider is present and the redirect derivation from a
public URL with a trailing slash.
internal/dockeragent: the update-all payload decode across wrong-typed and
missing fields, and the docker filter conversion.
Contract-Neutral: test-only branch coverage, no contract surface touched
The rejection told operators to re-run the agent installer, but the
token minted by the original install command cannot gain the exec scope
after the fact and install tokens are single use, so re-running the
same command loops forever (issues #1586, #1564). Name the actual
recovery step instead.
Contract-Neutral: reworded operator-facing rejection copy (#1586, #1564); no behavior or contract change
The docker container lifecycle codec in agentexec had a contract test that never
exercised the codec functions at runtime, leaving decode, bind, validate and
identity helpers at zero coverage. This adds a table-driven test taking each to
near or full coverage including every validation error arm. In aicontracts,
CloneActionReference, IsNilAlertPayload and DefaultEngineConfig were uncovered,
so this covers the nil and populated arms and asserts CloneActionReference
produces an independent deep copy.
Both are new test-only files. No source changed. Verified with go test, gofmt
and go vet, with each target function confirmed to move off zero coverage.
RecoverExecutingActions existed with full test coverage but had no
production caller, so any typed action mid-dispatch across a server
restart (container update, start/stop/restart, host update, storage
cleanup) stayed in the executing state forever and sat in the Actions
inbox as live work, even after the agent persisted its terminal durable
receipt. Reproduced live on the dev instance with a Docker container
update (act_bf77dfe860ad3d8e4e0a91dc8eb83b44).
The router now runs a bounded, serialized recovery pass per organization
from a startup background worker, and again whenever an agent
(re)registers on the agentexec command server via a new registration
notifier, because a receipt-pending attempt can only be reconciled while
the owning agent is connected. Both triggers reuse the existing
query-only reconciliation semantics; nothing gains a resend authority.
Task 07 owns this residual; the api-contracts and agent-lifecycle
subsystem contracts now record the production trigger. The
rg-07-durable-delivery gate suite stays green, and a new router-level
test pins that a receipt-pending executing action completes from the
agent receipt without a second dispatch.
v6.1.0-rc.1 retired the legacy update endpoints before a replacement
existed, so the UI's Update button failed with an internal-jargon 410
(issue #1564). This lands the replacement end to end: update_container
is a typed agentexec operation with its own strict codec, durable
receipts, and a request digest bound to the image digest the plan
observed; the unified agent bridges execution to the Docker module's
existing pull/backup/recreate/verify/rollback implementation (which now
reports rollback attempt and outcome); and the container action
executor plans, dispatches, and reconciles the operation with declared
backup/rollback compensation truth. Containers advertise an
admin-approval update capability while an image update with a stated
current digest is detected. The legacy endpoints stay retired but
return actionable copy.
Proven live against a Colima daemon: single-container update, the
issue-1564 shared-network-namespace update, and the full UI journey
(Update button, governed review, approve, run) all completed with the
namespace preserved and the backup retained.