Skip to content

Add typed verbose capture diagnostics across SDKs - #1947

Draft
Richie Gomez (richiemsft) wants to merge 2 commits into
mainfrom
feature/1874-typed-capture-diagnostics
Draft

Richie Gomez (richiemsft) wants to merge 2 commits into
mainfrom
feature/1874-typed-capture-diagnostics

Conversation

@richiemsft

@richiemsft Richie Gomez (richiemsft) commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

📖 Description

Implement the approved typed verbose capture diagnostics readers in the Rust,
.NET, and Node V1 SDKs. All three use the existing native artifact reader for
versions 3-6, preserving optional fields, property order and duplicates, original
summary flags, and exact 64-bit counts.

Add the C ABI adapter, bounded input-free parsing errors, native allocation
cleanup, .NET source-generated JSON/AOT support, shared fixtures, and public API
documentation. Node retains successfully initialized native bindings while
allowing failed setup to be retried; Unicode validation and .NET UTF-8 transport
avoid unnecessary full-document copies.

Add functional Windows capture scenarios through all three public SDKs, require
their discovery and successful execution in scheduled validation, and select the
native parser/FFI tests in the relevant Linux/macOS jobs. This does not change
capture behavior, backend enforcement, or request schemas.

🔗 References

Refs #1874 (feature-accepted).

Approved design/API specification: #1878 (merged).

🔍 Validation

Validated locally on Windows x64. Node tests use Node 24. Native tests and
managed integration tests use the freshly built debug native library.

From src with the MSVC build environment initialized:

Command Result
cargo test --locked -p mxc-sdk --test capture_diagnostics_api Passed: 6 tests.
cargo test --locked -p mxc_ffi --lib diagnostics_tests Passed: 2 tests.

From sdk\node:

Command Result
npm run typecheck Passed, including the isolated packed-SDK integration build.
npm exec --yes --package=node@24 -- node --test dist-tests\tests\unit\diagnostics.test.js Passed: 5 tests, including failed-setup retry, successful-binding reuse across parse errors, Unicode rejection, and native cleanup. The new cache regression failed before the fix (5 library loads instead of 3) and passed afterward.
npm run build Passed.

From sdk\node\tests\integration, with MXC_FFI_DIR pointing to
src\target\debug:

Command Result
npm run build Passed.
npm exec --yes --package=node@24 -- node --test dist\capture-diagnostics.test.js Passed: 6 real-native parser tests, including Unicode preservation and exact counters.
npm exec --yes --package=node@24 -- node --test --test-name-pattern 'public capture returns typed verbose diagnostics while file access stays denied' dist\windows-process-container.test.js Passed: 1 real Windows capture test, no skips.

From sdk\dotnet, run the following for each $framework in
net8.0, net10.0, with $native pointing to src\target\debug:

Command Result
dotnet run --project Microsoft.Mxc.Sdk.Tests --framework $framework --no-restore "-p:MxcPrebuiltNativeDir=$native" "-p:MxcTestPrebuiltNativeLibrary=$native\mxc_ffi.dll" -- -class '*.DiagnosticsTests' Passed: 8 tests on each framework, including Unicode preservation and invalid UTF-8 rejection without exposing input.
dotnet run --project Microsoft.Mxc.Sdk.Tests --framework $framework --no-restore "-p:MxcPrebuiltNativeDir=$native" "-p:MxcTestPrebuiltNativeLibrary=$native\mxc_ffi.dll" -- -method '*.CaptureDenials_ReturnsTypedVerboseDiagnosticsWhileReadStaysDenied' Passed: 1 real Windows capture test on each framework, no skips.
dotnet publish Microsoft.Mxc.Sdk.AotSmokeTest -f $framework -c Release -r win-x64 -p:Platform=AnyCPU "-p:MxcPrebuiltNativeDir=$native" Passed on both frameworks with the MSVC build environment initialized.
& "Microsoft.Mxc.Sdk.AotSmokeTest\bin\Release\$framework\win-x64\publish\Microsoft.Mxc.Sdk.AotSmokeTest.exe" Passed on both frameworks: JSON paths work with reflection disabled.

The Windows capture commands use MXC_E2E_PSEC_CAPABLE_HOST=1 and
MXC_SKIP_OS_BUILD_DEPENDENT_TESTS=0 on a capture-capable host.

Additional checks: git diff HEAD --check passed before committing. Python
yaml.safe_load successfully parsed all three modified Linux/macOS CI YAML
files.

Limitations: Linux/macOS execution and the full scheduled Windows matrix were
not run locally. A broader Node unit run previously had two native-packaging
failures against the existing stale sdk\node\bin\x64\mxc_ffi.dll, which lacks
mxc_register_runtime_directory; the packaged artifact was left unchanged.
The targeted tests above use the fresh native library.

✅ Checklist

  • Signed the Contributor License Agreement
  • Linked to an issue
  • For features or changes requiring a spec: linked the issue with maintainer-applied feature-accepted
  • Before merging implementation: linked the required maintainer-approved design/API spec, or explained why no spec is required
  • Feature issue remains open unless this PR completes all agreed implementation, validation, and documentation
  • Updated documentation (if applicable)
  • Updated Copilot instructions (if build, architecture, or conventions changed)
  • If this PR changes Cargo.lock, the dependency-feed-check check passes (see pull request builds)

📋 Issue Type

  • Bug fix
  • Feature
  • Task
Microsoft Reviewers: Open in CodeFlow

Implement the approved diagnostics readers for Rust, .NET, and Node with shared artifact parsing, exact counters, bounded errors, functional coverage, and CI integration. Include native binding reuse and UTF-8 allocation fixes from review.

Refs #1874.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7add358a-6560-4267-9ea1-28abe37f5928
Copilot AI max review requested due to automatic review settings December 5, 2026 00:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new .NET V1 ResourceType breaks existing callers that also import System.Security.AccessControl, causing CS0104 ambiguity errors.

5 open issues
What changed in this PR

Adds typed verbose-capture readers to MXC’s Rust, .NET, and Node V1 SDKs, implementing #1874’s design approved in #1878. It reuses native artifact parsing without changing capture policy or request schemas.

Changes:

  • Add version 3–6 readers that preserve classifications, optional fields, and exact 64-bit counts.
  • Add native binding cleanup, safe errors, Node binding reuse, and .NET source-generated JSON support.
  • Extend parser tests, Windows capture validation, CI requirements, and public documentation.
File Description
src/​mxc-sdk/​tests/​streaming_processcontainer.rs Adds public Rust capture validation.
src/​mxc-sdk/​tests/​fixtures/​diagnostics/​verbose-v6.json Covers all current outcome reasons.
src/​mxc-sdk/​tests/​fixtures/​diagnostics/​verbose-v5.json Covers network fields and large counts.
src/​mxc-sdk/​tests/​fixtures/​diagnostics/​verbose-v4.json Covers version-4 diagnostics.
src/​mxc-sdk/​tests/​fixtures/​diagnostics/​verbose-v3.json Covers legacy fields and duplicate properties.
src/​mxc-sdk/​tests/​capture_diagnostics_api.rs Tests Rust parsing and rejection behavior.
src/​mxc-sdk/​src/​lib.rs Exposes V1 diagnostics and binding adapter.
src/​mxc-sdk/​src/​diagnostics.rs Implements typed native-backed readers.
src/​mxc-sdk/​README.md Documents Rust reader usage.
src/​ffi/​mxc_ffi/​src/​lib.rs Registers diagnostics modules.
src/​ffi/​mxc_ffi/​src/​diagnostics.rs Adds panic-contained C ABI reader.
src/​ffi/​mxc_ffi/​src/​diagnostics_tests.rs Tests allocation ownership and safe errors.
src/​ffi/​mxc_ffi/​build.rs Includes diagnostics in binding generation.
sdk/​node/​tests/​unit/​diagnostics.test.ts Tests mapping, cleanup, validation, and caching.
sdk/​node/​tests/​integration/​windows-process-container.test.ts Adds public Node capture validation.
sdk/​node/​tests/​integration/​capture-diagnostics.test.ts Tests Node against the native reader.
sdk/​node/​src/​v1/​index.ts Exports diagnostics APIs and types.
sdk/​node/​src/​v1/​diagnostics.ts Adds typed results and exact-count decoding.
sdk/​node/​src/​bindings/​diagnostics.ts Adds cached bindings and native cleanup.
sdk/​node/​README.md Documents Node usage and loading behavior.
sdk/​node/​package.json Includes diagnostics unit tests.
sdk/​dotnet/​README.md Documents .NET reader usage.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​V1/​MxcDiagnostics.cs Adds immutable diagnostics and native parsing.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​MxcJsonSerialization.cs Registers source-generated diagnostics serialization.
sdk/​dotnet/​Microsoft.Mxc.Sdk.Tests/​MxcProcessTests.cs Adds public .NET capture validation.
sdk/​dotnet/​Microsoft.Mxc.Sdk.Tests/​Microsoft.Mxc.Sdk.Tests.csproj Embeds shared artifact fixtures.
sdk/​dotnet/​Microsoft.Mxc.Sdk.Tests/​DiagnosticsTests.cs Tests parsing, counts, Unicode, and errors.
sdk/​dotnet/​Microsoft.Mxc.Sdk.AotSmokeTest/​Program.cs Checks diagnostics with reflection disabled.
scripts/​ci/​run_backend_validation_tests.ps1 Requires scheduled diagnostics scenarios.
scripts/​ci/​build-windows-sdk-test-bundle.ps1 Stages tests and verifies discovery.
docs/​learning-mode.md Explains typed readers and summary flags.
docs/​development/​build-and-test/​ci-validation-infrastructure.md Documents required diagnostics coverage.
docs/​api-reference/​rust/​v1/​types.md Defines Rust diagnostics types.
docs/​api-reference/​rust/​v1/​api.md Documents Rust reader behavior.
docs/​api-reference/​node/​v1/​types.md Defines Node diagnostics types.
docs/​api-reference/​node/​v1/​api.md Documents Node reader behavior.
docs/​api-reference/​dotnet/​v1/​types.md Defines .NET diagnostics types.
docs/​api-reference/​dotnet/​v1/​api.md Documents .NET reader behavior.
.github/​workflows/​Build.MacOS.Job.yml Selects native FFI diagnostics tests.
.github/​workflows/​Build.Linux.Job.yml Selects Rust and FFI diagnostics tests.
.azure-pipelines/​templates/​Rust.Test.Job.yml Adds diagnostics to Azure Rust validation.

Review effort: Max

public enum AccessType { Read, Write, Execute, Unknown }

/// <summary>Classified resource observed in a signature.</summary>
public enum ResourceType { File, Ui, Network, Capability, Other }
}

/// <summary>Classification of an observed event, distinct from its network decision.</summary>
public enum VerboseLoggingOutcomeReason
function loadDiagnosticsNative() {
let native: ReturnType<typeof loadMxcFfi>;
try {
native = loadMxcFfi();
Comment on lines +53 to +54
} catch {
throw setupError();
assert.equal(parseVerboseLoggingDocument(artifact(6, reason)).signatures[0].signature.reason, reason);
}
const seatbelt = parseVerboseLoggingDocument(artifact(6, VerboseLoggingOutcomeReason.Actionable, 'seatbelt'));
assert.equal(seatbelt.signatures[0].signature.provider, VerboseLoggingProvider.Seatbelt);
Keep the filesystem-probe deadline tests and staged artifacts from main alongside the diagnostics and lifecycle boundary tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7add358a-6560-4267-9ea1-28abe37f5928
Copilot AI max review requested due to automatic review settings December 5, 2026 01:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment on lines +384 to +391
Error::new(
ErrorCode::MalformedRequest,
format!(
"invalid verbose logging document ({category}) at line {}, column {}",
error.line(),
error.column()
),
)
Comment on lines +404 to +408
document.signatures().iter().any(|group| {
group.count() > 0
&& group.signature().reason() == VerboseLoggingOutcomeReason::Actionable
&& group.signature().access_type() == Some(AccessType::Read)
&& group.signature().resource_type() == Some(ResourceType::File)

This branch has not been deployed

No deployments
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