Repository navigation
Preserve MTP report diagnostics and document agent usage - #12282
Conversation
Fixes #12274. Co-authored-by: Copilot App <[email protected]>
Addresses #12275 with version-aware runner, output, reporting and telemetry guidance. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🧪 Test quality review — PR #12282
Compared merge base b3f3c980c480c5d97976d658ac367b1e246502be with head e8eef67cd9d53fce18bd42fee436d720114d55b0. Evidence applies to this head, not every intermediate commit.
Test-value evidence
All entries are static predictions; no paired execution records were available (this workflow does not run tests).
| Contract | Scenario / expected outcome | Test and decisive assertion | Counterfactual (old exception.StackTrace) |
Correct implementation | Evidence |
|---|---|---|---|---|---|
| Nested exceptions keep inner causes in captured trace | Exception with inner exception; trace contains the inner type and message | TryCaptureCore_NestedException_PreservesInnerDiagnosticTrace (4 data rows), Assert.Contains("System.ArgumentException: [INNER_CAUSE]...", trace) |
Unthrown exception: StackTrace is null, so Assert.IsNotNull(trace) fails |
Pass | Static prediction: killed |
| AggregateException branches preserved | Both inner branches appear | TryCaptureCore_AggregateException_PreservesAllInnerDiagnostics, two Assert.Contains |
Null trace, fails | Pass | Static prediction: killed |
| Explanation message plus trace | The explanation stays as the message and the trace has the inner cause | TryCaptureCore_ExplanationWithNestedException_PreservesExplanationAndTrace |
Null trace, fails | Pass | Static prediction: killed |
| Exception without inner keeps the original stack trace | Trace equals exception.StackTrace |
TryCaptureCore_SimpleThrownException_PreservesOriginalStackTrace, Assert.AreEqual |
Passes before and after (behavior-preserving guard) | Pass | Static prediction: passes on both revisions |
| HTML capture truncates the longer trace | Truncated at 32 KiB with a length suffix | TryCapture_NestedException_KeepsDiagnosticTraceBounded, exact equality |
Fails: the old trace is null | Pass | Static prediction: killed |
| End-to-end CTRF/HTML/JUnit reports carry the causes | Causes present in all three reports, none for the simple case | Reports_NestedExceptions_PreserveAssociatedCausesAndExplanations, per-report Assert.Contains and absence checks |
Old behavior loses the causes, fails | Pass | Static prediction: killed |
AGENTS.md, docs, PACKAGE.md |
Documentation only | n/a | n/a | n/a | Not applicable |
🧵 Parallel safety
STATUS: CLEAN. No findings (Critical=0, High=0, Warning=0, Info=0).
| Test assembly | Scope | Workers | Analyzer coverage |
|---|---|---|---|
| Microsoft.Testing.Platform.Acceptance.IntegrationTests | New ReportExceptionDiagnosticsTests (one method, per-test TempDirectory) |
Not determined; no configuration changes | Manual review only |
| Microsoft.Testing.Extensions.UnitTests | TestResultCaptureHelperTests.cs 210-318 (local objects only) |
Not determined; no configuration changes | Manual review only |
The specialist did not read the helper source for static state. Only the changed test ranges were checked.
Per-test assessment
Pseudo-mutation evidence below consists of static predictions, not executed mutation results.
| Result | Quality | Test | Notes | How to improve |
|---|---|---|---|---|
| Pass | A (90–100) | new ReportExceptionDiagnosticsTests.Reports_NestedExceptions_PreserveAssociatedCausesAndExplanations |
Asserts identities, outcomes, messages and causes across all three report formats. | None |
| Pass | A (90–100) | new TestResultCaptureHelperTests.TryCapture_NestedException_KeepsDiagnosticTraceBounded |
Exact equality on the truncated trace. | None |
| Pass | B (80–89) | new TestResultCaptureHelperTests.TryCaptureCore_NestedException_PreservesInnerDiagnosticTrace |
Covers four states, with the inner cause asserted. | None |
| Pass | B (80–89) | new TestResultCaptureHelperTests.TryCaptureCore_AggregateException_PreservesAllInnerDiagnostics |
Both aggregate branches are asserted. | None |
| Pass | B (80–89) | new TestResultCaptureHelperTests.TryCaptureCore_ExplanationWithNestedException_PreservesExplanationAndTrace |
Explanation and inner cause both asserted. | None |
| Pass | B (80–89) | new TestResultCaptureHelperTests.TryCaptureCore_SimpleThrownException_PreservesOriginalStackTrace |
Exact stack trace equality guards the no-inner path. | None |
No inline findings. The production change and tests were checked statically only.
<sub>This advisory review is heuristic and non-blocking.
Re-run the combined review with /review-tests, or only the parallel-safety specialist with /parallel-audit.</sub>
🤖 Automated content by GitHub Copilot. Generated by the Test Quality Review on PR (on open / sync) workflow. · copilot · auto · ~52 AIC · ⌖ ~1 AIC · ⊞ 8K
There was a problem hiding this comment.
🟡 Changes recommended
The documented native MTP command forwards flags to the child that do not disable SDK-rendered ANSI output or progress, so it needs SDK-level --no-ansi --no-progress options before the separator.
1 open issue
What changed in this PR
Preserves nested exception diagnostics in MTP’s existing reports and adds version-aware guidance for agents and CI tools, without changing report schemas or public APIs.
Changes:
- Retains nested and aggregate exception details while preserving framework explanations and ordinary stack traces.
- Adds unit regressions and a packed-consumer test covering five distinct results across CTRF, HTML and JUnit.
- Documents runner modes, diagnostic retrieval and telemetry limits, with discoverable guidance links.
Test-value evidence: The PR reports paired failing/passing runs for production revision d8ae1ef against original source b3f3c9, followed by documentation-only head e8eef67. Execution artifacts remain local and were not independently verified here.
| File | Description |
|---|---|
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/TestResultCaptureHelperTests.cs |
Covers nested causes, aggregate branches, explanations and truncation. |
test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/ReportExceptionDiagnosticsTests.cs |
Checks associated results and diagnostics across three packaged reporters. |
src/Platform/SharedExtensionHelpers/TestResultCaptureHelper.cs |
Captures full exception text when inner exceptions exist. |
src/Platform/Microsoft.Testing.Extensions.JUnitReport/PACKAGE.md |
Documents preserved failure diagnostics. |
src/Platform/Microsoft.Testing.Extensions.HtmlReport/PACKAGE.md |
Documents nested diagnostic traces. |
src/Platform/Microsoft.Testing.Extensions.CtrfReport/PACKAGE.md |
Explains trace preservation and message precedence. |
docs/README.md |
Adds the agent/CI guide to the index. |
docs/mtp-for-agents.md |
Adds runner, output, reporting and telemetry guidance. |
AGENTS.md |
Links contribution instructions and consumer guidance outside the managed block. |
Review effort: Balanced
There was a problem hiding this comment.
🧪 Test quality review — PR #12282
Compared merge base b3f3c980c480c5d97976d658ac367b1e246502be with head 7c5d3099bbd76426a58327e38ab3d426c50a7559. Evidence applies to this head, not every intermediate commit. Since the previously reviewed head e8eef67, only docs/mtp-for-agents.md changed, so the earlier test analysis still applies.
Test-value evidence
All entries are static predictions. No paired execution records were accessible.
| Contract | Scenario / expected outcome | Test and decisive assertion | Counterfactual (old exception.StackTrace) |
Correct implementation | Evidence |
|---|---|---|---|---|---|
| Nested exceptions keep inner causes in the captured trace | Inner exception cause appears in the trace for failed, error, timeout and cancelled states | TryCaptureCore_NestedException_PreservesInnerDiagnosticTrace (4 data rows), Assert.Contains on the inner cause |
The exception was never thrown, so StackTrace is null and Assert.IsNotNull(trace) fails |
Pass | Static prediction: killed |
| AggregateException branches preserved | Both branches appear in the trace | TryCaptureCore_AggregateException_PreservesAllInnerDiagnostics, two Assert.Contains |
Null trace fails | Pass | Static prediction: killed |
| Explanation message kept, trace carries the cause | Message is the explanation; trace has the inner cause | TryCaptureCore_ExplanationWithNestedException_PreservesExplanationAndTrace |
Null trace fails | Pass | Static prediction: killed |
| Exception without an inner exception keeps its original stack trace | Trace equals exception.StackTrace |
TryCaptureCore_SimpleThrownException_PreservesOriginalStackTrace, Assert.AreEqual |
Passes before and after | Pass | Static prediction: passes on both revisions |
| HTML capture bounds the longer trace | Truncated at 32 KiB with a length suffix | TryCapture_NestedException_KeepsDiagnosticTraceBounded, exact equality |
Null trace fails | Pass | Static prediction: killed |
| CTRF, HTML and JUnit reports carry causes per result | Each result has its own message, type, outcome and causes; the simple case has no trace | Reports_NestedExceptions_PreserveAssociatedCausesAndExplanations, per-report assertions |
Causes are lost, so the assertions fail | Pass | Static prediction: killed |
AGENTS.md, docs, PACKAGE.md |
Documentation only | n/a | n/a | n/a | Not applicable |
🧵 Parallel safety
STATUS: CLEAN, with limited coverage (Critical=0, High=0, Warning=0, Info=0). No parallelization configuration changed.
| Test assembly | Scope | Workers | Analyzer coverage |
|---|---|---|---|
| Microsoft.Testing.Platform.Acceptance.IntegrationTests | New ReportExceptionDiagnosticsTests, one method with a per-test TempDirectory |
Not determined; no configuration changes | Manual review only |
| Microsoft.Testing.Extensions.UnitTests | TestResultCaptureHelperTests.cs 210-318, local objects only |
Not determined; no configuration changes | Manual review only |
Per-test assessment
Pseudo-mutation evidence below consists of static predictions, not executed mutation results.
| Result | Quality | Test | Notes | How to improve |
|---|---|---|---|---|
| Pass | A (90–100) | new ReportExceptionDiagnosticsTests.Reports_NestedExceptions_PreserveAssociatedCausesAndExplanations |
Asserts identities, outcomes, messages and causes across all three reports. | None |
| Pass | A (90–100) | new TestResultCaptureHelperTests.TryCapture_NestedException_KeepsDiagnosticTraceBounded |
Exact equality on the truncated trace. | None |
| Pass | B (80–89) | new TestResultCaptureHelperTests.TryCaptureCore_NestedException_PreservesInnerDiagnosticTrace |
Four states, each with the inner cause asserted. | None |
| Pass | B (80–89) | new TestResultCaptureHelperTests.TryCaptureCore_AggregateException_PreservesAllInnerDiagnostics |
Both aggregate branches asserted. | None |
| Pass | B (80–89) | new TestResultCaptureHelperTests.TryCaptureCore_ExplanationWithNestedException_PreservesExplanationAndTrace |
Explanation and inner cause both asserted. | None |
| Pass | B (80–89) | new TestResultCaptureHelperTests.TryCaptureCore_SimpleThrownException_PreservesOriginalStackTrace |
Exact stack trace equality guards the no-inner path. | None |
No inline findings. The production change and tests were checked statically only.
<sub>This advisory review is heuristic and non-blocking.
Re-run the combined review with /review-tests, or only the parallel-safety specialist with /parallel-audit.</sub>
🤖 Automated content by GitHub Copilot. Generated by the Test Quality Review on PR (on open / sync) workflow. · copilot · auto · ~33 AIC · ⌖ ~1 AIC · ⊞ 8K
This comment has been minimized.
This comment has been minimized.
Retain the upstream JUnit graduation, opt-in and compatibility documentation together with the nested-exception diagnostic contract. Revalidated with the updated pinned SDK and aligned 3.0 packages. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🧪 Test quality review — PR #12282
Compared merge base 19bfd517ba336e27bbeed4967fc5629e956ccc23 with head d6a5ebfb69de10299cc2a3cca0c32602c04abf38. Evidence applies to this head only.
Test-value evidence
| Contract | Scenario / expected | Test and decisive assertion | Counterfactual | Evidence |
|---|---|---|---|---|
Captured stack trace includes inner exceptions (ToString() when InnerException is set) |
Nested, aggregate and explained exceptions keep every cause text in the trace | TryCaptureCore_NestedException_PreservesInnerDiagnosticTrace (4 data rows), ..._AggregateException_..., ..._ExplanationWithNestedException_...: Assert.Contains("[..._CAUSE]", trace). Acceptance test Reports_NestedExceptions_... checks the same in CTRF, HTML and JUnit. |
Old code used exception.StackTrace, which is null for an unthrown exception, so Assert.IsNotNull(trace) fails. |
Static prediction: would fail before the change and pass after. Not executed. |
| Exceptions without an inner exception are unchanged | Thrown simple exception keeps its original StackTrace |
TryCaptureCore_SimpleThrownException_PreservesOriginalStackTrace: Assert.AreEqual(exception.StackTrace, ...) |
Always using ToString() would add the type and message and fail the equality check. |
Static prediction: passes before and after. |
| HTML capture truncates the longer trace | 40k-character inner message is cut to 32 KiB plus a marker | TryCapture_NestedException_KeepsDiagnosticTraceBounded: exact equality with the expected truncated string |
Without truncation the exact comparison fails. | Static prediction. |
Docs, AGENTS.md and PACKAGE.md changes |
Not executable | None | None | Not applicable |
No paired execution records were available, so none of the above is executed evidence.
🧵 Parallel safety
STATUS: PARTIAL. The specialist subtask was not run in this session. Manual inspection found no shared mutable state: the new acceptance test generates its own TempDirectory and asset, and the unit tests use only local data. This is not a substitute for the specialist analysis.
Per-test assessment
Pseudo-mutation evidence below consists of static predictions, not executed mutation results.
| Result | Quality | Test | Notes | How to improve |
|---|---|---|---|---|
| Pass | A (90–100) | new ReportExceptionDiagnosticsTests.Reports_NestedExceptions_PreserveAssociatedCausesAndExplanations |
Checks per-test identity, outcome, message, type and causes in all three reports. | None |
| Pass | A (90–100) | new TestResultCaptureHelperTests.TryCaptureCore_NestedException_PreservesInnerDiagnosticTrace |
Covers four failure states and asserts the inner cause is in the trace. | None |
| Pass | A (90–100) | new TestResultCaptureHelperTests.TryCaptureCore_AggregateException_PreservesAllInnerDiagnostics |
Asserts both aggregate branches appear in the trace. | None |
| Pass | A (90–100) | new TestResultCaptureHelperTests.TryCaptureCore_ExplanationWithNestedException_PreservesExplanationAndTrace |
Asserts the explanation message and the inner cause together. | None |
| Pass | A (90–100) | new TestResultCaptureHelperTests.TryCaptureCore_SimpleThrownException_PreservesOriginalStackTrace |
Exact equality guards the unchanged no-inner path. | None |
| Pass | A (90–100) | new TestResultCaptureHelperTests.TryCapture_NestedException_KeepsDiagnosticTraceBounded |
Exact expected truncated string including marker and length. | None |
No inline findings.
<sub>This advisory review is heuristic and non-blocking.
Re-run the combined review with /review-tests, or only the parallel-safety specialist with /parallel-audit.</sub>
🤖 Automated content by GitHub Copilot. Generated by the Test Quality Review on PR (on open / sync) workflow. · copilot · auto · ~29 AIC · ⌖ ~1 AIC · ⊞ 8.1K
|
Final test-triage resolution — Azure Pipelines build 1671122 Result: inconclusive (evidence incomplete); no issue created. The
Next step: re-run the Windows Debug leg. If the same four tests fail again, check whether main shows the same failures, then inspect the wait/cancellation helpers around
|

Pull request
Summary
Existing CTRF, HTML and JUnit reports can omit an exception's inner cause when a framework supplies an exception without a flattened explanation. Preserve those diagnostics in the existing reports instead of introducing another JSON format, and consolidate version-aware MTP guidance for agents and CI tools.
AGENTS.mdblock. No runner defaults, report schemas or public APIs change.Fixes #12274
Fixes #12275
Relates to #8824. The separate failure-index evaluation in #8827 is not implemented by this PR.
Design and decision record
This is a focused correctness fix and documentation follow-up, not a new feature requiring a separate design document. The maintained rationale is in the RFC decision record, report-fidelity evidence, and guidance scope.
A new format cannot recover diagnostics discarded during capture. Using the standard exception representation for nested cases avoids a second exception-tree formatter, while leaving ordinary exceptions unchanged. Inner causes belong in the trace; the existing message field continues to prefer the framework's explanation. The guidance distinguishes shipped MTP 2.x behavior from upcoming 3.0 changes, and OTel observability from a complete persisted results ledger. The earlier pilot is limited triage evidence, not proof of model-cost or energy savings.
Demonstration
Opened the actual self-contained HTML generated by the packed net11.0
DiagnosticFrameworkconsumer and expandedNestedFailurein the browser at a 1280 x 721 CSS-pixel viewport. Its inner cause rendered as literal text, including<401>,&and quotes, under the correct result. The disclosure was reachable and the diagnostic block readable. No layout code changed; constrained viewports were not exercised.Sanitized transcript of the inspected result:
The same original-source consumer omitted this diagnostic trace. A text transcript communicates this data-preservation change better than a screenshot containing machine/user metadata. Screenshots and raw logs remain local; no media was uploaded. No hosted CI or IDE UI behavior is being claimed.
Validation and regression proof
Original tested production commit:
d8ae1ef788e7a72fc767ccfca29e58b186ddfa4c. Initial tested heade8eef67cd9d53fce18bd42fee436d720114d55b0adds only the validated guide/index/pointer. Guide-review commit7c5d3099bbd76426a58327e38ab3d426c50a7559corrects native SDK renderer controls. Current headd6a5ebfb69de10299cc2a3cca0c32602c04abf38merges main at19bfd517ba336e27bbeed4967fc5629e956ccc23, retaining both JUnit graduation/compatibility guidance and the nested-diagnostic paragraph. The report helper and both regression-test files remain byte-identical to the pre-merge head.Historical paired regression proof
Counterfactual: original production source
b3f3c980c480c5d97976d658ac367b1e246502bewith identical final regression-test bytes in a separate task-owned checkout. Windows; Release; repository SDK12.0.100-alpha.1.26509.101. Unit hosts: net10.0 and net472. Outer acceptance host: net12.0; generated consumer: net11.0.$evidenceand$resultsdenote isolated local result directories; commands ran from each variant's repository root.Build/pack:
.\build.cmd -c Release -pack -blpassed with exit 0 in both production states. The default desktop-MSBuild path is required for the repository's UAP assets.Unit commands:
Correct implementation: 29 executed/passed per TFM, 0 failed/skipped, exit 0. Original-source net10.0 run: 29 executed, 22 passed, 7 failed at missing diagnostic-trace assertions, 0 skipped, runner exit 2. Existing baseline before the new tests: 21 passed, 0 failed/skipped.
Packed acceptance commands:
Discovery passed and selected the one source-declared case. Correct implementation: 1 executed/passed, 0 failed/skipped, outer exit 0; the intentionally failing child exits 2 after publishing five results. Original packages: the same case executed and failed at
CTRF result 'nested' must retain its nested exception trace., outer exit 2. Fresh TRX execution verification passed for the final green run.Both variants were repacked and restored with separate acceptance caches. Consumer runtime DLL SHA-256 values matched their respective historical package payloads: MTP/CTRF/HTML
3.0.0-devand JUnit1.0.0-dev. Package/cache provenance summaries, paired reports, TRX, logs and available binlogs are retained locally, not publicly hosted; the linked issue evidence contains compact results and limitations. The owned comparison checkout and build-node processes were cleaned up.Post-merge validation
Main updates the pinned SDK to
12.0.100-alpha.1.26556.115and graduates JUnit to the platform-aligned version. After resolving the README conflict, the merged tree was rebuilt and repacked using that declared SDK. No build configuration, CI infrastructure or dependency policy was changed by the conflict resolution..\build.cmd -c Release -pack -bl: passed, exit 0, no warnings/errors.unit-net10.trx/unit-net472.trxin separate result directories.3.0.0-dev; each staged runtime DLL hash matched its freshly packed payload. The earlier task-owned JUnit 1.0 artifact was archived rather than mixed into this feed. Shared package caches were not cleared.This is fresh green validation of the merged toolchain/package state. The earlier red/green runs remain labeled at their original revisions; a new paired red run was not performed with the updated SDK. The PR's own executable behavior and regression assertions are unchanged.
Guide validation
The native SDK command correction was checked against official SDK documentation. All guide PowerShell blocks parsed successfully and
git diff --checkpassed. The retained packed module also exercised SDK-owned renderer switches using:Here
$moduleDirectoryis the retained net11.0 consumer output directory. Five results executed (1 passed, 4 intentionally failed, 0 skipped), the expected runner exit was 2, and captured output contained no ANSI escapes. This validates the SDK switches, not a new product behavior.The managed
AGENTS.mdblock matches the merged upstream block; the repository pointer remains outside it. Other operating systems, release-branch/backport validation and constrained-viewport checks were not run. Local results are not a claim that CI has passed on the current head.Test-value evidence
TryCaptureCore_NestedException_PreservesInnerDiagnosticTrace(failed/error/timeout/cancelled),TryCaptureCore_AggregateException_PreservesAllInnerDiagnostics,TryCaptureCore_ExplanationWithNestedException_PreservesExplanationAndTraceTryCaptureCore_SimpleThrownException_PreservesOriginalStackTraceTryCapture_NestedException_KeepsDiagnosticTraceBoundedReports_NestedExceptions_PreserveAssociatedCausesAndExplanations