diff --git a/NexVerse/Core/ControlPlane/NexNodeRegistry.cs b/NexVerse/Core/ControlPlane/NexNodeRegistry.cs index 1e20bf94..6c7799ac 100644 --- a/NexVerse/Core/ControlPlane/NexNodeRegistry.cs +++ b/NexVerse/Core/ControlPlane/NexNodeRegistry.cs @@ -19,8 +19,10 @@ namespace NexVerse.Core.ControlPlane int sizeX, int sizeY, int agentCount, - DateTimeOffset lastSeen) + DateTimeOffset lastSeen, + int npcCount = 0) { + NpcCount = Math.Clamp(npcCount, 0, Math.Max(0, agentCount)); RegionId = regionId ?? string.Empty; Name = name ?? string.Empty; ServerUri = serverUri ?? string.Empty; @@ -36,6 +38,7 @@ namespace NexVerse.Core.ControlPlane public int SizeX { get; } public int SizeY { get; } public int AgentCount { get; } + public int NpcCount { get; } public DateTimeOffset LastSeen { get; } } @@ -72,8 +75,10 @@ namespace NexVerse.Core.ControlPlane IReadOnlyList regions, string updateState = "", string updateOperationId = "", - DateTimeOffset? updateAt = null) + DateTimeOffset? updateAt = null, + int npcCount = 0) { + NpcCount = Math.Clamp(npcCount, 0, Math.Max(0, agentCount)); NodeId = nodeId ?? string.Empty; Hostname = hostname ?? string.Empty; ServerVersion = serverVersion ?? string.Empty; @@ -121,6 +126,7 @@ namespace NexVerse.Core.ControlPlane public long DiskTotalBytes { get; } public int RegionCount { get; } public int AgentCount { get; } + public int NpcCount { get; } public bool ManagedRegionCommands { get; } public bool CrossRegionObjectMessaging { get; } public bool CrossOwnerObjectMessaging { get; } @@ -269,6 +275,9 @@ namespace NexVerse.Core.ControlPlane ApplyRegionOnline( nexEvent); break; + case "region.presence": + ApplyRegionPresence(nexEvent); + break; case "region.offline": ApplyRegionOffline( @@ -358,6 +367,8 @@ namespace NexVerse.Core.ControlPlane nexEvent, "agent_count", value => record.AgentCount = value); + AssignInt(nexEvent, "npc_count", value => + record.NpcCount = Math.Clamp(value, 0, Math.Max(0, record.AgentCount))); AssignBool(nexEvent, "maintenance_mode", value => record.MaintenanceMode = value); AssignBool(nexEvent, "draining", value => record.Draining = value); AssignBool( @@ -494,8 +505,10 @@ namespace NexVerse.Core.ControlPlane "agent_count", out int agentCount)) { - region.AgentCount = agentCount; + region.AgentCount = Math.Max(0, agentCount); } + if (TryParseInt(nexEvent, "npc_count", out int npcCount)) + region.NpcCount = Math.Clamp(npcCount, 0, region.AgentCount); region.LastSeen = receivedAt; @@ -513,6 +526,26 @@ namespace NexVerse.Core.ControlPlane } } + // A compact, current presence update delivered alongside each node heartbeat. + // Never resurrect regions which were removed or mark offline nodes online. + private void ApplyRegionPresence(NexEvent ev) + { + if (!TryData(ev, "node_id", out string nodeId) || + !TryData(ev, "region_id", out string regionId) || + !TryParseInt(ev, "agent_count", out int agents) || + !TryParseInt(ev, "npc_count", out int npcs) || + !m_Nodes.TryGetValue(nodeId, out NodeRecord record)) + return; + lock (record.Sync) + { + if (record.ExplicitOffline || !record.Regions.TryGetValue(regionId, out RegionRecord region)) + return; + region.AgentCount = Math.Max(0, agents); + region.NpcCount = Math.Clamp(npcs, 0, region.AgentCount); + region.LastSeen = DateTimeOffset.UtcNow; + } + } + private void ApplyRegionOffline( NexEvent nexEvent) { @@ -650,7 +683,8 @@ namespace NexVerse.Core.ControlPlane region.SizeX, region.SizeY, region.AgentCount, - region.LastSeen)) + region.LastSeen, + region.NpcCount)) .ToArray(); return new NexNodeSnapshot( @@ -686,7 +720,8 @@ namespace NexVerse.Core.ControlPlane regions, record.UpdateState, record.UpdateOperationId, - record.UpdateAt); + record.UpdateAt, + record.NpcCount); } } @@ -973,6 +1008,7 @@ namespace NexVerse.Core.ControlPlane public long DiskTotalBytes; public int RegionCount; public int AgentCount; + public int NpcCount; public bool ManagedRegionCommands; public bool CrossRegionObjectMessaging; public bool CrossOwnerObjectMessaging; @@ -1015,6 +1051,7 @@ namespace NexVerse.Core.ControlPlane public int SizeX; public int SizeY; public int AgentCount; + public int NpcCount; public DateTimeOffset LastSeen; } } diff --git a/NexVerse/RegionModules/NodeAgent/NexVerseNodeAgentModule.cs b/NexVerse/RegionModules/NodeAgent/NexVerseNodeAgentModule.cs index 52b67ec6..773d5bc3 100644 --- a/NexVerse/RegionModules/NodeAgent/NexVerseNodeAgentModule.cs +++ b/NexVerse/RegionModules/NodeAgent/NexVerseNodeAgentModule.cs @@ -1364,6 +1364,10 @@ namespace NexVerse.RegionModules.NodeAgent "node.heartbeat", "nexverse.simulator", NodeData())); + // Keep per-region NPC and total avatar presence fresh rather than + // relying on the count captured at region startup. + foreach (Scene scene in m_Scenes.Values.ToArray()) + PublishRegionEvent("region.presence", scene); } catch (Exception e) { @@ -1375,6 +1379,7 @@ namespace NexVerse.RegionModules.NodeAgent { Scene[] scenes = m_Scenes.Values.ToArray(); int agents = scenes.Sum(x => x.GetRootAgentCount()); + int npcs = scenes.Sum(x => x.GetRootNPCCount()); LunaTextureNodeSummary lunaTexture = CollectLunaTextureDiagnostics(scenes); @@ -1396,6 +1401,7 @@ namespace NexVerse.RegionModules.NodeAgent ["disk_total_bytes"] = drive.TotalSize.ToString(), ["region_count"] = scenes.Length.ToString(), ["agent_count"] = agents.ToString(), + ["npc_count"] = npcs.ToString(), ["maintenance_mode"] = m_MaintenanceMode.ToString(), ["draining"] = m_Draining.ToString(), ["update_staging_enabled"] = m_UpdateStagingEnabled.ToString(), @@ -1531,7 +1537,8 @@ namespace NexVerse.RegionModules.NodeAgent ["server_uri"] = scene.RegionInfo.ServerURI ?? string.Empty, ["size_x"] = scene.RegionInfo.RegionSizeX.ToString(), ["size_y"] = scene.RegionInfo.RegionSizeY.ToString(), - ["agent_count"] = scene.GetRootAgentCount().ToString() + ["agent_count"] = scene.GetRootAgentCount().ToString(), + ["npc_count"] = scene.GetRootNPCCount().ToString() })); } diff --git a/NexVerse/Server/Api/NexApiDocsPage.cs b/NexVerse/Server/Api/NexApiDocsPage.cs index f4ec6bc9..23e1879f 100644 --- a/NexVerse/Server/Api/NexApiDocsPage.cs +++ b/NexVerse/Server/Api/NexApiDocsPage.cs @@ -677,7 +677,8 @@ body.ogl-sidebar-collapsed .ogl-admin-header,body.ogl-sidebar-collapsed main{gri
Registriert
–
lokale Einwohnerkonten
-
Gerade online
–
Einwohner + Hypergrid
+
Gerade online
–
Einwohner + Hypergrid + NPCs
+
NPCs online
–
in Regionen anwesende NPC-Avatare
Einwohner online
–
auf diesem Grid
Aktiv letzte 7 Tage
–
eindeutige Einwohner
Aktiv letzte 30 Tage
–
eindeutige Einwohner
@@ -686,7 +687,7 @@ body.ogl-sidebar-collapsed .ogl-admin-header,body.ogl-sidebar-collapsed main{gri
HG letzte 30 Tage
–
eindeutige Besucher
-

Gerade online

Lokale Einwohner und Hypergrid-Besucher mit aktuell ermittelter Region.

+

Angemeldete Benutzer

Lokale Einwohner und Hypergrid-Besucher mit aktiver Anmeldung. NPCs zaehlen zur Gesamtanzeige und Regionsbelegung, haben aber keine Login-Sitzung.

NameTypRegionHeimat-GridLogin
@@ -694,8 +695,8 @@ body.ogl-sidebar-collapsed .ogl-admin-header,body.ogl-sidebar-collapsed main{gri
Heimat-GridBekanntOnline7 Tage30 Tage
-

Regionen jetzt

Aktuelle Belegung nach Region, getrennt nach lokalen Einwohnern und Hypergrid-Besuchern.

-
RegionGesamtEinwohnerHypergrid
+

Regionen jetzt

Aktuelle Avatar-Belegung je Region inklusive NPCs. Diese Details sind nur mit statistics:read sichtbar.

+
RegionGesamtEinwohnerHypergridNPCs

Datenbasis

Statistik noch nicht geladen.
@@ -1810,6 +1811,7 @@ function renderStatistics(data){ oglGithubText('dashResidents',residents.registered_total==null?'–':residents.registered_total); oglGithubText('dashOnline',online.total==null?'–':online.total); statText('statOnlineTotal',online.total); + statText('statNpcOnline',online.npcs); statText('statResidentsOnline',residents.online_now); statText('statActive7',residents.active_last_7_days); statText('statActive30',residents.active_last_30_days); @@ -1839,10 +1841,10 @@ function renderStatistics(data){ appendStatsRow('statsHgBody',[originLabel,'','','','']); } $('statsRegionBody').replaceChildren(); - (data.regions||[]).forEach(item=>appendStatsRow('statsRegionBody',[ - item.region_name||item.region_id,item.online_total,item.residents,item.hypergrid + (data.region_online_users||[]).forEach(item=>appendStatsRow('statsRegionBody',[ + item.region_name||item.region_id,item.online_total,item.residents,item.hypergrid,item.npcs??0 ])); - if(!(data.regions||[]).length)appendStatsRow('statsRegionBody',[protectedDetails?'Keine Online-Belegung':'Geschützte Details – statistics:read erforderlich','','','']); + if(!(data.region_online_users||[]).length)appendStatsRow('statsRegionBody',[protectedDetails?'Keine Online-Belegung':'Geschützte Details – statistics:read erforderlich','','','','']); const states=Object.fromEntries(Object.entries(data.account_states||{}).map(([k,v])=>[accountStateLabels[k]||k,v])); const quality=data.data_quality||{}; const qualityValues={ diff --git a/NexVerse/Server/Api/NexNodeApi.cs b/NexVerse/Server/Api/NexNodeApi.cs index cac9ae33..fc4a8a1f 100644 --- a/NexVerse/Server/Api/NexNodeApi.cs +++ b/NexVerse/Server/Api/NexNodeApi.cs @@ -332,6 +332,8 @@ namespace NexVerse.Server.Api node.RegionCount, agent_count = node.AgentCount, + npc_count = + node.NpcCount, managed_region_commands = node.ManagedRegionCommands, cross_region_object_messaging = @@ -372,6 +374,8 @@ namespace NexVerse.Server.Api region.SizeY, agent_count = region.AgentCount, + npc_count = + region.NpcCount, last_seen = region.LastSeen }).ToArray() diff --git a/NexVerse/Server/Api/NexStatisticsApi.cs b/NexVerse/Server/Api/NexStatisticsApi.cs index 7c13cab0..2bf471be 100644 --- a/NexVerse/Server/Api/NexStatisticsApi.cs +++ b/NexVerse/Server/Api/NexStatisticsApi.cs @@ -8,6 +8,7 @@ using System.Text; using System.Text.Json; using log4net; using NexVerse.Core; +using NexVerse.Core.ControlPlane; using NexVerse.Core.Security; using OpenMetaverse; using OpenSim.Data; @@ -28,6 +29,7 @@ namespace NexVerse.Server.Api private readonly IGridService m_Grid; private readonly IRegionData m_RegionData; private readonly IAssetService m_Assets; + private readonly NexNodeRegistry m_Nodes; private readonly NexApiAuthenticator m_Authenticator; private readonly bool m_AllowPublicAggregates; @@ -39,7 +41,8 @@ namespace NexVerse.Server.Api NexApiAuthenticator authenticator, bool allowPublicAggregates, IRegionData regionData = null, - IAssetService assets = null) + IAssetService assets = null, + NexNodeRegistry nodes = null) { m_UserAccounts = userAccounts; m_GridUsers = gridUsers; @@ -47,6 +50,7 @@ namespace NexVerse.Server.Api m_Grid = grid; m_RegionData = regionData; m_Assets = assets; + m_Nodes = nodes; m_Authenticator = authenticator; m_AllowPublicAggregates = allowPublicAggregates; } @@ -244,21 +248,60 @@ namespace NexVerse.Server.Api .ThenBy(x => x.Name, StringComparer.OrdinalIgnoreCase) .ToList(); + // NPCs are real in-world avatar presences, but not authenticated + // GridUser sessions. Merge them into public online totals without + // inventing login sessions or duplicate UserAccount records. + NexNodeSnapshot[] onlineNodes = m_Nodes?.List() + .Where(node => node.State == "online").ToArray(); + int? npcOnline = onlineNodes == null + ? null : onlineNodes.Sum(node => Math.Max(0, node.NpcCount)); + int? avatarsPresent = onlineNodes == null + ? null : onlineNodes.Sum(node => Math.Max(0, node.AgentCount)); + + // Include NPC-only regions in authenticated per-region statistics. + // If a region is temporarily reported by two nodes, use the + // freshest authoritative presence update to avoid duplicate NPCs. + var npcRegions = onlineNodes == null + ? Enumerable.Empty() + : onlineNodes.SelectMany(node => node.Regions) + .Where(region => region.NpcCount > 0 && + Guid.TryParse(region.RegionId, out _)) + .GroupBy(region => region.RegionId, StringComparer.OrdinalIgnoreCase) + .Select(group => group.OrderByDescending(region => region.LastSeen).First()); + object[] regionBreakdown = - allOnline.GroupBy(x => x.RegionId) - .Select(group => new - { - region_id = group.Key.IsZero() ? string.Empty : group.Key.ToString(), - region_name = group.Select(x => x.RegionName) - .FirstOrDefault(x => !string.IsNullOrWhiteSpace(x)) ?? string.Empty, - online_total = group.Count(), - residents = group.Count(x => x.Type == "resident"), - hypergrid = group.Count(x => x.Type == "hypergrid") - }) - .OrderByDescending(x => x.online_total) - .ThenBy(x => x.region_name, StringComparer.OrdinalIgnoreCase) - .Cast() - .ToArray(); + allOnline.Select(record => new + { + RegionId = record.RegionId.ToString(), + RegionName = record.RegionName, + Residents = record.Type == "resident" ? 1 : 0, + Hypergrid = record.Type == "hypergrid" ? 1 : 0, + Npcs = 0 + }) + .Concat(npcRegions.Select(region => new + { + RegionId = region.RegionId, + RegionName = region.Name, + Residents = 0, + Hypergrid = 0, + Npcs = region.NpcCount + })) + .GroupBy(item => item.RegionId, StringComparer.OrdinalIgnoreCase) + .Select(group => new + { + region_id = Guid.TryParse(group.Key, out Guid regionGuid) && + regionGuid != Guid.Empty ? group.Key : string.Empty, + region_name = group.Select(x => x.RegionName) + .FirstOrDefault(x => !string.IsNullOrWhiteSpace(x)) ?? string.Empty, + online_total = group.Sum(x => x.Residents + x.Hypergrid + x.Npcs), + residents = group.Sum(x => x.Residents), + hypergrid = group.Sum(x => x.Hypergrid), + npcs = group.Sum(x => x.Npcs) + }) + .OrderByDescending(group => group.online_total) + .ThenBy(group => group.region_name, StringComparer.OrdinalIgnoreCase) + .Cast() + .ToArray(); HashSet onlineHypergridKeys = new HashSet( @@ -376,7 +419,15 @@ namespace NexVerse.Server.Api protected_details = includeProtectedDetails, online = new { - total = gridUserAvailable ? allOnline.Count : (int?)null, + // Both user sessions and NPCs are counted in the official + // avatar total. The authenticated user list below contains + // only real identities, never synthetic logins for NPCs. + total = gridUserAvailable + ? allOnline.Count + (npcOnline ?? 0) : (int?)null, + authenticated_users = gridUserAvailable ? allOnline.Count : (int?)null, + npcs = npcOnline, + npc_count_available = onlineNodes != null && onlineNodes.Length > 0, + avatars_present_inworld = avatarsPresent, users = includeProtectedDetails ? allOnline.Select(OnlinePayload).ToArray() : Array.Empty() diff --git a/NexVerse/Server/Api/NexVerseWorldApiConnector.cs b/NexVerse/Server/Api/NexVerseWorldApiConnector.cs index 67c7132a..445ca1f4 100644 --- a/NexVerse/Server/Api/NexVerseWorldApiConnector.cs +++ b/NexVerse/Server/Api/NexVerseWorldApiConnector.cs @@ -1116,7 +1116,8 @@ namespace NexVerse.Server.Api authenticator, true, LoadRegionData(config), - assets); + assets, + nodeRegistry); INexSecurityStore securityStore = new PersistentNexSecurityStore( diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index dfc41819..df2f81c2 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -416,9 +416,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap switch (itemtype) { case (int)GridItemType.AgentLocations: - // Service 6 right now (MAP_ITEM_AGENTS_LOCATION; green dots) + // Service 6 (MAP_ITEM_AGENTS_LOCATION; green dots): NPCs are in-world avatars. - if (m_scene.GetRootAgentCount() <= 1) //own position is not sent + if (m_scene.GetRootAgentCount() <= 1 && m_scene.GetRootNPCCount() == 0) //own position is not sent { mapitem = new mapItemReply( m_regionGlobalX + 1, @@ -435,7 +435,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // Don't send a green dot for yourself if (sp.UUID != remoteClient.AgentId) { - if (sp.IsNPC || sp.IsDeleted || sp.IsInTransit) + if (sp.IsChildAgent || sp.IsDeleted || sp.IsInTransit) return; mapitem = new mapItemReply( @@ -541,7 +541,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // Service 6 right now (MAP_ITEM_AGENTS_LOCATION; green dots) - if (m_scene.GetRootAgentCount() <= 1) // own is not sent + if (m_scene.GetRootAgentCount() <= 1 && m_scene.GetRootNPCCount() == 0) // own is not sent { mapitem = new mapItemReply( m_regionGlobalX + 1, @@ -558,7 +558,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // Don't send a green dot for yourself if (sp.UUID != remoteClient.AgentId) { - if (sp.IsNPC || sp.IsDeleted || sp.IsInTransit) + if (sp.IsChildAgent || sp.IsDeleted || sp.IsInTransit) return; mapitem = new mapItemReply( @@ -1459,7 +1459,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap OSDArray responsearr = new OSDArray(); // Don't preallocate. MT (m_scene.GetRootAgentCount()); m_scene.ForEachRootScenePresence(delegate (ScenePresence sp) { - if (sp.IsNPC || sp.IsDeleted || sp.IsInTransit) + if (sp.IsChildAgent || sp.IsDeleted || sp.IsInTransit) return; OSDMap responsemapdata = new OSDMap(); responsemapdata["X"] = OSD.FromInteger((int)(m_regionGlobalX + sp.AbsolutePosition.X)); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 78a4c0e8..67df1119 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5279,7 +5279,7 @@ Label_GroupsDone: public int GetRootNPCCount() { - return m_sceneGraph.GetRootAgentCount(); + return m_sceneGraph.GetRootNPCCount(); } public int GetChildAgentCount() @@ -6355,9 +6355,11 @@ Environment.Exit(1); etcd.Store("HealthFlags", flags.ToString(), 300000); } + // RootAgents tracks in-world avatar presence, including NPCs. + // Account/login statistics remain based on real user sessions. int roots = 0; foreach (ScenePresence sp in GetScenePresences()) - if (!sp.IsChildAgent && !sp.IsNPC) + if (!sp.IsChildAgent && !sp.IsDeleted && !sp.IsInTransit) roots++; if (m_lastUsers != roots) diff --git a/doc/NexVerse/WORLD_API.md b/doc/NexVerse/WORLD_API.md index 597d5dc1..6f47f1cd 100644 --- a/doc/NexVerse/WORLD_API.md +++ b/doc/NexVerse/WORLD_API.md @@ -148,6 +148,31 @@ These endpoints are public and read-only. Without credentials, the endpoint returns resident/Hypergrid aggregates plus **all locally registered regions from authoritative GridStore** (including offline and reserved records). Public region metadata includes only region UUID, name, position, size and GridStore online flag; it never includes avatars, personal identities, estate owners, simulator connection endpoints or region secrets. Hypergrid link entries are counted separately and excluded from local region totals. The pre-existing avatar-based region online-population breakdown is available only as `region_online_users` with `statistics:read` authentication. Hypergrid home-grid identity details remain protected. +### NPC presence in official avatar statistics (OpenGenesisLINK Gen1) + +Region root presence includes human avatars **and** server-controlled NPC avatars. +The existing `online.total` now counts authenticated residents/Hypergrid visitors +**plus** NPCs observed through the live, signed NexBus simulator heartbeats. +`online.authenticated_users` remains the count of real signed-in users; +`online.npcs` is the NPC contribution. `online.npc_count_available` indicates +whether at least one active node supplied a heartbeat and +`online.avatars_present_inworld` counts all root presences observed on active +simulators (including NPCs). In the absence of node telemetry, +`online.total` continues returning the known signed-in user count instead +of returning a spurious error; `online.npcs` is null when the node registry +is unavailable. Per-region `region_online_users.online_total` also includes +NPCs and contains a distinct `npcs` number; these region details still require +`statistics:read`. + +NPCs also appear as avatar-location green dots on the viewer world map. +The existing `llGetAgentList`, `llGetRegionAgentCount`, and OSSL NPC-aware +scene-presence interfaces continue to operate. NPC identity is **not** converted +into a login session, a GridUser entry, a password, or an API bearer principal. +No administrator, economy, OAuth, Voice/WebRTC, social, or external-grid +privileges are automatically assigned to NPCs. Functions that require a real +viewer client or user account retain those security boundaries. + + `region_summary` gives `registered_total`, `online_total`, `offline_total`, `reserved_total` and `hypergrid_links`. Count fields are `null` when GridStore cannot be read, rather than a misleading 0. `RegionOnline` reflects **GridService registration state**; it is not a separate live network heartbeat and may be stale after a sudden simulator crash. VAR regions count once by region UUID, not by their occupied 256m map cells. `services.grid.status` and `services.asset.status` report `ok`, `degraded` or `unavailable`. Grid service `ok` requires the local GridService and successful GridStore inventory access. Asset service `ok` requires successful read-only `AssetsExist` datastore probing with a nonexistent UUID (both `true` and `false` are valid answers). These checks do not guarantee remote simulator reachability, upload success, disk space or end-to-end asset delivery. Probe failures leave the resident statistics available but set `data_quality.complete=false` and list missing metrics. diff --git a/tools/ci/NexNodeRegistryRegression/Program.cs b/tools/ci/NexNodeRegistryRegression/Program.cs index 6eff6dab..1facb3fd 100644 --- a/tools/ci/NexNodeRegistryRegression/Program.cs +++ b/tools/ci/NexNodeRegistryRegression/Program.cs @@ -43,6 +43,7 @@ internal static class Program ["cpu_seconds"] = "3.500", ["region_count"] = "2", ["agent_count"] = "7", + ["npc_count"] = "2", ["managed_region_commands"] = "true", ["cross_region_object_messaging"] = "true", ["cross_owner_object_messaging"] = "false", @@ -66,6 +67,7 @@ internal static class Program Require(first.Hostname == "sim-a.internal", "hostname mismatch"); Require(first.RegionCount == 2, "heartbeat region count mismatch"); Require(first.AgentCount == 7, "heartbeat agent count mismatch"); + Require(first.NpcCount == 2, "NPCs must be included in root avatar count"); Require(first.ManagedRegionCommands, "managed-region capability mismatch"); Require(first.CrossRegionObjectMessaging, @@ -99,7 +101,8 @@ internal static class Program ["server_uri"] = "http://sim-a.internal:9000/", ["size_x"] = "512", ["size_y"] = "256", - ["agent_count"] = "4" + ["agent_count"] = "4", + ["npc_count"] = "1" })); NexNodeSnapshot owner = @@ -118,6 +121,20 @@ internal static class Program "region.online size metadata mismatch"); Require(alpha.AgentCount == 4, "region.online agent metadata mismatch"); + Require(alpha.NpcCount == 1, + "region.online NPC metadata mismatch"); + + bus.Publish(Event("region.presence", new Dictionary + { + ["node_id"] = "sim-a", + ["region_id"] = "11111111-1111-1111-1111-111111111111", + ["agent_count"] = "5", + ["npc_count"] = "3" + })); + NexNodeRegionSnapshot live = registry.Get("sim-a").Regions.First( + x => x.RegionId == "11111111-1111-1111-1111-111111111111"); + Require(live.AgentCount == 5 && live.NpcCount == 3, + "periodic region.presence must include and refresh NPCs"); bus.Publish(Event( "node.heartbeat", @@ -126,6 +143,7 @@ internal static class Program ["node_id"] = "sim-a", ["region_count"] = "1", ["agent_count"] = "4", + ["npc_count"] = "1", ["luna_texture_diagnostic_count"] = "0", ["luna_texture_occurrence_count"] = "0", ["luna_texture_regions_affected"] = "0", @@ -140,6 +158,8 @@ internal static class Program Require(pruned.Regions.Count == 1, "heartbeat must prune regions no longer reported"); + Require(pruned.NpcCount == 1, + "heartbeat must refresh NPC count without counting twice"); Require(pruned.LunaTextureDiagnosticCount == 0 && pruned.LunaTextureOccurrenceCount == 0 && pruned.LunaTextureRegionsAffected == 0 && diff --git a/tools/ci/verify_statistics_fallback.py b/tools/ci/verify_statistics_fallback.py index accecd78..4d92cc9e 100644 --- a/tools/ci/verify_statistics_fallback.py +++ b/tools/ci/verify_statistics_fallback.py @@ -18,13 +18,24 @@ for marker in ( '"Both GridUser history and complete UserAccount enumeration are unavailable."', 'active_last_7_days = gridUserAvailable', 'online_now = gridUserAvailable ? hypergridOnline.Count : (int?)null', - 'total = gridUserAvailable ? allOnline.Count : (int?)null', + 'total = gridUserAvailable', + 'authenticated_users = gridUserAvailable ? allOnline.Count : (int?)null', + 'npcs = npcOnline', + 'avatars_present_inworld = avatarsPresent', + 'onlineNodes.Sum(node => Math.Max(0, node.NpcCount))', + 'npcRegions.Select(region => new', + 'npcs = group.Sum(x => x.Npcs)', 'missing_metrics = (gridUserAvailable', 'griduser_source = gridUserAvailable ? "available" : "unavailable"', 'complete = gridUserAvailable && completeAccountEnumeration &&', ): assert marker in stats, "Statistics fallback contract missing: " + marker +# Never fabricate sessions or treat NPCs as authenticated users. +assert 'allOnline.Count + (npcOnline ?? 0)' in stats +assert 'allOnline.Select(OnlinePayload)' in stats +assert 'NexNodeRegistry nodes = null' in stats +assert 'nodeRegistry);' in routes assert "m_UserAccounts == null || m_GridUsers == null" not in stats # Full OpenSim HG UUIs must be looked up exactly. Prefixing all lookups