From 7e287f29f996bda3e9c7eade60f3f9986a170a29 Mon Sep 17 00:00:00 2001 From: "OpenGenesis (MPL 2.0)" <153564363+opengenesislink@users.noreply.github.com> Date: Tue, 20 Oct 2026 22:52:44 +0200 Subject: [PATCH] test(hg-friends): enforce bounded relog retry, no false offline, requested-only foreign status --- tools/ci/verify_hg_friends_reconnect_09312.py | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/tools/ci/verify_hg_friends_reconnect_09312.py b/tools/ci/verify_hg_friends_reconnect_09312.py index a074bf87..1e1c688d 100644 --- a/tools/ci/verify_hg_friends_reconnect_09312.py +++ b/tools/ci/verify_hg_friends_reconnect_09312.py @@ -42,4 +42,46 @@ assert body.count("userdata.ServerURLs = null;") >= 6 assert body.count('serverType.Equals("FriendsServerURI", StringComparison.OrdinalIgnoreCase)') >= 4 assert body.count("userdata.LastWebFail = Util.GetTimeStamp();") >= 6 assert "BADURLEXPIRE * 1000" in body -print("OGL HG friends: all-presence delivery, duplicate guard, recoverable URL cache: OK") +# A foreign home-grid may not be reachable on the *first* status +# lookup at viewer login. Confirm that delayed reconciliation is bounded, +# does not invent online status, does not refresh local users, and never +# publishes a foreign UUID not present in the requested friend list. +module = read("OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs") +for marker in ( + "using System.Threading.Tasks;", + "PresenceRetrySeconds", + "PresenceRetryAttempts", + "PendingForeignPresence(client.AgentId).Count > 0", + "_ = RetryForeignPresenceAsync(client);", + "private List PendingForeignPresence(UUID owner)", + "(friend.TheirFlags & (int)FriendRights.CanSeeOnline) == 0", + "IsFriendOnline(owner, friendId)", + "private async Task RetryForeignPresenceAsync(IClientAPI client)", + "await Task.Delay(TimeSpan.FromSeconds(retrySeconds))", + "LocateClientObject(owner) != client", + "GetOnlineFriends(owner, pending, online)", + "client.SendAgentOnline(online.ToArray())", + "HashSet requested = new();", + "if (!requested.Contains(friendID))", +): + assert marker in module, "HG foreign reconnect reconciliation missing: " + marker +assert "m_HGPresenceRetryAttempts = Math.Clamp(" in module +assert "0, 4);" in module, "foreign status requests need a hard retry bound" +retry = module.split("private async Task RetryForeignPresenceAsync", 1)[1].split( + "protected override void GetOnlineFriends", 1)[0] +assert retry.index("LocateClientObject(owner) != client") < retry.index("GetOnlineFriends(owner, pending, online)") +assert retry.index("GetOnlineFriends(owner, pending, online)") < retry.index("client.SendAgentOnline(online.ToArray())") +assert "SendAgentOffline" not in retry, "an unreachable HG grid must not be treated as proven offline" +getonline = module.split("protected override void GetOnlineFriends", 1)[1].split( + "protected override void StatusNotify", 1)[0] +assert getonline.index("HashSet requested") < getonline.index("connector.StatusNotification(") +assert getonline.index("if (!requested.Contains(friendID))") < getonline.index("friends.Add(friendID);") + +for path in ("bin/config-include/GridCommon.ini", + "bin/config-include/GridCommon.ini.example", + "bin/config-include/StandaloneCommon.ini.example"): + cfg = read(path).split("[HGFriendsModule]", 1)[1].split("\n[", 1)[0] + assert "PresenceRetrySeconds = 135" in cfg, path + assert "PresenceRetryAttempts = 3" in cfg, path + +print("OGL HG friends: all-presence delivery, duplicate guard, recoverable URL cache, bounded relog presence retries: OK")