Skip to content

test(agent): honor Windows expanduser home in HOME-dependent tests - #49118

Open
hakanpak wants to merge 1 commit into
NousResearch:mainfrom
hakanpak:fix/48986-windows-expanduser-home
Open

test(agent): honor Windows expanduser home in HOME-dependent tests#49118
hakanpak wants to merge 1 commit into
NousResearch:mainfrom
hakanpak:fix/48986-windows-expanduser-home

Conversation

@hakanpak

Copy link
Copy Markdown
Contributor

What

Two HOME-dependent tests now resolve ~ to the test's tmp dir on native Windows, instead of leaking the real user profile.

Why

os.path.expanduser reads USERPROFILE (then HOMEDRIVE+HOMEPATH) on Windows and HOME on POSIX. The tests set only HOME, so on native Windows ~ expanded to the real profile:

  • test_normalize_path_expands_tilde asserted against the wrong home and failed.
  • test_blocks_sensitive_home_and_hermes_paths compared the ~/.ssh/id_rsa guard against the real profile, so the SSH-key block was never actually exercised on Windows — the security assertion silently passed over.

Change

Pin USERPROFILE alongside HOME and clear HOMEDRIVE/HOMEPATH so ~ resolves to the same home on every platform. Test-only; no production code change, POSIX behavior unaffected.

Tests

Both pass on native Windows after the change; unchanged on POSIX.

Part of #48986.

os.path.expanduser resolves ~ from USERPROFILE (then HOMEDRIVE+HOMEPATH)
on Windows and from HOME on POSIX. Two tests set only HOME, so on native
Windows ~ expanded to the real user profile instead of the test's tmp dir:

- test_normalize_path_expands_tilde asserted against the wrong home.
- test_blocks_sensitive_home_and_hermes_paths silently skipped the
  ~/.ssh/id_rsa block (the guard compared against the real profile), so a
  security check went unexercised on Windows.

Pin USERPROFILE alongside HOME and clear HOMEDRIVE/HOMEPATH so ~ resolves
to the same home on every platform. No production change; POSIX behavior
is unaffected.

Part of NousResearch#48986.
@daimon-nous daimon-nous Bot added type/test Test coverage or test infrastructure comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have labels Jun 19, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused Windows test-isolation fix. The premise remains present on current main: agent/lsp/workspace.py:41 and agent/context_references.py:366 call os.path.expanduser, while the target tests currently set only HOME (tests/agent/lsp/test_workspace.py:137; tests/agent/test_context_references.py:334). The proposed USERPROFILE setup and fallback removal match the existing portable fixture convention in tests/tools/test_checkpoint_manager.py:57-60.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jul 14, 2026

@GottZ GottZ left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was generated by AI during triage.

Summary

Three open PRs address Windows tilde-expansion tests that set HOME without pinning the USERPROFILE source used by os.path.expanduser on Windows. #49118 fixes two tests, #63562 applies the more robust HOME/USERPROFILE-plus-fallback isolation to seven tests, and #71425 overlaps three of those while uniquely covering the cron workdir test.

Related pull requests

  • #49118 related — (+13/-0) — superseded: Fixes the workspace and sensitive-path tests by pinning USERPROFILE and clearing HOMEDRIVE/HOMEPATH, but both changes are contained in the broader #63562. Despite the keep_open review on #49118, the complete diffs show that #63562 covers the same two test defects and five additional sibling paths.
  • #63562 duplicate — (+29/-5) — preferred consolidation base: Covers all seven identified tilde-dependent fixtures, including both #49118 targets, and consistently pins HOME/USERPROFILE while removing Windows fallback variables; it also uses semantic Path comparisons where separators can differ. Its keep_open review identified the sibling gaps, and the updated diff addresses every path named by that review.
  • #71425 related — (+8/-0) — partially duplicate with one unique fixture: Overlaps #63562 in the workspace and two CLI tests and was validated on native Windows, but only sets USERPROFILE rather than also clearing fallback variables. Its cron workdir fixture is not present in #63562 and should be retained during consolidation.

Duplicates

#49118 is fully duplicated by #63562. #71425 substantially overlaps #63562 for three tests, with tests/cron/test_cron_workdir.py as its unique addition.

Suggested consolidation

Merge #63562 after incorporating the cron workdir fixture from #71425, preserving #63562's consistent clearing of HOMEDRIVE/HOMEPATH. Then close #49118 as fully superseded and #71425 as consolidated after its unique cron coverage has been ported.

Complex graph

flowchart LR
    classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
    classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
    classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
    classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
    classDef best stroke-width:3px,stroke:#b45309
    classDef target stroke-width:3px,stroke:#4338ca
    subgraph Dup49118 ["PRs duplicating each other"]
        P49118["PR #49118 (open)"]
        P63562["PR #63562 (open)"]
    end
    class P49118 open
    class P63562 open
    class P49118 target
    click P49118 "https://github.com/NousResearch/hermes-agent/pull/49118"
    click P63562 "https://github.com/NousResearch/hermes-agent/pull/63562"
Loading

Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed or no verify verdict yet (state tag in the node label).

Cross-PR triage: Reviewed 3 pull requests and 0 issues in this complex. Each diff was read against this issue; Assessment working set: 11 kB of PR diffs, 3 kB of issue/PR text, 5 kB of discussion (8 comments), 1 verify verdict. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

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

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/test Test coverage or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants