Repository navigation
Fix OpenCode detection and reconcile vendored source baselines - #12174
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🧪 Test quality review — PR #12174
Compared merge base 6075756d0590f3d1643d4fdf4bc03f79684660fd with head ff1e22692d1afaed096bff8185fe1b8fc255a4ea. Evidence applies to this head, not every intermediate commit.
Test-value evidence
All results below are static predictions. No tests were executed, and no paired red/green execution records were available.
- Contract: OpenCode detection changes from
OPENCODE_AItoOPENCODE.- Test:
LLMEnvironmentDetectorTests.IsLLMEnvironment_WhenCheckingOpenCode_ReturnsExpectedResult. OPENCODE=1andOPENCODE=falsemust givetrue(decisive assertion:Assert.AreEqual(expected, ...)).OPENCODEempty or null, andOPENCODE_AI=1, must givefalse.- Counterfactual: with the old
OPENCODE_AIrule, theOPENCODE=1andOPENCODE=falsecases would fail, andOPENCODE_AI=1would wrongly returntrue. This is a static prediction. - Correct implementation: all five cases pass (predicted).
- Test:
- Contract:
AnsiOptionTestsandWellKnownEnvironmentVariablesclearOPENCODEinstead ofOPENCODE_AI.- These are test-infrastructure updates that keep the host process from being detected as an LLM environment. They are covered indirectly. No dedicated counterfactual was assessed.
eng/vendored-files.json: metadata only, so not applicable.
🧵 Parallel safety
STATUS: PARTIAL. The separate specialist task was not run in this session, so parallel-safety coverage is incomplete. This is not a clean result.
Manual check of the changed code, which is not a substitute for the specialist:
- The new test creates its own
Mock<IEnvironment>per call and touches no shared state. - The other two test-side changes only rename an environment-variable string.
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 LLMEnvironmentDetectorTests. |
Data rows cover set, falsy-string, empty, null and the old name. | None |
Pseudo-mutation evidence:
- Reverting the rule to
OPENCODE_AIis likely killed (inferred) by theOPENCODE=1row and theOPENCODE_AI=1row.
No inline findings were published. The helper change to CreateDetector preserves existing AI_AGENT behavior through its default parameter.
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.
🤖 Automated content by GitHub Copilot. Generated by the Test Quality Review on PR (on open / sync) workflow. · copilot · auto · 25.9 AIC · ⌖ 0.824 AIC · ⊞ 7.8K · ◷
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the OpenCode detection and vendored-baseline updates.
No open issues 🎉
What changed in this PR
Fixes Microsoft.Testing.Platform’s OpenCode detection so agent-aware output defaults use OPENCODE, and reconciles the vendored drift reports in #12171 and #12172.
Changes:
- Replaces
OPENCODE_AIwithOPENCODEin detection and acceptance-test environment isolation. - Adds five regression cases covering nonempty, empty, absent, and obsolete variables.
- Updates both upstream baselines and documents why the MSBuild changes require no local code changes.
Test-value evidence: For ff1e22692d1afaed096bff8185fe1b8fc255a4ea, the PR reports three intended pre-fix unit failures followed by 12 passing cases, plus seven passing packaged-consumer scenarios after the fix. Raw artifacts were not available for independent verification; full acceptance-suite and CI execution are not claimed.
| File | Description |
|---|---|
| test/Utilities/Microsoft.Testing.TestInfrastructure/WellKnownEnvironmentVariables.cs | Updates the shared environment-isolation list. |
| test/UnitTests/Microsoft.Testing.Platform.UnitTests/Helpers/LLMEnvironmentDetectorTests.cs | Adds focused OpenCode detection regression cases. |
| test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/AnsiOptionTests.cs | Clears OPENCODE for isolated ANSI tests. |
| src/Platform/Microsoft.Testing.Platform/Helpers/LLMEnvironmentDetector.cs | Detects OpenCode through the upstream variable name. |
| eng/vendored-files.json | Refreshes baseline hashes and adaptation notes. |
Review effort: Balanced
Pull request
Summary
OpenCode sets
OPENCODE, but MTP was still checkingOPENCODE_AI, so OpenCode sessions missed the agent-aware output defaults. Use the upstream variable name, keep acceptance-test environment isolation in sync, and add focused regression cases.Reconcile both vendored drift reports. The MSBuild OpenHarmony changes are outside the copied console-mode method and P/Invokes, so that entry needs only a baseline and adaptation-note update.
Fixes #12171
Fixes #12172
Design and decision record
The existing drift reports contain the upstream diffs and rationale; this is a synchronization fix, not a new feature requiring a separate design record. Follow the SDK's rule rename exactly, including ignoring the obsolete variable. Leave local
NativeMethods.cscode unchanged rather than importing unrelated OS-detection helpers.Demonstration
Paired executions of the existing
AnsiOptionTests.TestAssetFixtureasset against separately packed MTP variants produced the following results.GITHUB_ACTIONS=true, unrelated agent flags andNO_COLORwere cleared, and each child executed exactly one passed result namedTest1with exit 0.OPENCODE=1orOPENCODE=false,--ansi autoOPENCODEabsent or empty,--ansi autoOPENCODE_AI=1,--ansi autoOPENCODE=1,--ansi onOPENCODE=1,--ansi offThese are seven concrete environment/option cases. Text signals are clearer than screenshots for this detector correction; no CLI strings or layout are changed.
Validation and regression proof
Local Windows x64 validation used the pinned SDK
12.0.100-alpha.1.26509.101. Normal project target-framework matrices were built without warnings or errors. The packed consumer targetednet11.0; host traces confirmed the normal roll-forward to runtime12.0.0-alpha.1.26509.101.The following executed commands all exited 0. Only machine-specific scratch paths are parameterized as
$Artifacts.Final detector run: 12 executed, 12 passed, 0 failed, 0 skipped. TRX, JUnit, and CTRF exports were parsed and checked against independent discovery. Manifest validation,
python .github\scripts\check_vendored_files.py validate, exited 0; all 38 detector variables match the acceptance isolation list.Packed-consumer commands and provenance
The existing asset was generated for
net11.0, restored withMicrosoft.Testing.Platformmapped exclusively to the respective variant'sartifacts\packages\Debug\Shippingfeed, and given a fresh.packagescache per variant.$Assetbelow parameterizes that generated asset's directory.Consumer builds and all seven child launches exited 0 in both states. The last command was repeated with the environment/
--ansivalues in the demonstration matrix. Checks independently required the expected ANSI/banner state, the passedTest1identity, and summary counts of total 1, succeeded 1, failed 0, skipped 0.Both variants used package version
2.6.0-dev, but different bits:A9457247249BE0207ABFB91F1DEDB21AEDBDCC3FE361EFB407F7C95B59986DF2.B3D4499C27661C3DD0AA896E59CDE59592D688E1F046AF2FB13D857BDFE8585A.project.assets.json,deps.json, matching packed/cached/consumer DLL hashes, and host-resolution traces confirmed the loaded variant. Consumer project and program bytes were identical across states.Full acceptance-suite and CI execution are not claimed. Raw logs, binlogs, reports, and provenance are retained locally and have not been uploaded.
Test-value evidence
The validated patch is byte-identical to commit
ff1e22692d1afaed096bff8185fe1b8fc255a4ea. The pre-fix comparison used base6075756d0590f3d1643d4fdf4bc03f79684660fdwith the same test/isolation changes retained. Both states built cleanly, were packed separately, and used the same selectors, data, and assertions.IsLLMEnvironment_WhenCheckingOpenCode_ReturnsExpectedResult(five rows)AI_AGENTdetector casesThe pre-fix unit module exited 2 with exactly the
OPENCODE=1,OPENCODE=false, and obsolete-variable assertion failures. The same module exited 0 with all 12 cases passing after the fix. The packaged-check verifier exited 1 before and 0 after; all child hosts still exited 0, so its failures were the intended ANSI/banner assertions, not launch or execution failures.