Files
ThreadPilot/Services/ProcessOperationUserMessages.cs
T
Prime Build bffbdeeccc CPU topology v2 phase 8: add persistent rules engine foundation (#14)
Add persistent rules engine foundation

Introduce the foundation for Apply at process start without adding a background loop, Windows Service, installer changes, registry affinity or anti-cheat bypass behavior.

- Add PersistentProcessRule and PersistentRuleApplyResult models
- Add process-name and executable-path rule matching
- Add PersistentRulesEngine using existing safe affinity and priority services
- Add JSON-backed persistent rule store
- Add safe Apply at process start user-facing copy
- Validate incomplete rules so missing affinity/priority payloads fail safely
- Add tests for matching, CpuSelection, legacy affinity, priority, Realtime guardrails, access denied, protected processes, process exit, disabled rules and storage roundtrip

No process monitor hook, UI management, Windows Service, registry/IFEO expansion, version bump or tag changes.
2026-05-20 16:45:43 +02:00

63 lines
2.9 KiB
C#

namespace ThreadPilot.Services
{
using System.Diagnostics;
internal static class ProcessOperationUserMessages
{
public const string AccessDenied =
"Windows denied this change. The process may require administrator rights or may be protected.";
public const string AntiCheatProtectedLikely =
"The process appears protected by anti-cheat or process protection. ThreadPilot will not try to bypass it.";
public const string AdminClarification =
"Administrator mode may help with normal permission issues, but cannot bypass anti-cheat or protected process restrictions.";
public const string LegacyFallbackBlocked =
"This CPU selection cannot be safely represented by legacy affinity APIs on this topology. CPU Sets are required for this selection.";
public const string InvalidTopology =
"This CPU selection does not match the current CPU topology. Review or recreate the preset.";
public const string ProcessExited =
"The process exited before ThreadPilot could apply the change.";
public const string CpuSetsUnavailable =
"Windows CPU Sets are unavailable or rejected this selection. ThreadPilot will use a safe fallback only when possible.";
public const string HighPriorityWarning =
"High priority can improve responsiveness for some workloads but may reduce system responsiveness.";
public const string RealtimePriorityBlocked =
"Realtime priority is blocked by ThreadPilot because it can make Windows unstable or unresponsive.";
public const string PersistentLaunchTimePriorityNotice =
"Persistent launch-time priority may be supported for normal processes, but it does not bypass protected process or anti-cheat restrictions.";
public const string PersistentRulesDescription =
"Applies saved rules when a matching process starts. Some protected or anti-cheat processes may reject changes. Administrator mode can help with normal permission issues but cannot bypass protection.";
public const string PersistentRulesProtectedProcessWarning =
"The process appears protected by anti-cheat or process protection. ThreadPilot will not try to override it.";
}
internal static class ProcessPriorityGuardrails
{
public static string? GetWarning(ProcessPriorityClass priority) =>
priority == ProcessPriorityClass.High
? ProcessOperationUserMessages.HighPriorityWarning
: null;
public static bool IsBlocked(ProcessPriorityClass priority) =>
priority == ProcessPriorityClass.RealTime;
public static void ThrowIfBlocked(ProcessPriorityClass priority)
{
if (IsBlocked(priority))
{
throw new InvalidOperationException(ProcessOperationUserMessages.RealtimePriorityBlocked);
}
}
}
}