Let daemon reject action bar intent indices

This commit is contained in:
Meta Vens 2026-06-21 12:22:29 +01:00
commit 16b7c9334a
3 changed files with 44 additions and 12 deletions

View file

@ -7692,6 +7692,21 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root)
string.Join(", ", shieldAuthorityHits));
}
var forbiddenActionBarIntentAcceptanceSymbols = new[]
{
"observer == null || !observer.HasAuthoritativeState || equipmentIndex < 0 || behaviorIndex < 0",
"observer == null || !observer.HasAuthoritativeState || weaponGroup < 0"
};
var actionBarIntentAcceptanceHits = forbiddenActionBarIntentAcceptanceSymbols
.Where(symbol => actionGameManager.Contains(symbol, StringComparison.Ordinal))
.ToArray();
if (actionBarIntentAcceptanceHits.Length > 0)
{
throw new InvalidOperationException(
"Unity action-bar intent requests still reject through renderer-local index checks instead of daemon authority: " +
string.Join(", ", actionBarIntentAcceptanceHits));
}
var requiredTargetAuthoritySymbols = new[]
{
"ApplySetTarget(run, command)",

View file

@ -3956,7 +3956,7 @@ public class ActionGameManager : MonoBehaviour
public bool TryRequestDaemonActionBarBehavior(int equipmentIndex, int behaviorIndex, bool active)
{
var observer = ResolveDaemonObserver();
if (observer == null || !observer.HasAuthoritativeState || equipmentIndex < 0 || behaviorIndex < 0)
if (observer == null || !observer.HasAuthoritativeState)
{
return false;
}
@ -3976,7 +3976,7 @@ public class ActionGameManager : MonoBehaviour
public bool TryRequestDaemonActionBarWeaponGroup(int weaponGroup, bool active)
{
var observer = ResolveDaemonObserver();
if (observer == null || !observer.HasAuthoritativeState || weaponGroup < 0)
if (observer == null || !observer.HasAuthoritativeState)
{
return false;
}

View file

@ -2423,18 +2423,26 @@ public class DaemonRuntimeDocumentTests
public void DaemonOperationsRejectsWeaponGroupIntentForMissingGroup()
{
var run = RunWithTwoEntities();
var fire = AetheriaRuntimeDaemonCommandDocument.Create(
var negative = AetheriaRuntimeDaemonCommandDocument.Create(
AetheriaRuntimeDaemonCommandKinds.FireWeaponGroup,
"codex",
"session-intents",
33,
"zone.0.entity.0");
fire.WeaponGroup = 99;
negative.WeaponGroup = -1;
var missing = AetheriaRuntimeDaemonCommandDocument.Create(
AetheriaRuntimeDaemonCommandKinds.SetWeaponGroupActive,
"codex",
"session-intents",
34,
"zone.0.entity.0");
missing.WeaponGroup = 99;
missing.ScalarValue = 1.0;
var result = AetheriaRuntimeDaemonOperations.Execute(run, new[] { fire });
var result = AetheriaRuntimeDaemonOperations.Execute(run, new[] { negative, missing });
Assert.AreEqual(0, result.AppliedCommandIds.Count);
Assert.AreEqual(1, result.RejectedCommandIds.Count);
Assert.AreEqual(2, result.RejectedCommandIds.Count);
Assert.AreEqual(0, result.Intents.WeaponGroups.Count);
}
@ -2442,20 +2450,29 @@ public class DaemonRuntimeDocumentTests
public void DaemonOperationsRejectsBehaviorIntentForMissingBehavior()
{
var run = RunWithTwoEntities();
var behavior = AetheriaRuntimeDaemonCommandDocument.Create(
var negative = AetheriaRuntimeDaemonCommandDocument.Create(
AetheriaRuntimeDaemonCommandKinds.SetBehaviorActive,
"codex",
"session-intents",
34,
"zone.0.entity.0");
behavior.EquipmentIndex = 0;
behavior.BehaviorIndex = 99;
behavior.ScalarValue = 1.0;
negative.EquipmentIndex = -1;
negative.BehaviorIndex = 0;
negative.ScalarValue = 1.0;
var missing = AetheriaRuntimeDaemonCommandDocument.Create(
AetheriaRuntimeDaemonCommandKinds.SetBehaviorActive,
"codex",
"session-intents",
35,
"zone.0.entity.0");
missing.EquipmentIndex = 0;
missing.BehaviorIndex = 99;
missing.ScalarValue = 1.0;
var result = AetheriaRuntimeDaemonOperations.Execute(run, new[] { behavior });
var result = AetheriaRuntimeDaemonOperations.Execute(run, new[] { negative, missing });
Assert.AreEqual(0, result.AppliedCommandIds.Count);
Assert.AreEqual(1, result.RejectedCommandIds.Count);
Assert.AreEqual(2, result.RejectedCommandIds.Count);
Assert.AreEqual(0, result.Intents.Behaviors.Count);
}