Skip to content

[mxc] - Add Microsoft.Mxc.Sdk and native build support #1473

Description

@JoshuaRowePhantom

Part of #1471

Dependencies

None

Summary

Integrate the source-only Microsoft.Mxc.Sdk into Phantom's normal build and package pipeline for win-x64. Pin the public microsoft/mxc repository at commit 29702c3a408462a4e6be0f265328693a0d2169eb, build its managed SDK plus native unit with Rust 1.93, and preserve dotnet build Phantom.Workspaces.slnx as the developer/CI entry point. Ship only x64 until an independently validated native ARM64 build is available; installation and update flows must reject ARM64 clearly rather than selecting a missing or unenforced artifact.

Root Cause

Phantom has no MXC source dependency, project reference, Rust setup, native-payload copy target, or MXC release validation. Its current build assumes both Windows architectures and single-file publishing, while the MXC SDK builds native host artifacts during MSBuild and rejects a mismatched RID.

  • Phantom.Workspaces/Phantom.Workspaces.csproj:9-27 currently declares <RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers> and enables <PublishSingleFile>true</PublishSingleFile>. There is no MXC reference or payload handling.
  • Phantom.Workspaces/Phantom.Workspaces.csproj:40-69 documents the applicable loose-runtime precedent: PublishSingleFile drops that transitive content from the publish output entirely, then PublishCopilotRuntimeLoose copies runtime files into $(PublishDir)runtimes\$(RuntimeIdentifier)\native. MXC needs equivalent resolver-aware handling for its complete native unit.
  • Directory.Packages.props:1-61 centrally pins package versions (for example, <PackageVersion Include="GitHub.Copilot.SDK" Version="1.0.11" /> at line 35) but contains no MXC package. MXC must be consumed from pinned source; this issue does not assume or claim that an official NuGet package exists.
  • Public MXC source at pinned commit 29702c3a408462a4e6be0f265328693a0d2169eb, sdk/dotnet/Microsoft.Mxc.Sdk/Microsoft.Mxc.Sdk.csproj:4,17-20, targets <TargetFramework>net8.0</TargetFramework> and states that NativeMethods.g.cs is generated at build time by GenerateNativeBindings, which builds mxc_ffi with the dotnetsdk feature. A net8 library is reference-compatible with Phantom's net10 application.
  • The same MXC project at lines 42-57 defines mxc_ffi.dll and plm.exe as the two-file Windows native unit and explains: mxc_engine resolves plm.exe beside the loaded module on Windows.
  • The same MXC project at lines 135-167 rejects RuntimeIdentifier values different from the host RID and invokes rustc -vV followed by cargo build ... --target $(MxcRustHostTriple). Therefore Phantom's current x64-hosted cross-RID ProjectReference publish loop cannot build win-arm64 through this SDK.
  • .github/actions/setup-build/action.yml:1-32 describes and installs only .NET 10 SDK, NuGet package cache, and solution restore; it has no Rust/rustup setup or Cargo cache.
  • .github/workflows/release.yml:56-66,76-104 builds Phantom.Workspaces.slnx, runs existing Copilot gates, then loops over @('win-x64', 'win-arm64'). .github/workflows/publish-validation.yml:1-54 repeats that two-RID publish/package loop.
  • packaging/zip/New-ReleaseZip.ps1:62-97 already computes archive names relative to the publish root because flattening runtimes/<rid>/native breaks runtime resolution. MXC validation must exercise this final ZIP behavior, not only the publish directory.
  • install.ps1:34-42 maps Arm64 to win-arm64. Phantom.Workspaces/Services/Updates/UpdateControllerFactory.cs:90-95 does the same for update asset selection. These paths would request an artifact that this first MXC integration cannot safely produce.
  • README.md:9-13,32-35 and docs/design/build-and-installation.md:11,246-258 advertise both x64 and ARM64 release/publish behavior, so they must be aligned with the temporary x64-only support boundary.

Affected Files

File / Area Required Change
.gitmodules and pinned microsoft/mxc checkout Add the public source dependency at the reviewed commit.
Phantom.Workspaces.slnx Include Microsoft.Mxc.Sdk so the existing solution build remains the entry point.
Phantom.Workspaces.Llm.Core/Phantom.Workspaces.Llm.Core.csproj Add the SDK ProjectReference for the trust-policy/process-executor layer that consumes MXC.
Phantom.Workspaces/Phantom.Workspaces.csproj Restrict publishing to win-x64 and copy the complete resolver-compatible MXC native unit as loose files.
Directory.Packages.props Do not invent a package version; document/validate the source pin through repository tooling instead.
.github/actions/setup-build/action.yml Install public rustup/Rust 1.93 and add appropriate Cargo/Rust caching.
.github/workflows/release.yml Publish only x64 and gate release on MXC payload, native-unit, version, license, and ZIP validation.
.github/workflows/publish-validation.yml Apply the same x64-only MXC publish validation outside releases.
packaging/validate/* Add managed/native version, native-unit, license, resolver-layout, and final-ZIP assertions.
packaging/zip/New-ReleaseZip.ps1 Preserve and validate MXC nested runtime paths without flattening.
install.ps1 Reject ARM64 with an actionable unsupported-architecture error.
Phantom.Workspaces/ManagementModeDispatcher.cs Fail clearly for unsupported ARM64 install/update management modes before launch.
Phantom.Workspaces/Services/Updates/UpdateControllerFactory.cs Stop selecting a win-arm64 update asset and report the support boundary.
README.md Document x64-only availability, Rust prerequisites for source builds, MXC runtime files, and DACL behavior.
docs/design/build-and-installation.md Document the pinned source build, loose native layout, validation gates, architecture boundary, license notices, and DACL behavior.
Phantom.Workspaces.Install.Tests and packaging validation tests Cover architecture rejection, installer/updater selection, native payload, version, and ZIP layout.

Design / Fix

  1. Pin and build public source. Add microsoft/mxc as a repository dependency/submodule pinned to commit 29702c3a408462a4e6be0f265328693a0d2169eb. Reference sdk/dotnet/Microsoft.Mxc.Sdk/Microsoft.Mxc.Sdk.csproj from Phantom.Workspaces.Llm.Core, where the trust-policy and shared executor integration lives. Do not add a fictional Microsoft.Mxc.Sdk package version or claim an official NuGet package exists.
  2. Keep the standard build entry point. Wire the project/solution and MSBuild dependency so dotnet build Phantom.Workspaces.slnx builds generated P/Invoke bindings, mxc_ffi, and plm. Install public Rust 1.93 through rustup for local setup and .github/actions/setup-build/action.yml; cache Cargo registry/git data and target outputs with keys that include the MXC pin, Rust version, lockfile, RID, and configuration where appropriate.
  3. Ship x64 only. Remove win-arm64 from project RID declarations, release and publish-validation matrices, documented downloads, installer selection, and updater selection. On ARM64, fail before download/publish/update with a clear message that MXC-backed releases currently support only win-x64. Native ARM64 support can return in a separate change after host-native build and containment validation.
  4. Preserve the complete loose native unit. Ensure mxc_ffi.dll and plm.exe remain loose, adjacent, and resolvable beside each other after single-file publish. Follow the existing Copilot loose-runtime pattern, but first verify the exact MXC NativeLibraryResolver probe order and required relative layout at the pinned revision rather than assuming the Copilot path applies. Fail the build if either member is absent. Validate the final ZIP retains the chosen nested relative paths.
  5. Gate compatibility and redistribution. Add release and publish-validation checks that run the MXC native unit's relevant upstream tests, verify the managed assembly and native unit report matching versions, assert both native files and required notices, and inspect/extract the final ZIP. The verified upstream license is microsoft/mxc/LICENSE.md and is MIT; copy the required license/notice text unmodified into the redistributed payload after confirming all dependency notices required by the built feature set. Do not create or require an mxc.lic file.
  6. Document accepted runtime mutation. MXC may temporarily mutate filesystem DACLs while establishing policy and is expected to restore them. This behavior is explicitly accepted for this integration; document runtime warnings/failures and restoration expectations, but add no build-time prohibition on DACL mutation.

Expected Tests

Test Name Class What It Verifies
MxcRuntimePayload_RequiredNativeUnit_IsPresent MxcRuntimePayloadTests The x64 publish contains adjacent mxc_ffi.dll and plm.exe at the resolver-verified loose path.
MxcRuntimeZip_NativeUnit_PreservesRelativePaths MxcRuntimeZipTests The final release ZIP preserves both native-unit files at their exact nested relative paths.
MxcSdkVersion_ManagedAndNativeUnits_Match MxcSdkVersionTests The managed SDK and built native unit report the same pinned MXC version.
MxcNativeUnit_WinX64Build_UpstreamTestsPass MxcNativeUnitTests The x64 native unit passes the required upstream MXC tests before packaging.
MxcRuntimePayload_RequiredLicenseNotice_IsPresent MxcRuntimePayloadTests The publish payload includes the verified upstream MIT license and required notices, with no invented mxc.lic.
ReleaseArtifacts_CurrentMatrix_ContainsOnlyWinX64 ReleasePackagingTests Release and validation workflows no longer create a win-arm64 asset.
Install_Arm64Architecture_ReportsUnsupportedArchitecture InstallScriptTests The installer fails clearly on ARM64 instead of selecting a missing x64/ARM64 asset.
ManagementMode_Arm64Architecture_ReportsUnsupportedArchitecture ManagementModeRunnerTests Managed install/update mode rejects unsupported ARM64 before performing work.
UpdateController_Arm64Architecture_ReportsUnsupportedArchitecture UpdateControllerFactoryTests Update selection cannot request a win-arm64 release asset.
BuildSolution_MxcSourceDependency_BuildsThroughStandardEntryPoint BuildIntegrationTests dotnet build Phantom.Workspaces.slnx builds the pinned managed/native MXC units with Rust 1.93.

Activity

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

Metadata

Metadata

Labels

bugSomething isn't workingdiagnosedRoot cause identifiedneeds-slow-testsRequires full test suite including slow Git tests at checkinverified-locallyImplementation has been verified locally

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions