fix(sessions): keep cwd filters within case-distinct workspaces - #115979
Open
Bryson11111w wants to merge 1 commit into
Open
Bryson11111w wants to merge 1 commit into
Bryson11111w wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Keep directory-scoped session operations inside the selected workspace. With ended sessions in
/work/Agent/srcand/work/agent/src, filtering by/work/Agentcurrently selects both: SQLiteLIKEfolds ASCII case even when its wildcard characters are escaped.prune_sessions()consequently deletes both sessions, and workspace resume, listing and bulk archive use the same predicate.Use literal
instr(...)=1prefix comparisons with a trailing path separator, matching the case sensitivity of the existing exact-directory comparison. This preserves literal%,_and backslashes and excludes similarly named sibling directories. Reuse the predicate for legacy Kanban worker retagging, which otherwise misclassifies unrelated CLI sessions and misses backslash-delimited descendants.Related Issue
Found while reviewing the session persistence code on
mainat8df0a03793784205833f9e0db12395aa33ada433; no new issue has been filed. Related prior fix: #78927 escaped SQL wildcards, butLIKEstill folds ASCII case. This change addresses that remaining path-boundary failure.Type of Change
Changes Made
hermes_state_sessions.py: use literal, separator-bounded comparisons in the shared cwd predicate.hermes_state.py: reuse that predicate when retagging legacy Kanban workers.tests/hermes_state/test_cwd_prefix_isolation.py: two behavioral tests, parameterized over slash- and backslash-delimited stored paths. Exercise realSessionDBimports and SQLite databases under isolatedHERMES_HOMEvalues.How to Test
Results on Linux / Python 3.12.13:
git diff --checkpasses.Rebased onto
mainat633dda6d7fdcac7e8340471c9f5ed08cdccbd70cand reran both focused commands: 21 passed, zero failed. The affected production paths were unchanged between the original reproduction and this base.The new tests cover listing/count agreement, workspace lookup, prune preview/count agreement, archive/delete isolation, literal wildcard characters, separator boundaries and one-time worker retagging. Stored Windows-style paths are exercised as data on Linux; native Windows and macOS have not been run. No live provider or full-suite claim.
Checklist
cwd_prefixand reviewed the earlier wildcard fix.scripts/run_tests.sh.