Skip to content

CPU topology v2 phase 4: add safe CpuSelection affinity apply path#10

Merged
PrimeBuild-pc merged 2 commits into
mainfrom
codex/cpu-topology-v2-phase-4-safe-cpuselection-affinity
May 19, 2026
Merged

CPU topology v2 phase 4: add safe CpuSelection affinity apply path#10
PrimeBuild-pc merged 2 commits into
mainfrom
codex/cpu-topology-v2-phase-4-safe-cpuselection-affinity

Conversation

@PrimeBuild-pc
Copy link
Copy Markdown
Owner

@PrimeBuild-pc PrimeBuild-pc commented May 19, 2026

Summary

  • Adds structured affinity apply result fields and error codes while preserving the existing legacy mask result surface.
  • Adds a safe CpuSelection affinity apply path that tries CPU Sets first and only falls back to legacy ProcessorAffinity when the selection is representable as a non-zero single-group <64 mask.
  • Wires the new ProcessService overload without migrating UI, presets, profiles, or removing the legacy SetProcessorAffinity(long) path.
  • Adds CpuSelection apply audit coverage: CPU Sets success audits success, invalid/unsafe selections audit failure, and legacy fallback continues to audit through the legacy fallback path without a duplicate audit.

Tests

  • dotnet test Tests\ThreadPilot.Core.Tests\ThreadPilot.Core.Tests.csproj --configuration Release --no-restore --filter AffinityApplyServiceTests
  • dotnet test Tests\ThreadPilot.Core.Tests\ThreadPilot.Core.Tests.csproj --configuration Release --no-restore --filter "AffinityApplyServiceTests|ProcessServiceSecurityTests"
  • dotnet test "ThreadPilot_1.sln" --configuration Release --no-restore (206 passed, 0 failed)

Notes

  • UI, preset generation, profiles/core-mask migration, registry/IFEO, priority guardrails, versioning, and tags are intentionally left untouched for later phases.
  • In this phase, ProcessCpuSetHandler.ApplyCpuSelection returns only bool, so a generic false can mean CPU Sets unavailable, access denied without detailed error, or native apply failure. More precise CPU Sets error classification is left for the next UX/error-model phase.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 19, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 60.00000% with 110 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
Services/ProcessService.cs 13.04% 59 Missing and 1 partial ⚠️
Services/AffinityApplyService.cs 75.72% 36 Missing and 14 partials ⚠️

📢 Thoughts on this report? Let us know!

@PrimeBuild-pc PrimeBuild-pc marked this pull request as ready for review May 19, 2026 21:32
@PrimeBuild-pc PrimeBuild-pc merged commit 0895100 into main May 19, 2026
3 checks passed
@PrimeBuild-pc PrimeBuild-pc deleted the codex/cpu-topology-v2-phase-4-safe-cpuselection-affinity branch May 19, 2026 21:35
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cc6b8b6cf0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

failureReason: AffinityApplyFailureReason.InvalidMask);
}

var cpuSetsResult = this.TryApplyCpuSets(process, selection);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Respect CPU Sets toggle before attempting CpuSelection apply

This path always calls TryApplyCpuSets first, so SetUseCpuSets(false) is effectively ignored for CpuSelection requests. In ProcessService, the legacy mask path explicitly gates CPU Sets with useCpuSets, but this new selection path does not, which means users who disable CPU Sets (to avoid compatibility issues) can still hit CPU-Set-specific behavior/errors. The selection apply flow should honor the same toggle and skip CPU Sets entirely when disabled.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants