Skip to content

fix(tests): keep tray tests out of real profiles - #1827

Closed
bkudiess wants to merge 1 commit into
mainfrom
bkudiess-tray-test-isolation-guard
Closed

bkudiess wants to merge 1 commit into
mainfrom
bkudiess-tray-test-isolation-guard

Conversation

@bkudiess

@bkudiess bkudiess commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: direct Tray.Tests runs can read or write a developer's real tray profile when no isolation overrides were supplied.

User Impact

User impact: no shipped application behavior changes. Local Tray.Tests processes get isolated defaults before linked application code can cache profile paths.

Why This Change Was Made

A test-only module initializer fills missing profile overrides and rejects explicit real release/dev profile paths before changing the environment. Safe caller overrides remain intact, including the effective legacy-only setup path.

Tray's direct local and roaming resolvers use only OPENCLAW_TRAY_DATA_DIR, so that override is supplied independently even when modern roaming/local roots exist. The modern roots remain available to their own consumers. A small reflection subprocess checks actual static paths without test discovery or application, provider, settings, or logger construction.

The existing settings isolation test now inspects real-file metadata only. Its synthetic owned settings still have exact path and saved-value assertions.

Evidence

Source and final test-evidence review: dedicated independent Claude Opus reviewer cleared commit 734aa41aa11f61c1dcca6f314196bdbc518a7e97 for draft publication, with no P0/P1/P2 findings. This is not application or Gateway runtime proof.

Check Observed result
Focused guard and settings regressions 24 passed, 0 failed, 0 skipped
Negative control removing only [ModuleInitializer] 5 expected failures, 1 pass, 0 skipped
Real profile metadata during focused and negative-control runs Unchanged for release/dev, Roaming/Local
Mandatory final full product build All five projects built; real-profile and source manifests unchanged
Mandatory Shared suite 4,659 passed, 0 failed, 25 existing skips
Mandatory Tray suite 4,497 passed, 0 failed, 0 skipped
Real profile metadata during final build and full suites Unchanged for release/dev, Roaming/Local

Two earlier build intervals saw the real local tray log grow by 365 bytes at 2026-10-22T08:12:59.7561717Z and 2026-10-22T08:21:05.2982567Z. Those intervals overlapped other workstreams and remain unattributed. They are preserved as failed isolation receipts, not erased by later passes. No other real-profile metadata changed. A quiet no-reuse build and the final ordinary environment-only build and full suites did not reproduce the changes. Quiet scheduling and worker isolation changed together, so no specific writer or historical fix is claimed. No real-profile bytes were read, restored, hashed, or deleted.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Required proof pools

  • none: test-process initialization only. No shipped application, native UI, Gateway, installer, or node-command behavior changes.

Validation

Normal commands started with task-owned OPENCLAW_TRAY_DATA_DIR, OPENCLAW_TRAY_APPDATA_DIR, OPENCLAW_TRAY_LOCALAPPDATA_DIR, and the legacy direct OPENCLAW_TRAY_LOCAL_DATA_DIR, plus OPENCLAW_REPO_ROOT and DOTNET_GENERATE_ASPNET_CERTIFICATE=false. Final mandatory commands also set process-local MSBUILDDISABLENODEREUSE=1, DOTNET_CLI_USE_MSBUILD_SERVER=0, and UseSharedCompilation=false; they use unmodified commands, with no PATH shim or shared build-server shutdown. The intentionally empty/partial override inputs are limited to the pure reflection regression children. Build and test commands are serial.

Exact command Result
dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --filter 'FullyQualifiedName~TrayTestProfileIsolationTests|FullyQualifiedName~SettingsManagerIsolationTests.OpenClawTrayDataDirRedirectsSettingsAwayFromRealAppData' --logger 'trx;LogFileName=focused.trx' --results-directory <unique-run-directory> Passed: 24, failed: 0, skipped: 0
dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --filter 'FullyQualifiedName~TrayTestProfileIsolationTests.FreshTestHost' --logger 'trx;LogFileName=focused.trx' --results-directory <unique-negative-control-directory> Initializer removed: 5 expected failures, 1 pass, 0 skipped
pwsh -NoProfile -File .\build.ps1 Final environment-only run passed: Shared, Cli, WinNodeCli, SetupEngine, WinUI. Profile and source metadata unchanged
dotnet build .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj First-run bootstrap passed, 0 warnings, 0 errors. Profile and source metadata unchanged
dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --logger 'trx;LogFileName=shared.trx' --results-directory <unique-run-directory> Passed: 4,659, failed: 0, skipped: 25, total: 4,684. Profile and source metadata unchanged
dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore --logger 'trx;LogFileName=tray.trx' --results-directory <unique-run-directory> Passed: 4,497, failed: 0, skipped: 0. Profile and source metadata unchanged

Source manifests were unchanged within each run. Final mandatory runs used clean commit 734aa41aa11f61c1dcca6f314196bdbc518a7e97. The focused source matches that committed tree; the negative-control source differs by removal of the initializer attribute only. Shared skips cover existing hardware/integration cases and are not claimed as custom proof.

Real Behavior Proof

  • Environment tested: native Windows AMD64, .NET SDK 10.0.402, isolated pure test processes.
  • PR head or commit tested: 734aa41aa11f61c1dcca6f314196bdbc518a7e97, base 51f18c1222c996fb6fa2eb4d7e8d668492103a0e.
  • Exact steps or command run: focused filter in Validation, including fresh reflection processes with absent, blank, direct-only, modern-root-only, legacy-only, and all-explicit overrides.
  • Evidence after fix: Passed! - Failed: 0, Passed: 24, Skipped: 0, Total: 24. Negative control reports Startup isolation did not establish an isolated direct profile. or Startup isolation resolved a real tray profile. before file/log owner access.
  • Observed result: actual static last-chat-state and aborted-message paths, default tool-metadata path, settings path, local/roaming paths, setup path, and isolation status match the expected isolated domains. Safe explicit paths and environment-scope restoration remain intact.
  • Screenshot or artifact links verified? (Yes/No/N/A): N/A. Evidence is copied process/TRX output; private local artifacts are not public proof links.
  • Not verified or blocked: the earlier real-log changes remain unattributed and are not claimed fixed. No UI, native Gateway, MCP, installation, or machine-runtime proof is applicable or claimed. Independent source and final test-evidence review cleared this exact commit for draft publication.

Security Impact

  • New permissions or capabilities? (Yes/No): No.
  • Secrets or tokens handling changed? (Yes/No): No.
  • New or changed network calls? (Yes/No): No.
  • Command or tool execution surface changed? (Yes/No): No shipped surface. Tests add a dependency-free reflection subprocess.
  • Data access scope changed? (Yes/No): Yes, tests use isolated defaults and stop reading real settings bytes.
  • If any answer is Yes, explain the risk and mitigation: explicit lexical paths into real release/dev profiles are rejected before environment mutation. Existing 8.3, junction, and symlink aliases are not canonicalized, so callers must supply genuinely task-owned roots. No production profile cleanup is performed.

Compatibility and Migration

  • Backward compatible? (Yes/No): Yes for shipped application behavior and safe explicit test roots.
  • Config or environment changes? (Yes/No): Yes, test processes fill unset/blank tray isolation overrides; relative or real-profile overrides fail closed.
  • Migration needed? (Yes/No): No.
  • If yes, list the exact upgrade steps: N/A. Deliberately supplied safe absolute test paths are preserved. A legacy-only direct setup override stays effective instead of being shadowed by a generated modern local root.

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

Guard default tray test processes before linked owners cache paths, preserve safe explicit roots and reject real profiles. Add a discovery-free subprocess regression and stop reading real settings contents in the settings isolation test.

Co-authored-by: Copilot App <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 22, 2026
@clawsweeper

clawsweeper Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codex review: needs changes before merge.

What this changes

The PR isolates tray test profile paths before static initialization and replaces real settings-content reads with metadata checks.

Example: A developer runs Tray.Tests on Windows without profile overrides.

  • Before: Linked settings, logger, and chat owners can resolve files under the developer's real OpenClawTray profile.
  • After: The test module supplies unique temporary profile paths before those owners initialize.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused test-process evidence supports a coherent repair with no identified correctness defect; the strongest execution evidence remains a harness.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored test-only change has no shipped behavior requiring runtime proof; supplied native Windows test-process evidence exercises initialization, path resolution, explicit overrides, and the initializer-removal negative control.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Running tray tests directly can read or write a developer's installed tray profile.
Reason: Automatic test-process isolation protects developer data and follows existing repository policy; maintainer authorship supplies direction for the test-only timeout override.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this maintainer-authored PR addresses a source-confirmed test-isolation defect, and no introduced correctness bug was found.

Priority: P2
Reviewed head: 734aa41aa11f61c1dcca6f314196bdbc518a7e97

Before merge

  • Complete next step - Inspect the failing-test output from the Run Tray UI Tests job and establish whether the failure is caused by this diff before landing.

Findings

None.

Agent review details

How this fits together

Tray.Tests compiles application profile owners directly; a test-only module initializer supplies their environment overrides, and a reflection subprocess observes the resulting paths.

flowchart TD
  A[Direct tray test run] --> B[Test module initializer]
  B --> C[Validated profile overrides]
  C --> D[Linked application path owners]
  D --> E[Isolated test files]
  F[Reflection subprocess] --> D
Loading

Technical review

Best possible solution:

Keep the isolation guard at test-module startup and retain the fresh-process regression without changing shipped profile resolution.

Do we have a high-confidence way to reproduce the issue?

Current-main profile resolvers fall back to real Windows profiles without overrides, and the existing isolation test reads real settings contents; the author's initializer-removal negative control supports the startup failure path.

Is this the best way to solve the issue?

The test module owns the earliest reliable initialization boundary, and the separate reflection process checks cached application paths without test discovery or settings construction.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 51f18c1222c9.

Provenance checked

  • Settings isolation regression changes intended behavior with a stated reason (581f78d: The existing regression verifies that an explicit test directory receives settings writes without changing real settings.)
  • Profile identity and override precedence keeps the original intent (feat: add dev/release side-by-side app identity #922: Dev and release builds require separate identities and data roots; the test guard preserves those production contracts and existing override precedence.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Karen: Raw commit 1629938 adds tests/OpenClaw.Tray.Tests/SettingsManagerIsolationTests.cs:121 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 16299381a4df; files: tests/OpenClaw.Tray.Tests/SettingsManagerIsolationTests.cs)

Review metrics

Metric Value Why it matters
Production scope 0 shipped production files changed The added initialization and subprocess machinery remain inside test projects.

Labels

Label changes:

  • add P2: Direct developer test runs can access real tray profile files, but shipped application behavior is unaffected.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Direct developer test runs can access real tray profile files, but shipped application behavior is unaffected.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 22, 2026, 5:09 AM ET / 09:09 UTC.

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

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant