Repository navigation
Add typed verbose capture diagnostics across SDKs - #1947
Draft
Richie Gomez (richiemsft) wants to merge 2 commits into
Draft
Richie Gomez (richiemsft) wants to merge 2 commits into
Richie Gomez (richiemsft) wants to merge 2 commits into
Conversation
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
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new .NET V1 ResourceType breaks existing callers that also import System.Security.AccessControl, causing CS0104 ambiguity errors.
5 open issues
Avoid ResourceType name collision in the .NET V1 namespace · New Check diagnostic vocabularies against Rust in the parity gate · New Load diagnostics without initializing the optional NVX runtime · New Preserve loader and missing-symbol errors in setup failures · New Add native-reader coverage for networkEndpoint fields · New
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
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new .NET ResourceType enum breaks compilation for existing callers, and Node diagnostics parsing can fail because it unnecessarily initializes the optional NVX backend.
7 open issues
Avoid ResourceType name collision in the .NET V1 namespace Unsupported-version errors report a nonexistent source location · New Capture tests do not verify the denied file read was captured · New Load diagnostics without initializing the optional NVX runtime Check diagnostic vocabularies against Rust in the parity gate Add native-reader coverage for networkEndpoint fields Preserve loader and missing-symbol errors in setup failures
Review effort: Max
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



📖 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
srcwith the MSVC build environment initialized:cargo test --locked -p mxc-sdk --test capture_diagnostics_apicargo test --locked -p mxc_ffi --lib diagnostics_testsFrom
sdk\node:npm run typechecknpm exec --yes --package=node@24 -- node --test dist-tests\tests\unit\diagnostics.test.jsnpm run buildFrom
sdk\node\tests\integration, withMXC_FFI_DIRpointing tosrc\target\debug:npm run buildnpm exec --yes --package=node@24 -- node --test dist\capture-diagnostics.test.jsnpm 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.jsFrom
sdk\dotnet, run the following for each$frameworkinnet8.0,net10.0, with$nativepointing tosrc\target\debug:dotnet run --project Microsoft.Mxc.Sdk.Tests --framework $framework --no-restore "-p:MxcPrebuiltNativeDir=$native" "-p:MxcTestPrebuiltNativeLibrary=$native\mxc_ffi.dll" -- -class '*.DiagnosticsTests'dotnet run --project Microsoft.Mxc.Sdk.Tests --framework $framework --no-restore "-p:MxcPrebuiltNativeDir=$native" "-p:MxcTestPrebuiltNativeLibrary=$native\mxc_ffi.dll" -- -method '*.CaptureDenials_ReturnsTypedVerboseDiagnosticsWhileReadStaysDenied'dotnet publish Microsoft.Mxc.Sdk.AotSmokeTest -f $framework -c Release -r win-x64 -p:Platform=AnyCPU "-p:MxcPrebuiltNativeDir=$native"& "Microsoft.Mxc.Sdk.AotSmokeTest\bin\Release\$framework\win-x64\publish\Microsoft.Mxc.Sdk.AotSmokeTest.exe"The Windows capture commands use
MXC_E2E_PSEC_CAPABLE_HOST=1andMXC_SKIP_OS_BUILD_DEPENDENT_TESTS=0on a capture-capable host.Additional checks:
git diff HEAD --checkpassed before committing. Pythonyaml.safe_loadsuccessfully parsed all three modified Linux/macOS CI YAMLfiles.
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 lacksmxc_register_runtime_directory; the packaged artifact was left unchanged.The targeted tests above use the fresh native library.
✅ Checklist
feature-acceptedCargo.lock, thedependency-feed-checkcheck passes (see pull request builds)📋 Issue Type
Microsoft Reviewers: Open in CodeFlow