Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Route hostname lookups through canonical equivalence
rcourtman62ec34ef0255
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex c1c9ef6511..74a1be45e9 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -386,6 +386,13 @@ an add-only capacity posture.registration and update paths must not depend on package-global mutable testseams that can leak between concurrent agent sessions or tests.5. Preserve canonical /api/auto-register node identity continuity when canonical hosts shift between hostname and IP forms for the same node.+ That same lifecycle-adjacent shared-API boundary now covers relay and+ command-target hostname resolution too. When lifecycle flows reuse+ `internal/api/router_routes_ai_relay.go`, `internal/agentexec/server.go`,+ or other shared agent-target helpers, they may treat a short hostname as+ equivalent to the same agent's FQDN, but they must not widen that fallback+ into a short-name collapse that would make two different FQDNs appear to+ be the same lifecycle target.6. Keep Proxmox registration continuity self-healing: stale local registration markers must be verified against Pulse before the host agent skips setup, and a missing matching node on the Pulse side must drive canonical re-registration instead of asking operators to delete marker files manually.7. Keep first-session lifecycle handoff explicit: the live setup completionsurface in `frontend-modern/src/components/SetupWizard/SetupCompletionPanel.tsx`diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 14e3a816ba..f5f3738160 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -96,6 +96,13 @@ runtime cost control, and shared AI transport surfaces.the runtime must reserve enough output tokens for structured discovery JSON,and discovery prompts must cap fact/path/port fan-out explicitly instead ofrelying on providers to truncate oversized infrastructure inventories.+ That same runtime-owned command-target boundary must resolve hostnames+ through `internal/unifiedresources/hostname_equivalence.go`.+ `internal/ai/tools/internal_routing.go`,+ `internal/ai/tools/tools_control.go`, and adjacent AI command helpers may+ match a short host against its FQDN, but they must not broaden that+ fallback into a generic short-name collapse that would make two distinct+ FQDNs with the same short host look interchangeable.## Current Statediff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 6b7d880ddf..9d730fe8c9 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -209,6 +209,15 @@ the canonical monitored-system blocked payload.18. Keep hosted tenant browser-session precedence on the shared auth boundary: `internal/api/auth.go`, `internal/api/contract_test.go`, and hosted tenant callers must treat a valid `pulse_session` as authoritative before any API-only token fallback or no-local-auth anonymous fallback, so cloud handoff can continue into protected hosted routes without flattening the operator back to `anonymous` or forcing a browser session through bearer-token-only mode after the tenant has minted API tokens.19. Keep tenant settings-scope authorization aligned with org management: `internal/api/security_setup_fix.go`, `internal/api/contract_test.go`, and settings-bound hosted callers must allow the current non-default org owner/admin membership to exercise privileged tenant routes, rather than requiring a separate configured local admin identity after hosted handoff.20. Keep mobile onboarding payload reads aligned with the server-owned relay-mobile credential: `internal/api/router_routes_ai_relay.go`, `internal/api/onboarding_handlers.go`, and `internal/api/contract_test.go` must allow the dedicated `relay:mobile:access` scope to reach the governed QR, deep-link, and connection-validation payloads without reintroducing a broader `settings:read` requirement for token-authenticated pairing clients.+ That same shared relay/runtime boundary also owns hostname target+ equivalence for agent command routing. `internal/api/router_routes_ai_relay.go`+ and `internal/api/contract_test.go` may match a short host against the+ canonical connected-agent FQDN, but they must do so through+ `internal/unifiedresources/hostname_equivalence.go` and must not collapse+ distinct FQDNs that merely share the same short hostname into one API+ target. When an explicit `targetHost` misses that canonical match, the+ shared relay adapter must keep the result empty instead of silently+ falling back to the lone connected agent.21. Keep hosted billing-state quickstart payload fields on the shared API contract: `internal/api/hosted_entitlement_refresh.go`, `internal/api/subscription_state_handlers.go`, and `internal/api/contract_test.go` must preserve `quickstart_credits_granted`, `quickstart_credits_used`, and `quickstart_credits_granted_at` through hosted signup, hosted lease refresh, and billing-state reads instead of letting lease rewrites silently erase seeded quickstart inventory.22. Keep hosted AI settings bootstrap on the shared API contract: `internal/api/ai_hosted_runtime.go`, `internal/api/ai_handlers.go`, `internal/api/ai_handler.go`, and `internal/api/contract_test.go` must treat a missing `ai.enc` in hosted mode as a canonical bootstrap condition, persist one machine-owned quickstart-backed AI config with the Pulse-owned alias `quickstart:pulse-hosted` when hosted entitlements grant AI capability, and preserve that configured settings payload as the same public contract that Chat, Patrol, and AI Settings consume instead of embedding a third-party model ID in the transport contract.That same hosted bootstrap surface must also preserve the secure quickstart-identity contract: hosted or trial-backed AI settings reads and enablement may bootstrap Patrol quickstart from the effective signed entitlement lease when no self-hosted installation token exists, but they must not fabricate installation-scoped activation state or anonymous client identity to satisfy `/v1/quickstart/bootstrap`.diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex f620b743c6..689f800d06 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -386,6 +386,13 @@ querying, and the operator-facing storage health presentation layer.2. Keep recovery store/runtime changes aligned with the storage and recovery frontend proofs in `registry.json`3. Tighten guardrails when legacy storage or recovery presentation paths are removed4. Preserve the dependency split: API payload ownership stays in `api-contracts`, settings shell ownership stays in `frontend-primitives`, and canonical resource truth stays in `unified-resources`+ That same adjacent API boundary now includes shared agent-target hostname+ equivalence. Storage- and recovery-adjacent surfaces that reuse+ `internal/api/router_routes_ai_relay.go` or other shared agent lookup+ helpers may match a short host against the same agent's FQDN, but they+ must keep that logic on the canonical+ `internal/unifiedresources/hostname_equivalence.go` contract instead of+ widening it into a broad short-name collapse across distinct FQDNs.5. Keep recovery history table width budgeting derived from the canonical column specs in `frontend-modern/src/utils/recoveryTablePresentation.ts`, not from raw visible-column counts, so normalized subject labels and optional column sets cannot drift the right-edge badges and controls off-screen6. Keep at least one browser-level desktop recovery proof in the governed `recovery-product-surface` policy so right-edge column visibility and wrapper-fit regressions are caught at rendered layout time instead of only through unit-level width math7. Keep the dashboard route's no-resources state on an explicit first-sessiondiff --git a/internal/agentexec/server.go b/internal/agentexec/server.goindex 1615641adb..9153e8bffa 100644--- a/internal/agentexec/server.go+++ b/internal/agentexec/server.go@@ -15,6 +15,7 @@ import ("github.com/google/uuid""github.com/gorilla/websocket"+ "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources""github.com/rs/zerolog/log")@@ -980,13 +981,14 @@ func (s *Server) IsAgentConnected(agentID string) bool {return ok}-// GetAgentForHost finds the agent for a given hostname+// GetAgentForHost finds the agent for a given hostname using the canonical+// hostname-equivalence contract shared with the unified identity layer.func (s *Server) GetAgentForHost(hostname string) (string, bool) {s.mu.RLock()defer s.mu.RUnlock()for _, ac := range s.agents {- if ac.agent.Hostname == hostname {+ if unifiedresources.HostnamesEquivalent(ac.agent.Hostname, hostname) {return ac.agent.AgentID, true}}diff --git a/internal/agentexec/server_test.go b/internal/agentexec/server_test.goindex 49043fb9ed..e709bc0ece 100644--- a/internal/agentexec/server_test.go+++ b/internal/agentexec/server_test.go@@ -260,3 +260,44 @@ func TestConnectedAgentLookups(t *testing.T) {t.Fatalf("expected 2 connected agents, got %d", len(agents))}}++func TestGetAgentForHostNormalizesFQDNAndCase(t *testing.T) {+ s := NewServer(nil)+ now := time.Now().Add(-1 * time.Minute)++ s.mu.Lock()+ s.agents["a1"] = &agentConn{agent: ConnectedAgent{AgentID: "a1", Hostname: "prox97.seftic.local", ConnectedAt: now}}+ s.mu.Unlock()++ cases := []string{"prox97", "PROX97", "prox97.seftic.local", "Prox97.Seftic.Local"}+ for _, lookup := range cases {+ agentID, ok := s.GetAgentForHost(lookup)+ if !ok || agentID != "a1" {+ t.Errorf("GetAgentForHost(%q) = (%q, %v), want (a1, true)", lookup, agentID, ok)+ }+ }++ if _, ok := s.GetAgentForHost(""); ok {+ t.Errorf("GetAgentForHost(\"\") should return false")+ }+}++func TestGetAgentForHostKeepsDistinctFQDNsSeparate(t *testing.T) {+ s := NewServer(nil)+ now := time.Now().Add(-1 * time.Minute)++ s.mu.Lock()+ s.agents["a1"] = &agentConn{agent: ConnectedAgent{AgentID: "a1", Hostname: "prox97.a.local", ConnectedAt: now}}+ s.agents["a2"] = &agentConn{agent: ConnectedAgent{AgentID: "a2", Hostname: "prox97.b.local", ConnectedAt: now}}+ s.mu.Unlock()++ agentID, ok := s.GetAgentForHost("prox97.a.local")+ if !ok || agentID != "a1" {+ t.Fatalf("GetAgentForHost(%q) = (%q, %v), want (a1, true)", "prox97.a.local", agentID, ok)+ }++ agentID, ok = s.GetAgentForHost("prox97.b.local")+ if !ok || agentID != "a2" {+ t.Fatalf("GetAgentForHost(%q) = (%q, %v), want (a2, true)", "prox97.b.local", agentID, ok)+ }+}diff --git a/internal/ai/tools/internal_routing.go b/internal/ai/tools/internal_routing.goindex 1ec97208bc..a6e23d1185 100644--- a/internal/ai/tools/internal_routing.go+++ b/internal/ai/tools/internal_routing.go@@ -2,6 +2,7 @@ package toolsimport ("github.com/rcourtman/pulse-go-rewrite/internal/models"+ "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources")func (e *PulseToolExecutor) resolveResourceLocation(name string) models.ResourceLocation {@@ -15,7 +16,7 @@ func (e *PulseToolExecutor) resolveResourceLocation(name string) models.Resourceif nodeName == "" {nodeName = node.NodeName()}- if nodeName == name || node.ID() == name {+ if unifiedresources.HostnamesEquivalent(nodeName, name) || node.ID() == name {return models.ResourceLocation{Found: true,Name: name,@@ -54,7 +55,7 @@ func (e *PulseToolExecutor) resolveResourceLocation(name string) models.Resourcefor _, dh := range rs.DockerHosts() {dhName := dh.Hostname()- if dhName == name || dh.ID() == name {+ if unifiedresources.HostnamesEquivalent(dhName, name) || dh.ID() == name {loc := models.ResourceLocation{Found: true,Name: dhName,@@ -139,7 +140,7 @@ func (e *PulseToolExecutor) resolveResourceLocation(name string) models.Resource}for _, host := range rs.Hosts() {- if host.Hostname() == name || host.ID() == name {+ if unifiedresources.HostnamesEquivalent(host.Hostname(), name) || host.ID() == name {return models.ResourceLocation{Found: true,Name: host.Hostname(),diff --git a/internal/ai/tools/strict_resolution_test.go b/internal/ai/tools/strict_resolution_test.goindex 2703aaa4a5..149d2fc0f1 100644--- a/internal/ai/tools/strict_resolution_test.go+++ b/internal/ai/tools/strict_resolution_test.go@@ -1300,6 +1300,67 @@ func TestRoutingOrder_HostnameMatchUsedWhenTopologyUnknown(t *testing.T) {t.Log("✓ Agent hostname matching works as fallback for unknown resources")}+// TestRoutingOrder_AgentFQDNMatchesShortNodeName verifies that an agent whose+// os.Hostname() resolves to an FQDN (e.g. "prox97.seftic.local") still routes+// correctly when the AI targets the Proxmox short node name ("prox97"). Prior+// to the hostname-normalization fix this failed silently with "no agent+// available", even though the agent was online with Pulse Commands enabled.+func TestRoutingOrder_AgentFQDNMatchesShortNodeName(t *testing.T) {+ state := models.StateSnapshot{+ Nodes: []models.Node{{ID: "prox97", Name: "prox97"}},+ }++ agentServer := &mockAgentServer{+ agents: []agentexec.ConnectedAgent{+ {+ AgentID: "agent-prox97",+ Hostname: "prox97.seftic.local", // FQDN as reported by os.Hostname()+ },+ },+ }++ executor := NewPulseToolExecutor(ExecutorConfig{+ StateProvider: &mockStateProvider{state: state},+ AgentServer: agentServer,+ })++ // AI targets the short Proxmox node name+ routing := executor.resolveTargetForCommandFull("prox97")++ if routing.AgentID != "agent-prox97" {+ t.Fatalf("AgentID = %q, want %q (FQDN must match short node name)", routing.AgentID, "agent-prox97")+ }+ if routing.ResolvedKind != "node" {+ t.Errorf("ResolvedKind = %q, want %q (should resolve via topology)", routing.ResolvedKind, "node")+ }+ if routing.ResolvedNode != "prox97" {+ t.Errorf("ResolvedNode = %q, want %q", routing.ResolvedNode, "prox97")+ }+}++// TestRoutingOrder_UppercaseHostnameMatchesLowercase verifies case-insensitive+// matching in the agent-hostname fallback path.+func TestRoutingOrder_UppercaseHostnameMatchesLowercase(t *testing.T) {+ state := models.StateSnapshot{}++ agentServer := &mockAgentServer{+ agents: []agentexec.ConnectedAgent{+ {AgentID: "agent-x", Hostname: "MyHost"},+ },+ }++ executor := NewPulseToolExecutor(ExecutorConfig{+ StateProvider: &mockStateProvider{state: state},+ AgentServer: agentServer,+ })++ routing := executor.resolveTargetForCommandFull("myhost")++ if routing.AgentID != "agent-x" {+ t.Fatalf("AgentID = %q, want %q (hostname match must be case-insensitive)", routing.AgentID, "agent-x")+ }+}+// TestRoutingOrder_VMRoutesViaQMExec verifies VMs also route through topology.func TestRoutingOrder_VMRoutesViaQMExec(t *testing.T) {state := models.StateSnapshot{diff --git a/internal/ai/tools/tools_control.go b/internal/ai/tools/tools_control.goindex 1329e1d630..13001638f6 100644--- a/internal/ai/tools/tools_control.go+++ b/internal/ai/tools/tools_control.go@@ -781,7 +781,7 @@ func (e *PulseToolExecutor) resolveTargetForCommandFull(targetHost string) Commaswitch loc.ResourceType {case "agent":for _, agent := range agents {- if agent.Hostname == loc.TargetHost || agent.AgentID == loc.TargetID {+ if unifiedresources.HostnamesEquivalent(agent.Hostname, loc.TargetHost) || agent.AgentID == loc.TargetID {result.AgentID = agent.AgentIDresult.AgentHostname = agent.Hostnameresult.ResolvedKind = "agent"@@ -880,7 +880,7 @@ func (e *PulseToolExecutor) resolveTargetForCommandFull(targetHost string) Comma}// Standalone Docker host - find agent directlyfor _, agent := range agents {- if agent.Hostname == loc.TargetHost || agent.AgentID == loc.TargetHost {+ if unifiedresources.HostnamesEquivalent(agent.Hostname, loc.TargetHost) || agent.AgentID == loc.TargetHost {result.AgentID = agent.AgentIDresult.AgentHostname = agent.Hostnamereturn result@@ -893,7 +893,7 @@ func (e *PulseToolExecutor) resolveTargetForCommandFull(targetHost string) Comma// Only used when the state doesn't know about this resource at all.// This handles standalone hosts without Proxmox topology.for _, agent := range agents {- if agent.Hostname == targetHost || agent.AgentID == targetHost {+ if unifiedresources.HostnamesEquivalent(agent.Hostname, targetHost) || agent.AgentID == targetHost {result.AgentID = agent.AgentIDresult.AgentHostname = agent.Hostnameresult.ResolvedKind = "agent"@@ -1170,7 +1170,7 @@ func (e *PulseToolExecutor) findAgentForNode(nodeName string) string {agents := e.agentServer.GetConnectedAgents()for _, agent := range agents {- if agent.Hostname == nodeName {+ if unifiedresources.HostnamesEquivalent(agent.Hostname, nodeName) {return agent.AgentID}}@@ -1197,11 +1197,11 @@ func (e *PulseToolExecutor) findAgentForNode(nodeName string) string {if linked == "" {continue}- if nodeNamesByID[linked] != nodeName {+ if !unifiedresources.HostnamesEquivalent(nodeNamesByID[linked], nodeName) {continue}for _, agent := range agents {- if agent.Hostname == host.Hostname() || agent.AgentID == host.ID() {+ if unifiedresources.HostnamesEquivalent(agent.Hostname, host.Hostname()) || agent.AgentID == host.ID() {return agent.AgentID}}@@ -1228,7 +1228,7 @@ func (e *PulseToolExecutor) findAgentForDockerHost(dockerHost *models.DockerHost// Fall back to hostname matchfor _, agent := range agents {- if agent.Hostname == dockerHost.Hostname {+ if unifiedresources.HostnamesEquivalent(agent.Hostname, dockerHost.Hostname) {return agent.AgentID}}diff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex 9f8c526602..55d4586ed1 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -21,6 +21,7 @@ import ("github.com/golang-jwt/jwt/v5""github.com/gorilla/websocket"+ "github.com/rcourtman/pulse-go-rewrite/internal/agentexec""github.com/rcourtman/pulse-go-rewrite/internal/ai""github.com/rcourtman/pulse-go-rewrite/internal/ai/approval""github.com/rcourtman/pulse-go-rewrite/internal/ai/chat"@@ -161,6 +162,27 @@ func TestContract_WebSocketTrustedProxyHostedOrigin(t *testing.T) {conn.Close()}+func TestContract_AIRelayTargetHostnameEquivalence(t *testing.T) {+ server := agentexec.NewServer(func(string, string) bool { return true })+ ts := newIPv4HTTPServer(t, http.HandlerFunc(server.HandleWebSocket))+ defer ts.Close()++ conn := registerAgent(t, ts.URL, "agent-1", "prox97.seftic.local")+ defer conn.Close()++ adapter := &agentCommandAdapter{handler: &AISettingsHandler{agentServer: server}}++ if got := adapter.FindAgentForTarget("prox97"); got != "agent-1" {+ t.Fatalf("FindAgentForTarget(%q) = %q, want agent-1", "prox97", got)+ }+ if got := adapter.FindAgentForTarget("prox97.seftic.local"); got != "agent-1" {+ t.Fatalf("FindAgentForTarget(%q) = %q, want agent-1", "prox97.seftic.local", got)+ }+ if got := adapter.FindAgentForTarget("prox97.other.local"); got != "" {+ t.Fatalf("FindAgentForTarget(%q) = %q, want empty for distinct FQDN", "prox97.other.local", got)+ }+}+func TestContract_WireAIChatDependencies_WiresTrueNASAppActionProvider(t *testing.T) {router := &Router{trueNASPoller: monitoring.NewTrueNASPoller(nil, 0, nil),diff --git a/internal/api/router_routes_ai_relay.go b/internal/api/router_routes_ai_relay.goindex d38a030d71..edc8ab6b2b 100644--- a/internal/api/router_routes_ai_relay.go+++ b/internal/api/router_routes_ai_relay.go@@ -12,6 +12,7 @@ import ("github.com/rcourtman/pulse-go-rewrite/internal/ai/approval""github.com/rcourtman/pulse-go-rewrite/internal/ai/chat""github.com/rcourtman/pulse-go-rewrite/internal/config"+ "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources""github.com/rcourtman/pulse-go-rewrite/pkg/aicontracts""github.com/rcourtman/pulse-go-rewrite/pkg/auth""github.com/rcourtman/pulse-go-rewrite/pkg/extensions"@@ -581,10 +582,11 @@ func (a *agentCommandAdapter) FindAgentForTarget(targetHost string) string {}if targetHost != "" {for _, agent := range agents {- if agent.Hostname == targetHost || agent.AgentID == targetHost {+ if unifiedresources.HostnamesEquivalent(agent.Hostname, targetHost) || agent.AgentID == targetHost {return agent.AgentID}}+ return ""}if len(agents) == 1 {return agents[0].AgentIDdiff --git a/internal/servicediscovery/deep_scanner.go b/internal/servicediscovery/deep_scanner.goindex e804caa948..9e7232b671 100644--- a/internal/servicediscovery/deep_scanner.go+++ b/internal/servicediscovery/deep_scanner.go@@ -7,6 +7,7 @@ import ("time""github.com/google/uuid"+ "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources""github.com/rs/zerolog/log")@@ -465,7 +466,7 @@ func (s *DeepScanner) findAgentForTarget(targetID, hostname string) string {// Then try hostname matchfor _, agent := range agents {- if agent.Hostname == hostname || agent.Hostname == targetID {+ if unifiedresources.HostnamesEquivalent(agent.Hostname, hostname) || unifiedresources.HostnamesEquivalent(agent.Hostname, targetID) {return agent.AgentID}}