Skip to content

fix(sessions): include descendants when filtering by filesystem root - #105553

Open
ymybxx wants to merge 1 commit into
NousResearch:mainfrom
ymybxx:fix/session-root-cwd-filter
Open

ymybxx wants to merge 1 commit into
NousResearch:mainfrom
ymybxx:fix/session-root-cwd-filter

Conversation

@ymybxx

@ymybxx ymybxx commented Sep 8, 2026

Copy link
Copy Markdown

What does this PR do?

A cwd_prefix="/" filter currently matches the root session but misses sessions under /repo or /repo/src: _cwd_prefix_clause appends another separator and produces the SQL LIKE pattern //%. A stored backslash root has the same issue. The shared predicate affects rich session lists, counts, workspace resume and prune previews/actions.

Append a separator only when the prefix does not already end in that separator, then apply the existing LIKE escaping. Ordinary paths, drive roots, and literal %/_ characters keep their existing behavior.

Related issue

Found on main 6e2b8e070d28b1a3381a3fb290b6b8d6cce13cef. No matching issue. Checked existing PRs around _cwd_prefix_clause, root filters and workspace filtering. #78927 fixed wildcard escaping; this preserves that fix and handles the remaining root-directory boundary case.

Type of change

  • Bug fix

How was this tested?

Two invariant tests use real temporary SessionDB files. Listing in both order modes, counts and workspace resume must select the same directory and descendants. Pruning must agree with its preview and preserve out-of-scope rows and messages. Windows-style paths are database values; the tests do not fake the host OS.

  • Unpatched main: 5 failed, 4 passed in the new regression file.
  • Patched: 61 passed across the new file, workspace-binding and CLI-listing suites, plus relevant prune/list/resume tests from test_hermes_state.py, via scripts/run_tests.sh with retries disabled.
  • Ruff, git diff --check and compatibility-pointer check passed.

A broader test_hermes_state.py run exposed an existing FTS query-count assertion failure, reproduced unchanged on the unpatched base. Its separate process-inspection sandbox error passed outside the sandbox. No live session database was modified; the full repository suite was not run.

Checklist

  • Reproduced on current main; focused regressions pass after the fix.
  • Shared caller behavior covered; existing wildcard isolation retained.
  • No new setting, schema, dependency or public API.

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Sep 8, 2026
@Enough1122

Copy link
Copy Markdown

AI code review — automated review for reference; please use your judgment.

Summary

Fixes filesystem-root cwd filtering: a root prefix (/, \, C:\) already ends with its separator, so appending another one searched for //repo instead of descendants. Children patterns now reuse the trailing separator when present, with LIKE wildcards escaped as before.

Findings (all Non-blocking)

  • hermes_state_sessions.py (new _cwd_prefix_clause) — generates both / and \ child patterns so mixed-separator stored paths match; the = arm preserves exact-root matches. The parametrized test covers /, \, C:\, and wildcard (%) prefixes across list/count/search/prune paths. Thorough. No issues.

Verdict

Looks good — small, correct boundary fix with strong cross-path test coverage.

This branch has not been deployed

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

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants