Skip to content

fix(test): a plain Tray test run writes into the real Companion profile - #1961

Merged
shanselman merged 4 commits into
mainfrom
openclaw/tray-tests-isolate-user-profile
Nov 11, 2026
Merged

shanselman merged 4 commits into
mainfrom
openclaw/tray-tests-isolate-user-profile

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: the Tray test command that AGENTS.md requires writes into the developer's real Companion profile unless the OPENCLAW_TRAY_* variables are set first.

User Impact

User impact: no end-user change. A developer or agent who runs dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj beside a real installation no longer gets fixture files in it.

Behavior to review: the tests now always run with AppIdentity.IsIsolated true, as they already do in CI, which sets OPENCLAW_TRAY_DATA_DIR. Values the caller already set are kept.

Why This Change Was Made

Production code falls back to %APPDATA% and %LOCALAPPDATA% when these overrides are unset, so isolation depended on remembering them. AGENTS.md asks for it, but its own required command does not set them. A module initializer runs before any test and cannot be forgotten.

Evidence

Before, on a4dd026 beside an installed Companion, one plain run created %APPDATA%\OpenClawTray\device-key-ed25519.json and added fixture chat-state files and about 2660 log lines under %LOCALAPPDATA%\OpenClawTray.

After, the same command with the variables unset leaves the real files untouched, and the same files land in the temp profile:

===== real profile before (override variables deliberately unset)
2026-10-31 19:23:00.678 411 device-key-ed25519.json
2026-10-27 02:23:09.404 2039 settings.json
2026-10-31 19:24:28.346 287451 openclaw-tray.log
2026-10-31 19:24:21.611 163 last-chat-state.json
===== full tray suite, plain dotnet test
Passed!  - Failed:     0, Passed:  4801, Skipped:     0, Total:  4801
===== real profile after
(identical)
unchanged: True
OPENCLAW_TRAY_DATA_DIR\aborted-messages.json
OPENCLAW_TRAY_DATA_DIR\attachment-metadata.json
OPENCLAW_TRAY_DATA_DIR\device-key-ed25519.json
OPENCLAW_TRAY_DATA_DIR\last-chat-state.json
OPENCLAW_TRAY_DATA_DIR\openclaw-tray.log
OPENCLAW_TRAY_DATA_DIR\tool-metadata.json

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: this changes only the test process. No product code and no custom host class is involved.

Validation

Run on a4dd026 plus this change. Windows 11 x64 build 26200, tr-TR, .NET SDK 10.0.402.

  • ./build.ps1: succeeded.
  • Tray tests with the OPENCLAW_TRAY_* variables unset: 4801 passed, 0 failed.
  • Shared tests: 4806 passed, 2 failed, 26 skipped. This PR changes no Shared code. Both failures come from this host: ExecReusableCommandBinderTests.PinnedCarrier_IgnoresShadowInsertedAfterApproval (computer name longer than 15 characters) and MxcFolderAdmissionTests.OwnedJunctionAndSymbolicLinkAreRejectedWithoutFollowingTheirChildren(symbolic: True) (no symbolic link privilege).

Real Behavior Proof

  • Environment tested: Windows 11 x64 build 26200 (tr-TR), with Companion 2026.9.8-1 installed.
  • PR head or commit tested: a4dd026 plus this change. CI on the PR head is the current-head result.
  • Exact steps or command run: unset the four override variables, record timestamp and size of four real profile files, run the Tray tests, record them again.
  • Evidence after fix: above.
  • Observed result: the real files are unchanged and the fixture files land in the temp profile.
  • Screenshot or artifact links verified? (Yes/No/N/A): N/A
  • Not verified or blocked:
    • The other test projects (Connection, SetupEngine, Cli, UITests) were not audited for the same leak.
    • The temp profile is deleted at process exit on a best-effort basis. One 300 KB folder stayed behind in %TEMP% after a run on this host.
    • This protects future runs only. It does not clean a profile that an earlier run already wrote to.

Security Impact

  • New permissions or capabilities? (No)
  • Secrets or tokens handling changed? (No)
  • New or changed network calls? (No)
  • Command or tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any answer is Yes, explain the risk and mitigation:

Compatibility and Migration

  • Backward compatible? (Yes)
  • Config or environment changes? (No)
  • Migration needed? (No)
  • If yes, list the exact upgrade steps:

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.

Review-fix follow-up (2026-11-04)

The original Windows build, suite counts, and real-profile proof above apply to original head 73932a0de1873de059952c7d0882b2c27aa4fd33 (source-equivalent to f7bae6f), not to this follow-up. The original Not verified list is unchanged.

At follow-up head 21b9a369bdb8d3a7e77ba7d544cdd9375a270cc4:

  • Preserve effective legacy-only OPENCLAW_TRAY_LOCAL_DATA_DIR by not generating the higher-precedence OPENCLAW_TRAY_LOCALAPPDATA_DIR. An existing modern root still wins when both are supplied, matching the unchanged AppIdentity.ResolveSetupLocalDataDirectory and SetupContext.ResolveLocalDataDir contracts. Production code is unchanged.
  • Allow safe explicit directories beneath Roaming AppData. Reject only release/dev Companion profile trees beneath Roaming or Local AppData, using normalized full paths and directory-separator boundaries rather than raw prefixes.
  • Add focused regressions for missing overrides, legacy-only and modern-plus-legacy precedence, a safe Roaming profile, and normalized boundary/sibling paths. Environment-mutating tests use the existing nonparallel collection and reversible EnvironmentScope.

Validation on Linux with workspace-local Microsoft .NET SDK 10.0.402:

  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --filter FullyQualifiedName~TrayTestProfileIsolationTests: 12 passed, 0 failed, 0 skipped. The project and its normal dependencies were built and the tests executed.
  • Original-logic regression replay: temporarily restored the original initializer loop and original profile assertion while retaining the new regressions and the behavior-preserving initializer-method extraction. Running dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --filter "FullyQualifiedName~CallerSelectedSetupDirectoryKeepsItsEffectivePrecedence|FullyQualifiedName~CallerSelectedProfileUnderRoamingAppDataIsPreserved" produced 2 failed, 1 passed, 0 skipped. The failures were legacy-only override preservation and the safe Roaming profile. Restored the exact reviewed candidate, rebuilt, and reran the focused class: 12 passed.
  • git diff --check: passed. Independent Auto Review of the exact candidate, with resolver and environment-fixture context, found no actionable P0-P3 defects.
  • The SDK was installed only for this task. GitVersion required restoring the actual repository history and main reference in the sandbox; no source, dependency, or versioning-policy changes were made for validation.

Remaining proof limits: these are Linux focused-test results, not Windows runtime or real-profile proof. The original whole Windows suite and installed-Companion proof were not rerun. A fresh Windows check of the legacy-only and safe-Roaming caller configurations remains for Mert/maintainer-scheduled validation. No current-head CI result is claimed here.

Worked on by

Worked on by:
- @MertBasar0

Co-authored-by: MertBasar0 <[email protected]>
OpenClaw-Publication: b99d9f07-3816-469e-b5d9-39e05df47c83
@clawsweeper

clawsweeper Bot commented Nov 1, 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

The PR supplies temporary profile defaults before Tray tests run while preserving existing caller overrides.

Example: Run dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj with no OPENCLAW_TRAY_* overrides.

  • Before: Fixture files can land in the installed Companion profile, including OpenClawTray\device-key-ed25519.json.
  • After: Default fixture files land beneath a unique temporary OpenClawTrayTests directory.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, useful patch with no remaining findings; confidence rests on source review and supplied test-process execution rather than shipped application proof.
Proof confidence 🦐 gold shrimp (3/6) This test-only change has no shipped runtime proof gate; supplied current-head Windows test-process evidence exercises automatic defaults and reports that installed-profile metadata remained unchanged.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A developer running the required Tray test command can get fixture files in their installed Companion profile.
Reason: Automatic test isolation enforces the existing repository contract and protects developer state without changing shipped behavior.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR addresses a current test-isolation defect, resolves the earlier review findings, and introduces no actionable correctness defect.

Priority: P2
Reviewed head: d2b5f806c0d1b8d23365a1b1c9a2c370109575d4

Before merge

None.

Findings

None.

Agent review details

How this fits together

Tray.Tests compiles application profile owners into its test assembly; environment overrides enter their path resolvers, which select settings, logging, chat-state, and setup-state locations.

flowchart TD
  A[Plain Tray test command] --> B[Test module initializer]
  B --> C[Preserved or generated overrides]
  C --> D[Application path resolvers]
  D --> E[Temporary fixture files]
  D --> F[Setup state and registry migration]
Loading

Technical review

Best possible solution:

Initialize missing overrides at test-module startup while preserving caller precedence and keeping generated setup paths consistent with registry migration.

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

Current-main resolvers fall back to installed profile directories without overrides, and the supplied Windows before/after evidence demonstrates the reported file-writing path; this review ran no target code.

Is this the best way to solve the issue?

The test assembly is the appropriate initialization owner, and the focused patch preserves production resolution and caller-selected paths without adding a parallel production mechanism.

AGENTS.md: found and applied where relevant.

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

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Change scope Production +0/-0; test code +213/-0 The growth contains test-process initialization and distinct startup, override-precedence, profile-boundary, and registry-migration regressions.

Root-cause cluster

Relationship: canonical
Canonical: #1961
Summary: This PR carries the active repair for plain Tray test runs using installed profile defaults.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Plain developer test runs can contaminate an installed Companion profile; shipped application behavior is unchanged.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-01T00:30:21.491Z sha 73932a0 :: needs changes before merge. :: [P2] Preserve the effective legacy local-data override | [P2] Limit the isolation assertion to actual Companion profile directories

Reviewed November 8, 2026, 8:01 PM ET / November 9, 2026, 01:01 UTC (Revision 2).

Worked on by:
- @MertBasar0

Co-authored-by: MertBasar0 <[email protected]>
OpenClaw-Publication: 1f471d66-4d27-46b9-b125-e3a5bf8fc64c
Worked on by:
- @MertBasar0

Co-authored-by: MertBasar0 <[email protected]>
OpenClaw-Publication: a99779c4-3f18-4297-a212-ecfa68b2a813
@MertBasar0

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

1 similar comment
@roboclaw-bot

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 9, 2026
@roboclaw-bot roboclaw-bot added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Nov 10, 2026
@roboclaw-bot

Copy link
Copy Markdown
Contributor Author

Cleanup review: the test-profile isolation remains absent from main and is a strong small landing candidate. The current-head-associated CI log contains all 14 new cases and 5,076 passing Tray tests, while the older local Shared failures remain explicitly separate. I am checking current-main integration and an independent final review, including the repaired but still-unresolved review thread, before deciding whether it can safely land. No Windows tests have been rerun by this cleanup pass yet, and green older-base CI is not being presented as validation of current main.

@roboclaw-bot

Copy link
Copy Markdown
Contributor Author

The branch is now refreshed without rewriting history: ab0f07a7a01a6c221b2250ca0b49ee912ee5b698, containing current main e59374c064f43d68f5c72d070d4c89ef2d20ec3b. The added isolation file is byte-identical to the prior head.

The normal PR classification skips the Core/Shared lane for this test-only change. I am requesting a full, exact-branch Build and Test run so the missing Shared/build closeout is evaluated rather than waived. This is a validation dispatch on the PR branch, not a release/tag/promotion. The final independent review is running on this refreshed head, and the original contributor credit and historical evidence will be preserved in the body update.

@roboclaw-bot

Copy link
Copy Markdown
Contributor Author

Maintainer cleanup: current-head evidence

Reviewed/refreshed head: ab0f07a7a01a6c221b2250ca0b49ee912ee5b698, containing main e59374c064f43d68f5c72d070d4c89ef2d20ec3b. The single 213-line isolation file remains byte-identical to d2b5f806. Independent GPT-6 Astra and GPT-6.1 Sol reviews both completed with no actionable P0-P3 findings. The repaired setup/registry discussion is now resolved.

Fresh full validation run 42892337557 has verified these completed suites:

Suite Passed Failed Permitted skips
Shared 5,632 0 11
Tray 6,141 0 0
SetupEngine 2,597 0 4

All 14 isolation cases passed. Both previously reported Shared failures also passed on this CI host, including the symbolic-link case. The original host-specific failures remain historical observations, not silently relabeled passes. CI supplies an explicit profile, so these results are distinct from Mert’s plain-process Windows preservation proof.

The normal targeted PR CI Gate passed. The extra full dispatch has a failure in an unchanged native chat reader-scroll test and is still being reconciled; I am not treating this as full workflow success or bypassing a gate. No local Windows runtime was launched by the Linux cleanup host.

The original body, contributor credit and publication marker are preserved. This comment records the refreshed evidence and provenance without rewriting that attribution.

Original contribution: @MertBasar0.

Work sessions

Linked for team reference; these sessions aren’t public.

@roboclaw-bot

Copy link
Copy Markdown
Contributor Author

Full validation run 42892337557 is now terminal. Its only failed job is UI tests, plus the dependent CI Gate. Shared, Tray, SetupEngine, Mock Gateway and the other selected lanes passed.

Failed case Failure Baseline comparison
ConversationFeedback_ThinkingToolReviewsAndHistoryRetainComposerWithoutSearch(width: 1100) Timed out waiting for reader at top with jump visible; offset 167, maximum 1679 The exact case passed at main e59374c in job 129999314814.

This PR adds one file to the separate Tray unit-test assembly. It changes no UI assembly, native reader code, UI-test source or CI workflow; these lanes run in separate jobs. The failure is outside this change. I am rerunning only failed jobs once on unchanged head ab0f07a7a01a6c221b2250ca0b49ee912ee5b698, without bypassing the gate or relabeling the failed attempt. A repeated failure will remain a blocker.

@roboclaw-bot

Copy link
Copy Markdown
Contributor Author

The one allowed failed-job rerun has finished on unchanged head ab0f07a7a01a6c221b2250ca0b49ee912ee5b698. Attempt 2 still fails UI tests and CI Gate. This time the failing case is SystemsPageProofTests.ForgetConfirmation_AfterGatewayChange_CannotSubmit: Assert.Single() found no matching item at SystemsPageProofTests.cs:2003. It is not the earlier reader-scroll timeout.

I am leaving the PR open and stopping automatic reruns. The completed Astra/Sol source reviews, 5,632 passing Shared tests and 6,141 passing Tray tests remain valid evidence, including all 14 isolation cases, but they do not waive the red required gate. No UI implementation change or broader test repair was attempted as part of this bounded cleanup.

The description’s required Work sessions placement also remains unresolved after an attribution-protection check rejected the update. The original credit and publication marker are unchanged; current evidence and verified session links are preserved in the follow-up comment.

Removing the actively-landing label while the CI failure and supported metadata correction are outstanding. No merge, force push, branch deletion or check bypass.

@roboclaw-bot roboclaw-bot removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Nov 10, 2026
@shanselman
shanselman merged commit 22c111d into main Nov 11, 2026
93 of 99 checks passed
@shanselman
shanselman deleted the openclaw/tray-tests-isolate-user-profile branch November 11, 2026 07:36
@shanselman

Copy link
Copy Markdown
Collaborator

I'm a Copilot triage agent working through PRs for Scott overnight (not Scott himself). I squash-merged this as 22c111d4 from head ab0f07a7. Thanks @MertBasar0 and everyone who reviewed, and thanks roboclaw-bot for the careful trail.

Why I landed it with the dispatch run still red. GitHub's required CI Gate for this PR is the pull_request run (run 42892101886, Gate passed), and the merge state was clean. The red results come from the workflow_dispatch runs that forced the UI job on. Three attempts on this unchanged head failed on four different UI tests, and each one is outside this change:

  • attempt 1 and attempt 3: ReactorChatLayoutProofTests.ConversationFeedback_ThinkingToolReviewsAndHistoryRetainComposerWithoutSearch(width: 1100) (a scroll and jump-control wait). It passed in attempt 2 and at main e59374c, so it is intermittent on this head.
  • attempt 2: SystemsPageProofTests.ForgetConfirmation_AfterGatewayChange_CannotSubmit.
  • attempt 3: UsagePageRenderingTests.DailyHeader_SharesTextCentresOnFreshMountAndAfterCompactTransition(width: 1400, transition: True).

OpenClaw.Tray.UITests references Tray.WinUI, Shared, TestSupport and GatewayFixtureHost, not OpenClaw.Tray.Tests, so a new file in the Tray unit-test assembly cannot reach those tests.

Local proof on the merge result (this head merged with main 994539b8, Windows ARM64, separate worktree, every OPENCLAW_TRAY_* variable unset, which is the plain dotnet test case this PR fixes):

  • Tray tests: 6290 passed, 0 failed, 0 skipped.
  • Real Companion profile snapshot before and after the run (%LOCALAPPDATA%\OpenClawTray and %APPDATA%\OpenClawTray, 11 files): no file added, removed or modified.

The main push runs for the merge are in progress, and I will keep an eye on them. The one thing I did not resolve is the PR description's Work sessions placement that the bot mentioned. Please fix that by hand if it still matters.

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: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants