Commit Graph

32 Commits

Author SHA1 Message Date
pulse-triage[bot]
be319e8204 Guard VM Discovery and command execution at the owning host agent
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
2026-10-04 17:59:09 +01:00
courtmanr@gmail.com
9e2ee3d535 Fail typed dispatches fast when their agent session drops
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.
2026-09-28 10:31:58 +01:00
rcourtman
2308db45bb Wait for slot release in the WebSocket connection limit test
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.
2026-09-24 18:27:22 +01:00
pulse-triage[bot]
f825e0b0a1 test(agentexec): isolate registration ordering log probe
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
2026-09-10 04:42:33 +01:00
pulse-triage[bot]
03dcabdf87 fix(agentexec): reserve registration acknowledgement before dispatch
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
2026-09-10 04:04:11 +01:00
rcourtman
60d0651a88 Cancel abandoned typed agent operations 2026-09-01 11:21:26 +01:00
rcourtman
4724c0764b Fence runner activation session authority 2026-08-31 23:52:25 +01:00
Richard Courtman
08f7c5f0d5 Harden secure agent runtime boundaries 2026-08-31 00:06:24 +01:00
Pulse Test
7e92ac8118 Harden secure runtime separation boundaries 2026-08-30 14:26:01 +01:00
Pulse Test
d06ffc233d Harden secure agent runtime transitions 2026-08-30 01:41:57 +01:00
Pulse Test
d607d5cf46 Separate agent remediation runtime 2026-08-29 23:48:28 +01:00
rcourtman
a9076de15a fix(patrol): require Docker health recovery 2026-08-27 20:43:54 +01:00
rcourtman
6163a2a564 feat(patrol): verify Docker actions independently 2026-08-27 20:14:38 +01:00
rcourtman
4c7b1a2434 Fix Docker-in-LXC probe storm against slow Proxmox hosts
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
2026-08-20 23:33:36 +01:00
rcourtman
e31fc37983 Gate Patrol actions on agent preflight 2026-08-14 01:12:49 +01:00
rcourtman
c41edb65a0 Fix agent command channel admission 2026-07-24 13:00:03 +01:00
rcourtman
acd5637485 Drive executing-action restart recovery at startup and agent registration
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.
2026-07-14 14:19:19 +01:00
rcourtman
373b491484 Fix durable APT drift receipts 2026-07-12 21:53:52 +01:00
rcourtman
d6838d3a25 Complete durable APT workflow continuity 2026-07-12 05:23:02 +01:00
rcourtman
4aac79dc72 Add durable agent operation receipts 2026-07-12 04:16:22 +01:00
rcourtman
e77ab9518d Add safe APT workflow foundations 2026-07-12 02:53:01 +01:00
rcourtman
4edf5f8265 fix: close chat command authority boundary 2026-07-11 11:54:56 +01:00
rcourtman
eb9954618a Add governed storage pressure cleanup 2026-07-11 10:11:35 +01:00
rcourtman
1312da3acb Add governed host update autonomy 2026-07-11 01:25:14 +01:00
rcourtman
9bada35337 Harden unified agent runtime and installer 2026-04-23 23:04:18 +01:00
rcourtman
60d7db6ef9 Harden agentexec token binding and disk filtering 2026-04-23 15:54:48 +01:00
rcourtman
c1d0d34c16 Cap agent exec websocket connections per IP 2026-04-22 07:22:44 +01:00
rcourtman
ccb2edc3b8 Require explicit websocket origin continuity 2026-04-22 04:46:13 +01:00
rcourtman
3ec2c0779e Harden agent command and deploy trust boundaries 2026-04-21 23:50:34 +01:00
rcourtman
778a2577b6 feat: Pulse v6 release 2026-03-18 16:06:30 +00:00
rcourtman
b7a94bad9f security: fix websocket scope and agent impersonation
1. Enforce monitoring:read scope on WebSocket upgrades
   - Prevents low-privilege tokens (e.g. host-agent:report) from accessing
     full infra state via requestData on the main WebSocket.

2. Enforce agent token binding to prevent impersonation
   - Added Metadata field to APITokenRecord to support bound_agent_id
   - Updated agentexec server to validate token-to-agent binding if present
   - Prevents agent:exec tokens from registering as arbitrary agent IDs
2026-02-03 20:40:08 +00:00
rcourtman
30f01771ac Add meaningful tests for host agent and exec websocket 2025-12-17 17:02:01 +00:00