Skip to content

fix(harness): fall through to remote store in glob and ls when index yields no matches (#3197) - #3201

Open
philo-x wants to merge 1 commit into
agentscope-ai:mainfrom
philo-x:fix/3197-remote-fs-fallback
Open

philo-x wants to merge 1 commit into
agentscope-ai:mainfrom
philo-x:fix/3197-remote-fs-fallback

Conversation

@philo-x

@philo-x philo-x commented Sep 18, 2026

Copy link
Copy Markdown

AgentScope-Java Version

2.0.4-SNAPSHOT

Description

Fixes #3197.

Background

RemoteFilesystem.glob() and ls() return directly from the
WorkspaceIndex fast path whenever the index has a matching prefix, even
when that fast path yields no matching results.

Because WorkspaceIndex is best-effort and may be stale or incomplete, an
empty index result is not authoritative. In that case, files present in the
remote store can be missed.

RemoteFilesystem.grep() already handles this case by falling through to
the authoritative store scan when the index produces no matches.

Changes

  • Align glob() and ls() with the existing grep() fallback semantics:
    • return non-empty index results directly;
    • fall through to the authoritative remote-store scan when the index fast
      path yields no matches or entries.
  • Keep the existing non-empty index fast path unchanged.
  • Update withIndex Javadoc to document the fallback semantics.
  • Add branch-level regression tests for empty/non-matching index results.
  • Add compatibility coverage using real SQLite WorkspaceIndex instances
    and RemoteFilesystemSpec routing.

The RemoteFilesystemSpecTest coverage is intentionally a compatibility
test rather than a reproducer for the empty-result fast path: real workspace
indexes use workspace-relative paths while the composite memory route uses
different path normalization.

Validation

  • mvn spotless:check
  • Added targeted regression coverage for glob() / ls() index fallback.
  • Codecov reports all modified and coverable lines are covered.
  • Full GitHub Actions Maven CI is currently running on Ubuntu and Windows.

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated where applicable
  • Code is ready for review

@CLAassistant

CLAassistant commented Sep 18, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…yields no matches (agentscope-ai#3197)

In multi-node deployments (e.g. Redis backing store), a node's local
WorkspaceIndex may not yet contain files written by sibling nodes.
RemoteFilesystem.grep() already implements the proper fallback paradigm:
it only returns early when the index yields matches, otherwise falling
through to searchAllItems() on the authoritative store.

However, RemoteFilesystem.glob() and ls() returned early as long as
index.hasPrefix() was true, even when pattern-filtered results or entry
lists were empty, masking files present in the remote store.

This fix:
1. Aligns glob() and ls() fast-path to only return early when results/infos
   are non-empty, falling through to searchAllItems() otherwise.
2. Updates Javadoc in withIndex to document unified fallback semantics and
   note that non-empty index results are returned directly without store merge.
3. Adds comprehensive unit regression tests in RemoteFilesystemGlobLsTest
   covering branch fallbacks when index returns non-matching or empty candidates.
4. Adds integration regression test in RemoteFilesystemSpecTest covering
   real SQLite WorkspaceIndex and composite filesystem routing.
@philo-x
philo-x force-pushed the fix/3197-remote-fs-fallback branch from 1e82dd1 to f87db37 Compare September 18, 2026 13:30

@oss-maintainer oss-maintainer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. The fallback fix is narrowly scoped and correct: glob/ls now fall through to the authoritative remote store when the WorkspaceIndex fast path yields zero candidates or zero matches, while non-empty fast-path results keep their existing (no-merge) semantics — aligning both tools with the already-correct grep/exists behavior. Regression coverage is strong: branch-level unit tests plus a parameterized integration test with real SQLite WorkspaceIndex instances across two workspace nodes. Spotless clean, CI green on ubuntu/windows, CLA signed. Welcome, and thanks for the thorough tests!


Automated review by github-manager-bot

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]:Redis 模式下 glob 和 ls 操作被本地索引误导,无法正确发现 Redis 中实际存储的记忆文件。

3 participants