Repository navigation
fix(harness): enforce namespace boundary for absolute paths in ROOTED local filesystem - #3292
Conversation
… local filesystem With LocalFilesystemSpec and a per-session/per-user IsolationScope, the namespace prefix only scopes RELATIVE keys: applyNamespacePrefix passes absolute keys through unchanged, and the ROOTED acceptance check treats the workspace root itself as an implicit allowed root. A session could therefore read or write another session's directory under the shared workspace root (MEMORY.md, memory/, agents/, generated artifacts) with a plain absolute path, which turns IsolationScope.SESSION into a path prefix rather than an access boundary (agentscope-ai#3261). - LocalFilesystem gains an opt-in namespaceBoundary: in ROOTED mode an absolute path resolving under cwd must resolve under cwd/<namespace>; the leading-slash virtual form is covered as well. Paths under PathPolicy roots outside cwd (read-only project layer, additional roots) are unaffected, and with no namespace active the check is a no-op. - LocalFilesystemSpec enables the boundary for the workspace layer in ROOTED mode (the spec default). SANDBOXED already re-roots absolute paths under the workspace; UNRESTRICTED is documented to pass absolute paths through. Shared workspace-root content stays reachable through workspace-relative paths, which the overlay read-falls-back to the project layer.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…e branch
- '/' alone reaches the same resolution as any other leading-slash virtual
path via Path.resolve(""), so the empty-stripped special case (dead on
real systems where the root always exists) is removed.
- cover the two no-op short-circuits of requireOwnNamespace: boundary
enabled with no namespace factory, and a factory resolving to null.
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Solid, well-scoped fix for #3261: with namespaceBoundary enabled, absolute and leading-slash virtual paths under cwd must resolve inside the caller's own namespace, the opt-in default keeps direct LocalFilesystem users unaffected, and LocalFilesystemSpec turns it on for the ROOTED workspace layer. One security gap in the boundary check itself needs attention before this can land, so I'm leaving this as COMMENT rather than an approval.
Findings
- [Critical]
LocalFilesystem.java:732— the boundary is enforced withPath.normalize()/Path.startsWith(), neither of which resolves symbolic links, so a symlink created inside one session's namespace can still reach a sibling namespace or a shared root directory. - [Warning]
LocalFilesystem.java:720/:733— the javadoc assumes..rejection makes relative keys safe, andstartsWith()is case-sensitive, so a case-mismatched path escapes the boundary on Windows/APFS. - [Warning]
LocalFilesystemModeTest.java:262— the new cases cover direct absolute traversal but not symlink or case-insensitive escape paths.
Suggested direction
Resolve the candidate against the filesystem before comparing (toRealPath() on the existing target, falling back to the nearest existing ancestor for not-yet-created files) and compare canonical paths case-insensitively, or add a canonical-path helper next to the existing validatePath check. If symlink traversal should stay out of scope for this mode, please record that explicitly in the namespaceBoundary javadoc and the class-level docs so the security property is not over-claimed.
Good catch on splitting the shared-directory behaviour out into an explicit note — the carve-out question is worth the maintainers' input, and the new no-op behaviour when no namespace is active reads correctly.
Automated review by github-manager-bot
| if (ns == null || ns.isEmpty()) { | ||
| return; | ||
| } | ||
| Path nsRoot = cwd.resolve(String.join("/", ns)).normalize(); |
There was a problem hiding this comment.
The namespace boundary is checked with Path.normalize() and Path.startsWith(), which do not resolve symbolic links. A symlink planted inside the caller's namespace directory (e.g. user-1/link -> ../user-2) lets an absolute path pass the prefix check while the filesystem operation follows the link into another namespace. Consider using Path.toRealPath() for the boundary check, or document that symlink traversal is out of scope.
There was a problem hiding this comment.
Fixed in 07ce9f5: the candidate is now resolved to its physical location before the comparison — Path.toRealPath() when it resolves, otherwise the nearest existing ancestor resolved to its real path with the remaining components appended lexically (components that do not exist yet cannot hide a link). Broken links are followed lexically through their recorded target (Files.readSymbolicLink), so the eventual target location is what gets compared. The namespace root is anchored at the physical cwd (cwd.toRealPath()), which also keeps both sides of the comparison consistent when cwd itself contains links (e.g. /tmp vs /private/tmp on macOS).
| /** | ||
| * Rejects absolute paths that resolve under {@link #cwd} but outside the caller's own | ||
| * namespace directory when {@link #namespaceBoundary} is enabled and a namespace is active. | ||
| * Relative keys never reach this check with a foreign namespace: they are prefixed into the |
There was a problem hiding this comment.
The javadoc asserts that relative keys never reach this check with a foreign namespace because .. is rejected. That is true for .. segments, but a relative key such as link-to-sibling/file is prefixed into the caller's namespace and can then escape via a symlink. This bypass is not covered by the new boundary logic and should at least be documented as a remaining limitation.
There was a problem hiding this comment.
Fixed in 07ce9f5 rather than only documented: relative keys now go through the same physical check after namespace prefixing, so link-to-sibling/file is rejected when the link leads out of the own namespace. The javadoc claim that relative keys never reach the check is removed.
| return; | ||
| } | ||
| Path nsRoot = cwd.resolve(String.join("/", ns)).normalize(); | ||
| if (resolved.startsWith(nsRoot)) { |
There was a problem hiding this comment.
Path.startsWith() is case-sensitive. On case-insensitive file systems (Windows, macOS APFS), a casing mismatch between cwd/nsRoot and resolved can cause false positives, rejecting legitimate paths inside the caller's namespace. Normalize or canonicalize casing at filesystem construction, or use a real-path check that follows the host FS semantics.
There was a problem hiding this comment.
Fixed in 07ce9f5 as a side effect of the physical resolution: toRealPath() returns the on-disk casing, so both sides of the comparison are canonical on case-insensitive hosts. (While re-verifying this finding we concluded it is a false-reject rather than an escape — a casing mismatch fails closed at the earlier root checks — but it is fixed regardless.)
| return; | ||
| } | ||
| Path nsRoot = cwd.resolve(String.join("/", ns)).normalize(); | ||
| if (resolved.startsWith(nsRoot)) { |
There was a problem hiding this comment.
The boundary check is performed on a Path object before the actual file operation, so a symlink or directory entry can change between the startsWith check and the subsequent Files.read*, Files.write*, or directory traversal. This is a general TOCTOU race inherent to path-prefix checks; resolving to a real path before the operation would narrow the window but cannot eliminate it entirely.
There was a problem hiding this comment.
Acknowledged and documented as a remaining limitation in the namespaceBoundary(boolean) javadoc: the check runs before the file operation, so a component swapped in between (TOCTOU) is not covered. Closing the window entirely would need fd-level operations (openat-style), which is out of scope for a Path-based API; physical resolution narrows it.
| if (ns == null || ns.isEmpty()) { | ||
| return; | ||
| } | ||
| Path nsRoot = cwd.resolve(String.join("/", ns)).normalize(); |
There was a problem hiding this comment.
nsRoot is recomputed on every call (cwd.resolve(String.join("/", ns)).normalize()). Both cwd and the namespace are effectively immutable for a given filesystem instance, so the root could be cached to avoid the repeated string join and path normalization on the hot path.
There was a problem hiding this comment.
Kept per-call on purpose: the namespace is derived per call from the RuntimeContext, so one filesystem instance can serve multiple sessions and a per-instance cache would be wrong. A per-namespace map would add state for a negligible gain — one string join plus one toRealPath next to the operation's own filesystem I/O.
There was a problem hiding this comment.
Follow-up from the Windows CI run: anchoring the namespace root at cwd.toRealPath() with lexical namespace components turned out to break one case — when the workspace root does not exist yet (e.g. the knowledge-directory glob runs before first use) AND cwd is reached through an alias (Windows 8.3 short names like RUNNER~1, macOS /var vs /private/var), the fallback lexical form and the candidate's real-pathed ancestor disagree and legit own-namespace paths get rejected. Fixed in 391a14c: the namespace root now goes through the same physicalPath() as the candidate, so both sides agree by construction. The trade-off: a link swapped in for a namespace directory now re-anchors the boundary to its target instead of failing closed — documented in the javadoc.
| } | ||
|
|
||
| @Test | ||
| void rooted_namespaceBlocksAbsolutePathIntoSiblingNamespace( |
There was a problem hiding this comment.
The new tests cover direct absolute-path traversal between namespaces but do not exercise symlink-based escapes. Add tests that create a symbolic link inside user-1 pointing at user-2 and assert that both absolute and workspace-relative access through the link is blocked (or at least that the behavior is explicitly defined).
There was a problem hiding this comment.
Added in 07ce9f5: a link into a sibling namespace is now asserted rejected via the absolute, namespace-prefixed relative, and leading-slash routes; a link pointing outside the workspace is rejected; a broken link into a sibling namespace is rejected via its recorded target; and a link that stays inside the own namespace is asserted still allowed (no false positive). All of these skip via Assumptions on platforms that cannot create links (e.g. Windows CI without symlink privilege).
The namespace boundary compared lexically normalized paths, so a symbolic link planted inside the caller's namespace could pass the prefix check while the file operation followed the link into a sibling namespace or a shared root. Case-sensitive prefix matching also rejected legitimate paths on case-insensitive hosts (Windows, APFS). requireOwnNamespace now resolves the candidate to its on-disk location (toRealPath, falling back to the nearest existing ancestor plus the lexical remainder for not-yet-created paths, and following broken links through their recorded target) before comparing against the namespace root anchored at the physical cwd. The check now also covers namespace-prefixed relative keys, which could escape the same way, and normalizes casing on case-insensitive filesystems as a side effect. Remaining limitations are documented on namespaceBoundary(boolean): the check-then-operate TOCTOU window inherent to path-prefix checks, and the assumption that framework-managed namespace directories are not swapped for links (which fails closed). New tests cover link escapes into a sibling namespace and outside the workspace via absolute, relative, and leading-slash routes, broken-link targets, and the no-false-positive case of links that stay inside the own namespace (skipped where the platform cannot create links).
|
Thanks for the thorough review — all findings are addressed in 07ce9f5. Summary: [Critical] Symlink escape — Fixed. Relative keys escaping via symlink — Fixed rather than only documented: the boundary check now also applies to namespace-prefixed relative keys, so Case sensitivity of TOCTOU — Documented as a remaining limitation in the
Tests — Added four cases in |
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Re-review after 07ce9f5e. All four functional findings from the previous review are properly resolved: the boundary is now checked on physical paths (symlinks inside the own namespace can no longer lead to a sibling namespace or out of the workspace), casing is normalized for case-insensitive hosts, TOCTOU and framework-managed-namespace assumptions are explicitly documented with fail-closed behavior, and symlink escape/allow tests were added (with a sane Windows assumeTrue probe). No re-review blockers from the code side — remaining inline notes are opt-out/migration, performance, and minor ergonomics.
One gate: build (ubuntu-latest) is red, but the failure is Upload coverage reports to Codecov (fail_ci_if_error: true, tokenless fork upload) — compile and all tests passed (80 tests, 0 failures before the upload step). Not a code problem; a maintainer re-run / coverage-token path should clear it.
Automated review by github-manager-bot
| // path would let one session/user address another session's directory under the | ||
| // shared workspace root (#3261). SANDBOXED re-roots absolute paths under the | ||
| // workspace already, and UNRESTRICTED is documented to pass absolute paths through. | ||
| upper.namespaceBoundary(true); |
There was a problem hiding this comment.
[Warning] This flips behavior for every existing ROOTED deployment built on the spec: absolute keys that legitimately addressed shared content under the workspace root (<cwd>/shared/...) now throw SecurityException. The fix is correct (it is what #3261 needs) and direct LocalFilesystem users keep the old default, but users upgrading will only discover this at runtime. Suggest (a) calling this out in the release notes / migration doc, and (b) a LocalFilesystemSpec escape hatch (e.g. namespaceBoundary(false) mirroring the opt-in) so an operator with a vetted single-tenant workspace can keep the old behavior without patching the library.
There was a problem hiding this comment.
Implemented in 3ac7058: LocalFilesystemSpec.namespaceBoundary(Boolean) now exists as the explicit opt-out/in (false keeps pre-boundary behaviour for vetted single-tenant workspaces, true forces it on in every mode, omit for the default). Migration note added to the harness filesystem docs (en+zh) with the shared-content-via-relative-paths guidance; the release-notes page currently only tracks released versions (2.0.2/2.0.3 entries do not exist yet), so I left its structure to the maintainers.
| if (ns == null || ns.isEmpty()) { | ||
| return; | ||
| } | ||
| Path nsRoot = physicalCwd().resolve(String.join("/", ns)).normalize(); |
There was a problem hiding this comment.
[Info] With the boundary enabled, every resolvePath in ROOTED mode now performs at least two toRealPath() calls (physicalCwd() and physicalPath(resolved)), plus resolve(tail)/normalize() walks when the target does not exist yet (the common case for write). That is fine for correctness, but it is hot for file-tool-heavy agents. Cheap wins while keeping the semantics: cache physicalCwd() after the first successful resolution (cwd is immutable), and when namespaceBoundary is on you can skip physicalPath() for the namespace-prefixed relative form if the freshly created path does not exist yet and no ancestor along cwd/<ns> is a link (the fail-closed variant: only walk the ancestor chain that already exists once, not per call).
There was a problem hiding this comment.
Addressed in 3ac7058: physicalPath(cwd) is cached per instance (volatile lazy field — computed on first boundary use so legacy constructors stay I/O-free), halving the guarded hot path. The per-call walks that remain are the namespace suffix and the candidate itself, which cannot be cached safely (per-call namespace, mutable filesystem).
| Path tail = null; | ||
| for (int hops = 0; hops < 64; hops++) { | ||
| try { | ||
| Path real = p.toRealPath(); |
There was a problem hiding this comment.
[Info] On the lexical-fallback floor of physicalPath(): when the 64-hop guard (or an unreadable link) leaves p as a relative lexical path, startsWith(nsRoot) compares a relative path against the absolute physical nsRoot, so it fails closed — good, but the resulting SecurityException message will be confusing for the user ("outside the isolated namespace" when they passed a normal relative path). Consider detecting the unresolved case and throwing a distinct "path could not be resolved" error. Minor.
There was a problem hiding this comment.
Addressed in 3ac7058: a candidate that floors to a relative lexical path now raises a distinct "could not be resolved to a physical location" SecurityException instead of the misleading namespace message.
| * namespace directory are rejected with a {@link SecurityException} in | ||
| * {@link LocalFsMode#ROOTED} mode. Off by default; see {@link #namespaceBoundary(boolean)}. | ||
| */ | ||
| private boolean namespaceBoundary = false; |
There was a problem hiding this comment.
[Info] namespaceBoundary is a non-final mutable field while LocalFilesystem is otherwise built from final config and shared across concurrent agent calls; the javadoc says it must be configured before exposure, which is not enforceable. A volatile field (or making it a constructor parameter) removes the publication hazard if any caller does set it lazily. The Spec path sets it before publishing, so today this is theoretical.
There was a problem hiding this comment.
Addressed in 3ac7058: the field is now volatile (constructor-parameter route would break the spec's builder call-site for marginal gain; the configure-before-expose contract stays in the javadoc).
Review summary (accompanies my inline review comments: #3292 (review))SummaryRe-review after One gate: Automated review by github-manager-bot |
…solution BuilderBootstrapSmokeTest failed on Windows: WorkspaceContextMiddleware globs the knowledge directory before the workspace root exists, and the boundary check then resolved the candidate up to the nearest existing ancestor — above the workspace root — while the namespace root anchored at cwd.toRealPath() had fallen back to the lexical form because cwd did not exist yet. On hosts where the two forms differ (Windows 8.3 short names like RUNNER~1, macOS /var vs /private/var) the prefix comparison rejected paths that sit inside the caller's own namespace. The namespace root now goes through the same physicalPath() resolution as the candidate, so both sides walk up to the same ancestor and agree by construction, regardless of cwd existence or path aliases. A link swapped in for a namespace directory now re-anchors the boundary to its target instead of failing closed; that trade-off is documented. Adds a regression test that reads and globs through a not-yet-created workspace root, which reproduces the aliasing mismatch locally.
|
Windows CI failure explained and fixed in 391a14c. The 4 The namespace root now goes through the same |
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Re-review after 391a14cc. The delta is exactly what the Windows failure needed: the namespace root is now anchored through the same physicalPath() walk as the candidate, so a not-yet-created workspace root and path aliases (RUNNER~1, /var → /private/var) land on the same nearest-existing-ancestor on both sides instead of one lexical / one real. The new cold-workspace test covers both affected routes (read → not found, glob → empty success). The previous round's functional findings stay resolved — physical resolution, casing, TOCTOU documentation and the symlink escape tests are all still in place.
One property moved, and it is the one thing I would like a maintainer to confirm before this lands: anchoring nsRoot physically means a symlink swapped in for the namespace directory itself now re-anchors the boundary instead of failing closed (the reworded javadoc acknowledges this). Reachability through the file API is nil — nothing in LocalFilesystem calls Files.createSymbolicLink — so it is a defence-in-depth loss, not a tenant-side escape, and I left it as a Warning with a one-loop-per-call alternative that keeps both halves.
Findings
- [Warning]
LocalFilesystem.java:762— namespace root resolved physically ⇒ a swappedcwd/<ns>symlink re-anchors the boundary instead of failing closed; suggestedFiles.isSymbolicLinkguard on each namespace component. - [Info]
LocalFilesystem.java:791—physicalPath()now runs twice per guarded resolution and climbs ancestor-by-ancestor while the workspace is missing;physicalPath(cwd)is instance-immutable and can be computed once. - [Info]
LocalFilesystemModeTest.java:502— the changed property itself has no test; suggested a symlinked-namespace-root case and a symlinked-ancestor alias case.
Carried over from the previous round, still open and not repeated here: LocalFilesystemSpec.java:346 (ROOTED behaviour flip with no opt-out / migration note), LocalFilesystem.java:97 (namespaceBoundary is non-final mutable on a shared instance), and the physicalPath() lexical-floor note.
Gate
CI on 391a14cc is still running (build (ubuntu-latest), build (windows-latest) and Check License pending; Check Module Sync and license/cla pass), and GitHub reports reviewDecision=REVIEW_REQUIRED. Not approving this round: the re-anchor semantics deserve an explicit maintainer call, and the Windows result is what proves the fix. Happy to re-review on request once the run is green.
Automated review by github-manager-bot
| if (ns == null || ns.isEmpty()) { | ||
| return; | ||
| } | ||
| Path nsRoot = physicalPath(cwd.resolve(String.join("/", ns))); |
There was a problem hiding this comment.
[Warning] Resolving nsRoot through physicalPath() fixes the false-reject (good), but it also drops the fail-closed behaviour the previous revision had for a swapped namespace directory. Before: nsRoot was physicalCwd().resolve(ns).normalize(), with the namespace components kept lexical, so if cwd/<ns> had been replaced by a link into a sibling namespace, the candidate resolved through the link while the root did not, and the check threw. Now both sides are link-resolved, so cwd/<ns> -> cwd/<siblingNs> makes the two sides agree and the cross-namespace path is accepted — the reworded javadoc states that trade-off explicitly ("re-anchors the boundary to its target rather than being detectable from here").
I'm calling it a Warning rather than a Critical because of reachability: planting that link needs write access at the workspace-root level, and a bounded tenant cannot get there through the LocalFilesystem API (its write/edit/glob/delete path never calls Files.createSymbolicLink). What is lost is defence-in-depth against an operator mistake or a framework bug that materialises a namespace directory as a symlink. One caveat worth recording: the boundary was never a control for the shell-bearing variant — LocalFilesystemWithShell.execute() runs sh -c with the namespace directory as the process working directory and no command filtering, and that class's javadoc states it provides no sandboxing or process isolation; that configuration relies on the sandbox layer, not on this check.
The cheapest way to keep both properties is to leave the comparison exactly as it is now and reject a linked namespace component up front, before the comparison:
Path nsDir = cwd;
for (String segment : ns) {
nsDir = nsDir.resolve(segment);
if (Files.isSymbolicLink(nsDir)) {
throw rootAccessDenied(resolved); // namespace dirs are framework-managed, never links
}
}
Path nsRoot = physicalPath(nsDir);That keeps the alias normalisation (RUNNER~1, /var → /private/var) and the on-disk casing on both sides, and restores fail-closed for the swapped-directory case. Anchoring the root lexically instead (physicalPath(cwd).resolve(ns).normalize()) also restores fail-closed, but reintroduces a casing asymmetry on case-insensitive hosts — the candidate would be fully real-pathed while the namespace suffix stays in its configured casing — so the link guard is the better half of the two. Whichever way it goes, if re-anchoring really is the intended semantics, the namespaceBoundary(boolean) javadoc at line 270 should say so in those words: today it describes the consequence in passing, and a reader who saw the previous "fails closed" wording would not learn from here that the guarantee moved.
There was a problem hiding this comment.
Implemented in 3ac7058 using exactly the sketched guard: every namespace component is checked with Files.isSymbolicLink before the comparison and a linked namespace directory is rejected outright (fail closed), while alias resolution on cwd itself (8.3 short names, /var) stays tolerated and both sides still real-path consistently. The shell caveat is now recorded in the namespaceBoundary(boolean) javadoc. This also removes the maintainer call the re-anchor question needed — the original fail-closed property is back.
| * lexical form is returned as a floor: no resolvable outside location can slip through, | ||
| * and the subsequent file operation fails on its own for the unresolvable remainder. | ||
| */ | ||
| private static Path physicalPath(Path path) { |
There was a problem hiding this comment.
[Info] physicalPath() is now called twice per guarded resolution — once for the namespace root at line 762, once for the candidate at line 763 — and each call is a loop that issues a toRealPath() plus a Files.isSymbolicLink() for every ancestor it climbs. In the exact case this commit targets (the workspace root is not created yet), both calls climb the whole missing suffix before the operation fails, so a cold read/glob/ls pays roughly 2 * depth stat+realpath pairs — and keeps paying it for as long as the workspace stays empty.
My earlier note about a per-namespace cache still stands as declined: the namespace comes from RuntimeContext per call, so a cache keyed by the instance alone would be wrong. The cwd half, however, is immutable for the lifetime of the instance, so physicalPath(cwd) can be a final field computed once in the constructor and the namespace suffix joined onto it per call (the link guard sketched above fits that shape naturally). That halves the resolution cost of the boundary check on the hot path for every ROOTED-mode file operation.
There was a problem hiding this comment.
Addressed in 3ac7058 via the cached physical cwd — the per-call work is now one join + link guard + one toRealPath for the namespace suffix, plus the candidate resolution.
| .namespaceBoundary(true); | ||
| RuntimeContext rc = RuntimeContext.builder().userId("user-1").build(); | ||
|
|
||
| ReadResult r = fs.read(rc, "notes.md", 0, 0); |
There was a problem hiding this comment.
[Info] Right regression guard for the Windows failure, and asserting both routes is the correct choice — read must degrade to not found instead of tripping the boundary, and glob must return an empty success instead of throwing; those are the two callers that actually hit a cold workspace.
Two additions would pin the semantics this commit changed instead of leaving them to the javadoc:
- A case where the own-namespace directory is replaced by a link into a sibling namespace, asserting whichever behaviour the maintainers decide (fail closed, or allow-after-re-anchor). Nothing exercises that path today, and it is the one property this commit actually moved — without a test it can silently flip back in either direction.
- Where feasible, a case that builds the workspace under a symlinked ancestor (guarded by the existing
symlinksSupportedprobe and skipped when unsupported). Right now the alias-normalisation property both sides rely on is only implied by whatever@TempDirhappens to return on a given platform, so a future change to how the root is anchored would be caught here only by accident.
There was a problem hiding this comment.
Both added in 3ac7058: rooted_symlinkedNamespaceDirectoryRejected pins fail-closed via absolute and relative routes, and rooted_symlinkedWorkspaceAliasTolerated builds the workspace behind a symlinked ancestor (guarded by the same symlinksSupported probe) and asserts relative and absolute access through the alias.
Review follow-ups on the namespace boundary: - A link swapped in for a namespace directory re-anchored the boundary to its target, accepting cross-namespace access. Namespace components are now checked with Files.isSymbolicLink before the comparison and rejected outright (fail closed), while path aliases on cwd itself (Windows 8.3 short names, macOS /var) stay tolerated. - LocalFilesystemSpec gains namespaceBoundary(Boolean) as an explicit opt-out/in for operators upgrading ROOTED deployments whose absolute keys legitimately addressed shared content under the workspace root; the migration note now lives in the harness filesystem docs (en+zh). - physicalPath(cwd) is cached per instance (cwd is immutable), halving the resolution cost of the guarded hot path; a fully unresolved candidate now raises a distinct "could not be resolved" error instead of a misleading namespace message; namespaceBoundary is volatile to make a late configuration publish safely. - Tests pin the moved semantics: a linked namespace directory is rejected via absolute and relative routes, a symlinked workspace ancestor is tolerated, and the spec default blocks while the escape hatch restores legacy absolute access.
|
All open findings from the last two review rounds are addressed in 3ac7058:
Harness suite: 1072 tests, 0 failures (14 skipped, baseline); @oss-maintainer happy to take a re-review once it's green — the Windows result and these tests now pin all the moved properties. |
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Re-review after the two new commits: this now addresses every outstanding point from my previous review - the linked-namespace-directory case fails closed instead of re-anchoring the boundary, the cwd physical form is cached instead of re-walked per call, the boundary flag is safely published, and LocalFilesystemSpec.namespaceBoundary(Boolean) gives deployments an explicit opt-out for the absolute-path behaviour change (documented in both the en and zh filesystem docs, with tests for the reject/allow sides and the escape hatch). LGTM, approving.
Findings
- [Info]
LocalFilesystem.java:781- the link check covers namespace segments but not the cachedcwdanchor itself; cold-workspace-then-symlink is still re-anchored onto the link target. Hardening follow-up, not blocking.
Notes
- CI was still in flight on the merge commit at review time, and the merge of
main(including theJdbcAgentStateStorechanges) resolved cleanly with no boundary-logic fallout visible in the diff. - Heads-up for maintainers: with the default now boundary-on for
ROOTED, the release notes should call outnamespaceBoundary(false)for single-tenant deployments that legitimately addressed shared workspace content by absolute path.
Automated review by github-manager-bot
| Path nsDir = physicalCwd(); | ||
| for (String segment : ns) { | ||
| nsDir = nsDir.resolve(segment); | ||
| if (Files.isSymbolicLink(nsDir)) { |
There was a problem hiding this comment.
[Info] Nice - the fail-closed guard is exactly the shape suggested, and the cached cwd anchor removes the repeated ancestor walk. One residual edge worth a follow-up: the loop link-checks the namespace segments but never the anchor itself, and physicalCwd() is filled once and never revalidated. If the workspace root does not exist at the first guarded resolution (cold workspace) and is later created as a symlink (or under a newly symlinked component), the cached anchor keeps the stale lexical form while the per-call physicalPath(resolved) side follows the link, so nsRoot gets re-anchored onto the link target and the comparison passes against a root outside the intended workspace. Reaching it needs write access above the workspace root, so this is a hardening note rather than a blocker - a Files.isSymbolicLink(cwd) check when the cache is filled (or re-resolving when the cached anchor's lexical form no longer matches cwd) would close it.
There was a problem hiding this comment.
Closed in fb7c454 with the deeper of the two options: the cache is now filled only once cwd exists, so the cold-anchor state class is gone entirely — there is no stale lexical form for a later-materialised link to be followed through, and the cold workspace simply re-resolves per call until the root exists (the climb is transient by definition). A cache that goes stale after filling (root swapped or removed) can only make the candidate and the namespace root disagree, which fails closed — it can never silently re-anchor. One property is deliberately kept and now documented in the namespaceBoundary(boolean) javadoc: a root that materialises as a link before the first guarded call anchors at its target, the same way as a pre-existing path alias — distinguishing the two at fill time is not possible without breaking the alias tolerance (8.3 short names, /var → /private/var), and reaching either requires operator-level write access above the workspace root, so it stays recorded as an operator-level assumption rather than a tenant-side guarantee.
A cold anchor sits above a not-yet-existing workspace root and keeps a stale lexical form. If the root later materialised as a symbolic link, the namespace resolution followed it from that stale form and silently re-anchored the boundary onto the link's target. The cache is now filled only once cwd exists; a cache that goes stale afterwards can only make the candidate and the namespace root disagree, which fails closed. A root that materialises as a link is followed the same way as a pre-existing path alias (operator-level, outside tenant reach), which the namespaceBoundary javadoc now records.
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Re-reviewed fb7c4549 ("never cache a cold physical cwd anchor") — the diff is exactly what the last review round sketched: physicalCwd() now fills the cache only once cwd exists, so a workspace root that later materialises as a symlink can no longer silently re-anchor the namespace boundary from a stale lexical form; cold paths fail closed per-call, and the javadoc + boundary-limitation notes are updated to match. The fail-closed opt-out from 3ac7058f is unchanged. CLA signed, tests updated. All my prior findings are addressed — approving on the new head; merging remains a maintainer call.
Automated review by github-manager-bot
## Description
With the default local filesystem, a blank or relative path reaches across
namespaces:
- `grep(pattern, "")` returns matches from another user's `MEMORY.md`,
content included; `ls("")` and `glob("**/*.md", "")` list the sibling
namespaces.
- `grep(pattern, ".")` behaves the same, because the overlay hands the same
path to the upper (workspace) and lower (project) layers, and the default
workspace is a subtree of the project directory: a recursive search from
the project root walks every namespace under it.
`LocalFilesystem.resolvePath` passes a blank key to the namespace prefix
unchanged, so it resolves to `cwd`, the workspace root. The project layer
carries no namespace at all, so any recursive enumeration from there covers
the whole workspace.
### What changed
- A blank key is resolved as `.` before the namespace is applied, so an
empty path means "the caller's root" instead of the shared workspace root.
Deployments without a namespace resolve to the same directory as before.
- `LocalFilesystem` can exclude a subtree from `ls`/`grep`/`glob`, and
`LocalFilesystemSpec` excludes the workspace from the project layer while
it is namespaced — a shared workspace (`sharedLocalWorkspace(true)`)
belongs to every caller equally and stays enumerable. The exclusion prunes
the walk itself (directory visitors skip the subtree) instead of filtering
results after visiting every file. Reads and writes still reach the
workspace; only enumeration is bounded. Addressing the excluded subtree as
an explicit search root now yields nothing rather than walking it.
Absolute paths and `..` segments are out of scope: agentscope-ai#3292 covers the former,
agentscope-ai#3378 the latter, and the shell keeps its own project-rooted working
directory (agentscope-ai#2329).
### Tests
- New: as one user, a blank, relative or glob search sees nothing under
another user's namespace — through the workspace layer and through a
workspace nested in the project directory, in both the default and the
writable-project construction.
- New: a shared workspace stays enumerable through the project layer, so the
exclusion does not over-reach into single-tenant deployments.
- `mvn -pl agentscope-harness test`: 1622 tests, 0 failures.
## Description
With the default local filesystem, the project layer reaches across
namespaces in two ways:
- Enumeration: `grep(pattern, "")` returns matches from another user's
`MEMORY.md`, content included; `ls("")` and `glob("**/*.md", "")` list the
sibling namespaces. The overlay hands the same path to the upper (workspace)
and lower (project) layers, the default workspace is a subtree of the
project directory, and the lower layer carries no namespace.
- Direct content access: `read`, `exists`, `edit` (copy-on-write),
`downloadFiles` and `move` fall back to the lower layer too, so a relative
path spelling the physical layout — `.agentscope/workspace/alice/MEMORY.md`
— reads alice's file, and `edit` copies it into the caller's namespace
before modifying it.
`LocalFilesystem.resolvePath` passes a blank key to the namespace prefix
unchanged, so it resolves to the workspace root; the physical layout is
reachable whenever the caller names it.
### What changed
- A blank key is resolved as `.` before the namespace is applied, so an
empty path means "the caller's root" instead of the shared workspace root.
Deployments without a namespace resolve to the same directory as before.
- `LocalFilesystem` can hide a subtree entirely: enumeration skips it while
walking, and the content operations see nothing there — reads, edits,
writes, downloads and existence checks answer "not found". Explicitly
addressing a hidden subtree as a search root yields nothing rather than
walking it.
- `LocalFilesystemSpec` hides the workspace from the project layer when the
workspace is a proper subtree of the project and namespace scoping is on.
A workspace equal to or outside the project has no nesting to hide, a
shared workspace belongs to every caller equally, and the projectFs write
route carries the namespace factory itself, so physical-layout spellings
resolve under the caller's own prefix either way. Project files outside
the workspace subtree stay shared, like `AGENTS.md` and `knowledge/`.
Absolute paths and `..` segments are out of scope: agentscope-ai#3292 covers the former,
agentscope-ai#3378 the latter, and the shell keeps its own project-rooted working
directory (agentscope-ai#2329).
### Tests
- New: as one user, a blank, relative or glob search sees nothing under
another user's namespace — in both the default and the writable-project
construction — and the content operations answer "not found" for a
sibling namespace spelled through the physical layout, while project
files outside the workspace and the caller's own namespace stay readable.
- New: a shared workspace stays enumerable through the project layer, so
the boundary does not over-reach into single-tenant deployments.
- New: `memory_get` cannot fetch a sibling namespace's content by spelling
the physical layout.
- `mvn -pl agentscope-harness test`: 1622 tests, 0 failures.
## Description
With the default local filesystem, the project layer reaches across
namespaces in two ways:
- Enumeration: `grep(pattern, "")` returns matches from another user's
`MEMORY.md`, content included; `ls("")` and `glob("**/*.md", "")` list the
sibling namespaces. The overlay hands the same path to the upper (workspace)
and lower (project) layers, the default workspace is a subtree of the
project directory, and the lower layer carries no namespace.
- Direct content access: `read`, `exists`, `edit` (copy-on-write),
`downloadFiles` and `move` fall back to the lower layer too, so a relative
path spelling the physical layout — `.agentscope/workspace/alice/MEMORY.md`
— reads alice's file, and `edit` copies it into the caller's namespace
before modifying it.
`LocalFilesystem.resolvePath` passes a blank key to the namespace prefix
unchanged, so it resolves to the workspace root; the physical layout is
reachable whenever the caller names it.
### What changed
- A blank key is resolved as `.` before the namespace is applied, so an
empty path means "the caller's root" instead of the shared workspace root.
Deployments without a namespace resolve to the same directory as before.
- `LocalFilesystem` can hide a subtree entirely: enumeration skips it while
walking, and the content operations see nothing there — reads, edits,
writes, downloads and existence checks answer "not found". Explicitly
addressing a hidden subtree as a search root yields nothing rather than
walking it.
- `LocalFilesystemSpec` hides the workspace from the project layer when the
workspace is a proper subtree of the project and namespace scoping is on.
A workspace equal to or outside the project has no nesting to hide, a
shared workspace belongs to every caller equally, and the projectFs write
route carries the namespace factory itself, so physical-layout spellings
resolve under the caller's own prefix either way. Project files outside
the workspace subtree stay shared, like `AGENTS.md` and `knowledge/`.
Absolute paths and `..` segments are out of scope: agentscope-ai#3292 covers the former,
agentscope-ai#3378 the latter, and the shell keeps its own project-rooted working
directory (agentscope-ai#2329).
### Tests
- New: as one user, a blank, relative or glob search sees nothing under
another user's namespace — in both the default and the writable-project
construction — and the content operations answer "not found" for a
sibling namespace spelled through the physical layout, while project
files outside the workspace and the caller's own namespace stay readable.
- New: a shared workspace stays enumerable through the project layer, so
the boundary does not over-reach into single-tenant deployments.
- New: `memory_get` cannot fetch a sibling namespace's content by spelling
the physical layout.
- `mvn -pl agentscope-harness test`: 1622 tests, 0 failures.
## Description
With the default local filesystem, the project layer reaches across
namespaces in three ways:
- Enumeration: `grep(pattern, "")` returns matches from another user's
`MEMORY.md`, content included; `ls("")` and `glob("**/*.md", "")` list the
sibling namespaces. The overlay hands the same path to the upper (workspace)
and lower (project) layers, the default workspace is a subtree of the
project directory, and the lower layer carries no namespace.
- Direct content access: `read`, `exists`, `edit` (copy-on-write),
`downloadFiles` and `move` fall back to the lower layer too, so a relative
path spelling the physical layout - `.agentscope/workspace/alice/MEMORY.md`
- reads alice's file, and `edit` copies it into the caller's namespace
before modifying it.
- Absolute paths: the namespace prefix is skipped for absolute spellings, so
without a boundary the `projectFs` write route would run a delete or move
against an absolute path inside the workspace subtree.
Previously `LocalFilesystem.resolvePath` passed a blank key to the namespace
prefix unchanged, so it resolved to the workspace root; the physical layout
was reachable whenever the caller named it.
### What changed
- A blank key is resolved as `.` before the namespace is applied, so an
empty path means "the caller's root" instead of the shared workspace root.
Deployments without a namespace resolve to the same directory as before.
- `LocalFilesystem` can hide a subtree entirely: enumeration skips it while
walking, and the content operations - reads, edits, writes, deletes, moves,
downloads, uploads and existence checks - see nothing there. `delete`
treats the subtree as absent (an idempotent no-op that never walks it),
`move` can neither move a file out of or into the subtree, and both `move`
and recursive `delete` refuse a directory that contains it outright rather
than partially touch it. Explicitly addressing a hidden subtree as a
search root yields nothing rather than walking it, and a `walkFileTree`
visitor that cannot enter a directory skips and continues instead of
propagating.
- `LocalFilesystemSpec` hides the workspace from the project layers when the
workspace is a proper subtree of the project and namespace scoping is on -
both the read-only lower layer and, for the same reason, the `projectFs`
write route, whose absolute paths skip the namespace prefix. A workspace
equal to or outside the project has no nesting to hide, a shared workspace
belongs to every caller equally, and project files outside the workspace
subtree stay shared, like `AGENTS.md` and `knowledge/`.
- `relativeForGlob` compares the first path name instead of the string, so a
legitimate directory literally named `..cache` is a descendant, not a
traversal escape.
- `docs/v2/{zh,en}/docs/harness/filesystem.md` note the boundary in the
Overlay filesystem section, the project-writable read behavior, and the
mode table.
Absolute paths in the upper (workspace) layer and `..` segments are out of
scope: agentscope-ai#3292 covers the former, agentscope-ai#3378 the latter. The shell keeps its own
project-rooted working directory, so `execute` is not bound by these guards
(agentscope-ai#2329). The ripgrep `--glob` exclusions assume rg matches globs against
paths relative to the search root; where that does not hold, the boundary
still holds because the default workspace lives under a hidden directory
that rg skips by default, and the `walkFileTree` fallback applies the same
exclusions directly.
### Tests
- New: as one user, a blank, relative or glob search sees nothing under
another user's namespace - in both the default and the writable-project
construction - and the content operations answer "not found" for a
sibling namespace spelled through the physical layout, while project
files outside the workspace and the caller's own namespace stay readable.
- New: direct use of the hidden lower layer - `delete` leaves the subtree
untouched, `move` cannot cross the boundary in either direction, writes
cannot land inside it (the target does not exist yet, so the assertion
cannot pass merely because the file is there), and operations that start
at an ancestor (recursive delete, directory move) are refused outright
instead of partially touching the hidden subtree. Each of these assertions
was verified to fail with its guard removed.
- New: a shared workspace stays enumerable through the project layer, so
the boundary does not over-reach into single-tenant deployments.
- New: `memory_get` cannot fetch a sibling namespace's content. This test's
workspace is a standalone temp directory, so it pins the blank-key and
namespace-prefix resolution end to end; the real project-layer boundary is
exercised by the boundary tests below.
- `mvn -pl agentscope-harness test`: 1626 tests, 0 failures.
Fixes agentscope-ai#4069
## Description
With the default local filesystem, the project layer reaches across
namespaces in three ways:
- Enumeration: `grep(pattern, "")` returns matches from another user's
`MEMORY.md`, content included; `ls("")` and `glob("**/*.md", "")` list the
sibling namespaces. The overlay hands the same path to the upper (workspace)
and lower (project) layers, the default workspace is a subtree of the
project directory, and the lower layer carries no namespace.
- Direct content access: `read`, `exists`, `edit` (copy-on-write),
`downloadFiles` and `move` fall back to the lower layer too, so a relative
path spelling the physical layout - `.agentscope/workspace/alice/MEMORY.md`
- reads alice's file, and `edit` copies it into the caller's namespace
before modifying it.
- Absolute paths: the namespace prefix is skipped for absolute spellings, so
without a boundary the `projectFs` write route would run a delete or move
against an absolute path inside the workspace subtree.
Previously `LocalFilesystem.resolvePath` passed a blank key to the namespace
prefix unchanged, so it resolved to the workspace root; the physical layout
was reachable whenever the caller named it.
### What changed
- A blank key is resolved as `.` before the namespace is applied, so an
empty path means "the caller's root" instead of the shared workspace root.
Deployments without a namespace resolve to the same directory as before.
- `LocalFilesystem` can hide a subtree entirely: enumeration skips it while
walking, and the content operations - reads, edits, writes, deletes, moves,
downloads, uploads and existence checks - see nothing there. `delete`
treats the subtree as absent (an idempotent no-op that never walks it),
`move` can neither move a file out of or into the subtree, and both `move`
and recursive `delete` refuse a directory that contains it outright rather
than partially touch it. Explicitly addressing a hidden subtree as a
search root yields nothing rather than walking it, and a `walkFileTree`
visitor that cannot enter a directory skips and continues instead of
propagating.
- `LocalFilesystemSpec` hides the workspace from the project layers when the
workspace is a proper subtree of the project and namespace scoping is on -
both the read-only lower layer and, for the same reason, the `projectFs`
write route, whose absolute paths skip the namespace prefix. A workspace
equal to or outside the project has no nesting to hide, a shared workspace
belongs to every caller equally, and project files outside the workspace
subtree stay shared, like `AGENTS.md` and `knowledge/`.
- The ripgrep path of `grep` runs rg with its working directory set to the
search root: `--glob` patterns match against paths relative to the working
directory, so the excluded-subtree globs missed whenever the parent process
was started outside the search root. Output paths do not depend on the
working directory, so entry-path resolution is unaffected.
- `relativeForGlob` compares the first path name instead of the string, so a
legitimate directory literally named `..cache` is a descendant, not a
traversal escape.
- `docs/v2/{zh,en}/docs/harness/filesystem.md` note the boundary in the
Overlay filesystem section, the project-writable read behavior, and the
mode table.
Absolute paths in the upper (workspace) layer and `..` segments are out of
scope: agentscope-ai#3292 covers the former, agentscope-ai#3378 the latter. The shell keeps its own
project-rooted working directory, so `execute` is not bound by these guards
(agentscope-ai#2329). The `walkFileTree` fallback of `grep` applies the same exclusions
directly.
### Tests
- New: as one user, a blank, relative or glob search sees nothing under
another user's namespace - in both the default and the writable-project
construction - and the content operations answer "not found" for a
sibling namespace spelled through the physical layout, while project
files outside the workspace and the caller's own namespace stay readable.
- New: direct use of the hidden lower layer - `delete` leaves the subtree
untouched, `move` cannot cross the boundary in either direction, writes
cannot land inside it (the target does not exist yet, so the assertion
cannot pass merely because the file is there), and operations that start
at an ancestor (recursive delete, directory move) are refused outright
instead of partially touching the hidden subtree. Each of these assertions
was verified to fail with its guard removed.
- New: the ripgrep path of `grep` keeps the boundary when the parent process
cwd is unrelated to the search root - the pinned directory is deliberately
not hidden, so ripgrep's default hidden-file skip cannot mask the result
(verified to fail with the working-directory alignment removed). Skipped
when ripgrep is not installed.
- New: a shared workspace stays enumerable through the project layer, so
the boundary does not over-reach into single-tenant deployments.
- New: `memory_get` cannot fetch a sibling namespace's content. This test's
workspace is a standalone temp directory, so it pins the blank-key and
namespace-prefix resolution end to end; the real project-layer boundary is
exercised by the boundary tests below.
- `mvn -pl agentscope-harness test`: 1626 tests, 0 failures.
Fixes agentscope-ai#4069
## Description
With the default local filesystem, the project layer reaches across
namespaces in three ways:
- Enumeration: `grep(pattern, "")` returns matches from another user's
`MEMORY.md`, content included; `ls("")` and `glob("**/*.md", "")` list the
sibling namespaces. The overlay hands the same path to the upper (workspace)
and lower (project) layers, the default workspace is a subtree of the
project directory, and the lower layer carries no namespace.
- Direct content access: `read`, `exists`, `edit` (copy-on-write),
`downloadFiles` and `move` fall back to the lower layer too, so a relative
path spelling the physical layout - `.agentscope/workspace/alice/MEMORY.md`
- reads alice's file, and `edit` copies it into the caller's namespace
before modifying it.
- Absolute paths: the namespace prefix is skipped for absolute spellings, so
without a boundary the `projectFs` write route would run a delete or move
against an absolute path inside the workspace subtree.
Previously `LocalFilesystem.resolvePath` passed a blank key to the namespace
prefix unchanged, so it resolved to the workspace root; the physical layout
was reachable whenever the caller named it.
### What changed
- A blank key is resolved as `.` before the namespace is applied, so an
empty path means "the caller's root" instead of the shared workspace root.
Deployments without a namespace resolve to the same directory as before.
- `LocalFilesystem` can hide a subtree entirely: enumeration skips it while
walking, and the content operations - reads, edits, writes, deletes, moves,
downloads, uploads and existence checks - see nothing there. `delete`
treats the subtree as absent (an idempotent no-op that never walks it),
`move` can neither move a file out of or into the subtree, and both `move`
and recursive `delete` refuse a directory that contains it outright rather
than partially touch it. Explicitly addressing a hidden subtree as a
search root yields nothing rather than walking it, and a `walkFileTree`
visitor that cannot enter a directory skips and continues instead of
propagating.
- `LocalFilesystemSpec` hides the workspace from the project layers when the
workspace is a proper subtree of the project and namespace scoping is on -
both the read-only lower layer and, for the same reason, the `projectFs`
write route, whose absolute paths skip the namespace prefix. A workspace
equal to or outside the project has no nesting to hide, a shared workspace
belongs to every caller equally, and project files outside the workspace
subtree stay shared, like `AGENTS.md` and `knowledge/`.
- The ripgrep path of `grep` runs rg with its working directory set to the
search root: `--glob` patterns match against paths relative to the working
directory, so the excluded-subtree globs missed whenever the parent process
was started outside the search root. Output paths do not depend on the
working directory, so entry-path resolution is unaffected.
- `relativeForGlob` compares the first path name instead of the string, so a
legitimate directory literally named `..cache` is a descendant, not a
traversal escape.
- `docs/v2/{zh,en}/docs/harness/filesystem.md` note the boundary in the
Overlay filesystem section, the project-writable read behavior, and the
mode table.
Absolute paths in the upper (workspace) layer and `..` segments are out of
scope: agentscope-ai#3292 covers the former, agentscope-ai#3378 the latter. The shell keeps its own
project-rooted working directory, so `execute` is not bound by these guards
(agentscope-ai#2329). The `walkFileTree` fallback of `grep` applies the same exclusions
directly.
### Tests
- New: as one user, a blank, relative or glob search sees nothing under
another user's namespace - in both the default and the writable-project
construction - and the content operations answer "not found" for a
sibling namespace spelled through the physical layout, while project
files outside the workspace and the caller's own namespace stay readable.
- New: direct use of the hidden lower layer - `delete` leaves the subtree
untouched, `move` cannot cross the boundary in either direction, writes
cannot land inside it (the target does not exist yet, so the assertion
cannot pass merely because the file is there), and operations that start
at an ancestor (recursive delete, directory move) are refused outright
instead of partially touching the hidden subtree. Each of these assertions
was verified to fail with its guard removed.
- New: the ripgrep path of `grep` keeps the boundary when the parent process
cwd is unrelated to the search root - the pinned directory is deliberately
not hidden, so ripgrep's default hidden-file skip cannot mask the result
(verified to fail with the working-directory alignment removed). Skipped
when ripgrep is not installed.
- New: a shared workspace stays enumerable through the project layer, so
the boundary does not over-reach into single-tenant deployments.
- `mvn -pl agentscope-harness test`: 1627 tests, 0 failures (one is skipped
without ripgrep).
Fixes agentscope-ai#4069
## Description
With the default local filesystem, the project layer reaches across
namespaces in three ways:
- Enumeration: `grep(pattern, "")` returns matches from another user's
`MEMORY.md`, content included; `ls("")` and `glob("**/*.md", "")` list the
sibling namespaces. The overlay hands the same path to the upper (workspace)
and lower (project) layers, the default workspace is a subtree of the
project directory, and the lower layer carries no namespace.
- Direct content access: `read`, `exists`, `edit` (copy-on-write),
`downloadFiles` and `move` fall back to the lower layer too, so a relative
path spelling the physical layout - `.agentscope/workspace/alice/MEMORY.md`
- reads alice's file, and `edit` copies it into the caller's namespace
before modifying it.
- Absolute paths: the namespace prefix is skipped for absolute spellings, so
without a boundary the `projectFs` write route would run a delete or move
against an absolute path inside the workspace subtree.
Previously `LocalFilesystem.resolvePath` passed a blank key to the namespace
prefix unchanged, so it resolved to the workspace root; the physical layout
was reachable whenever the caller named it.
### What changed
- A blank key is resolved as `.` before the namespace is applied, so an
empty path means "the caller's root" instead of the shared workspace root.
Deployments without a namespace resolve to the same directory as before.
- `LocalFilesystem` can hide a subtree entirely: enumeration skips it while
walking, and the content operations - reads, edits, writes, deletes, moves,
downloads, uploads and existence checks - see nothing there. `delete`
treats the subtree as absent (an idempotent no-op that never walks it),
`move` can neither move a file out of or into the subtree, and both `move`
and recursive `delete` refuse a directory that contains it outright rather
than partially touch it. Explicitly addressing a hidden subtree as a
search root yields nothing rather than walking it, and a `walkFileTree`
visitor that cannot enter a directory skips and continues instead of
propagating. The check resolves the path first, so a symbolic link that
points into the subtree is hidden too; `delete` and `move` still act on
the link entry itself, which never reaches the hidden target. Every
rejection reads like a missing path, so refusing a hidden path does not
announce that something is hidden.
- `LocalFilesystemSpec` hides the workspace from the project layers when the
workspace is a proper subtree of the project and namespace scoping is on -
both the read-only lower layer and, for the same reason, the `projectFs`
write route, whose absolute paths skip the namespace prefix. A workspace
equal to or outside the project has no nesting to hide, a shared workspace
belongs to every caller equally, and project files outside the workspace
subtree stay shared, like `AGENTS.md` and `knowledge/`.
- The ripgrep path of `grep` runs rg with its working directory set to the
search root: `--glob` patterns match against paths relative to the working
directory, so the excluded-subtree globs missed whenever the parent process
was started outside the search root. Output paths do not depend on the
working directory, so entry-path resolution is unaffected.
- `relativeForGlob` compares the first path name instead of the string, so a
legitimate directory literally named `..cache` is a descendant, not a
traversal escape.
- `docs/v2/{zh,en}/docs/harness/filesystem.md` note the boundary in the
Overlay filesystem section, the project-writable read behavior, and the
mode table.
Absolute paths in the upper (workspace) layer and `..` segments are out of
scope: agentscope-ai#3292 covers the former, agentscope-ai#3378 the latter. Symbolic links are covered
here - the path is resolved before the boundary is applied. The shell keeps its own
project-rooted working directory, so `execute` is not bound by these guards
(agentscope-ai#2329). The `walkFileTree` fallback of `grep` applies the same exclusions
directly.
### Tests
- New: as one user, a blank, relative or glob search sees nothing under
another user's namespace - in both the default and the writable-project
construction - and the content operations answer "not found" for a
sibling namespace spelled through the physical layout, while project
files outside the workspace and the caller's own namespace stay readable.
- New: a symbolic link planted in the project that points into the
workspace subtree stays hidden - `read`, `ls` and `write` see nothing
through it, and the target file is untouched. The case skips on hosts
that cannot create links.
- New: direct use of the hidden lower layer - `delete` leaves the subtree
untouched, `move` cannot cross the boundary in either direction, writes
cannot land inside it (the target does not exist yet, so the assertion
cannot pass merely because the file is there), and operations that start
at an ancestor (recursive delete, directory move) are refused outright
instead of partially touching the hidden subtree. Each of these assertions
was verified to fail with its guard removed.
- New: the ripgrep path of `grep` keeps the boundary when the parent process
cwd is unrelated to the search root - the pinned directory is deliberately
not hidden, so ripgrep's default hidden-file skip cannot mask the result
(verified to fail with the working-directory alignment removed). Skipped
when ripgrep is not installed.
- New: a shared workspace stays enumerable through the project layer, so
the boundary does not over-reach into single-tenant deployments.
- `mvn -pl agentscope-harness test`: 1628 tests, 0 failures, 37 skipped
(Docker, ripgrep and symlink cases that this host cannot run).
Fixes agentscope-ai#4069
## Description
With the default local filesystem, the project layer reaches across
namespaces in three ways:
- Enumeration: `grep(pattern, "")` returns matches from another user's
`MEMORY.md`, content included; `ls("")` and `glob("**/*.md", "")` list the
sibling namespaces. The overlay hands the same path to the upper (workspace)
and lower (project) layers, the default workspace is a subtree of the
project directory, and the lower layer carries no namespace.
- Direct content access: `read`, `exists`, `edit` (copy-on-write),
`downloadFiles` and `move` fall back to the lower layer too, so a relative
path spelling the physical layout - `.agentscope/workspace/alice/MEMORY.md`
- reads alice's file, and `edit` copies it into the caller's namespace
before modifying it.
- Absolute paths: the namespace prefix is skipped for absolute spellings, so
without a boundary the `projectFs` write route would run a delete or move
against an absolute path inside the workspace subtree.
Previously `LocalFilesystem.resolvePath` passed a blank key to the namespace
prefix unchanged, so it resolved to the workspace root; the physical layout
was reachable whenever the caller named it.
### What changed
- A blank key is resolved as `.` before the namespace is applied, so an
empty path means "the caller's root" instead of the shared workspace root.
Deployments without a namespace resolve to the same directory as before.
- `LocalFilesystem` can hide a subtree entirely: enumeration skips it while
walking, and the content operations - reads, edits, writes, deletes, moves,
downloads, uploads and existence checks - see nothing there. `delete`
treats the subtree as absent (an idempotent no-op that never walks it),
`move` can neither move a file out of or into the subtree, and both `move`
and recursive `delete` refuse a directory that contains it outright rather
than partially touch it. Explicitly addressing a hidden subtree as a
search root yields nothing rather than walking it, and a `walkFileTree`
visitor that cannot enter a directory skips and continues instead of
propagating. The check resolves the path first, so a symbolic link that
points into the subtree is hidden too; `delete` and `move` still act on
the link entry itself, which never reaches the hidden target. Every
rejection reads like a missing path, so refusing a hidden path does not
announce that something is hidden.
- `LocalFilesystemSpec` hides the workspace from the project layers when the
workspace is a proper subtree of the project and namespace scoping is on -
both the read-only lower layer and, for the same reason, the `projectFs`
write route, whose absolute paths skip the namespace prefix. A workspace
equal to or outside the project has no nesting to hide, a shared workspace
belongs to every caller equally, and project files outside the workspace
subtree stay shared, like `AGENTS.md` and `knowledge/`.
- The ripgrep path of `grep` runs rg with its working directory set to the
search root: `--glob` patterns match against paths relative to the working
directory, so the excluded-subtree globs missed whenever the parent process
was started outside the search root. Output paths do not depend on the
working directory, so entry-path resolution is unaffected.
- `relativeForGlob` compares the first path name instead of the string, so a
legitimate directory literally named `..cache` is a descendant, not a
traversal escape.
- `docs/v2/{zh,en}/docs/harness/filesystem.md` note the boundary in the
Overlay filesystem section, the project-writable read behavior, and the
mode table.
Absolute paths in the upper (workspace) layer and `..` segments are out of
scope: agentscope-ai#3292 covers the former, agentscope-ai#3378 the latter. Symbolic links are covered
here - the path is resolved before the boundary is applied. The shell keeps its own
project-rooted working directory, so `execute` is not bound by these guards
(agentscope-ai#2329). The `walkFileTree` fallback of `grep` applies the same exclusions
directly.
### Tests
- New: as one user, a blank, relative or glob search sees nothing under
another user's namespace - in both the default and the writable-project
construction - and the content operations answer "not found" for a
sibling namespace spelled through the physical layout, while project
files outside the workspace and the caller's own namespace stay readable.
- New: a symbolic link planted in the project that points into the
workspace subtree stays hidden - `read`, `ls` and `write` see nothing
through it, and the target file is untouched. The case skips on hosts
that cannot create links.
- New: direct use of the hidden lower layer - `delete` leaves the subtree
untouched, `move` cannot cross the boundary in either direction, writes
cannot land inside it (the target does not exist yet, so the assertion
cannot pass merely because the file is there), and operations that start
at an ancestor (recursive delete, directory move) are refused outright
instead of partially touching the hidden subtree. Each of these assertions
was verified to fail with its guard removed.
- New: the ripgrep path of `grep` keeps the boundary when the parent process
cwd is unrelated to the search root - the pinned directory is deliberately
not hidden, so ripgrep's default hidden-file skip cannot mask the result
(verified to fail with the working-directory alignment removed). Skipped
when ripgrep is not installed.
- New: a shared workspace stays enumerable through the project layer, so
the boundary does not over-reach into single-tenant deployments.
- `mvn -pl agentscope-harness test`: 1628 tests, 0 failures, 37 skipped
(Docker, ripgrep and symlink cases that this host cannot run).
Fixes agentscope-ai#4069
## Description
With the default local filesystem, the project layer reaches across
namespaces in three ways:
- Enumeration: `grep(pattern, "")` returns matches from another user's
`MEMORY.md`, content included; `ls("")` and `glob("**/*.md", "")` list the
sibling namespaces. The overlay hands the same path to the upper (workspace)
and lower (project) layers, the default workspace is a subtree of the
project directory, and the lower layer carries no namespace.
- Direct content access: `read`, `exists`, `edit` (copy-on-write),
`downloadFiles` and `move` fall back to the lower layer too, so a relative
path spelling the physical layout - `.agentscope/workspace/alice/MEMORY.md`
- reads alice's file, and `edit` copies it into the caller's namespace
before modifying it.
- Absolute paths: the namespace prefix is skipped for absolute spellings, so
without a boundary the `projectFs` write route would run a delete or move
against an absolute path inside the workspace subtree.
Previously `LocalFilesystem.resolvePath` passed a blank key to the namespace
prefix unchanged, so it resolved to the workspace root; the physical layout
was reachable whenever the caller named it.
### What changed
- A blank key is resolved as `.` before the namespace is applied, so an
empty path means "the caller's root" instead of the shared workspace root.
Deployments without a namespace resolve to the same directory as before.
- `LocalFilesystem` can hide a subtree entirely: enumeration skips it while
walking, and the content operations - reads, edits, writes, deletes, moves,
downloads, uploads and existence checks - see nothing there. `delete`
treats the subtree as absent (an idempotent no-op that never walks it),
`move` can neither move a file out of or into the subtree, and both `move`
and recursive `delete` refuse a directory that contains it outright rather
than partially touch it. Explicitly addressing a hidden subtree as a
search root yields nothing rather than walking it, and a `walkFileTree`
visitor that cannot enter a directory skips and continues instead of
propagating. The check resolves the path first, so a symbolic link that
points into the subtree is hidden too; `delete` and `move` still act on
the link entry itself, which never reaches the hidden target. Every
rejection reads like a missing path, so refusing a hidden path does not
announce that something is hidden.
- `LocalFilesystemSpec` hides the workspace from the project layers when the
workspace is a proper subtree of the project and namespace scoping is on -
both the read-only lower layer and, for the same reason, the `projectFs`
write route, whose absolute paths skip the namespace prefix. A workspace
equal to or outside the project has no nesting to hide, a shared workspace
belongs to every caller equally, and project files outside the workspace
subtree stay shared, like `AGENTS.md` and `knowledge/`.
- The ripgrep path of `grep` runs rg with its working directory set to the
search root: `--glob` patterns match against paths relative to the working
directory, so the excluded-subtree globs missed whenever the parent process
was started outside the search root. Output paths do not depend on the
working directory, so entry-path resolution is unaffected.
- `relativeForGlob` compares the first path name instead of the string, so a
legitimate directory literally named `..cache` is a descendant, not a
traversal escape.
- `docs/v2/{zh,en}/docs/harness/filesystem.md` note the boundary in the
Overlay filesystem section, the project-writable read behavior, and the
mode table.
Absolute paths in the upper (workspace) layer and `..` segments are out of
scope: agentscope-ai#3292 covers the former, agentscope-ai#3378 the latter. Symbolic links are covered
here - the path is resolved before the boundary is applied. The shell keeps its own
project-rooted working directory, so `execute` is not bound by these guards
(agentscope-ai#2329). The `walkFileTree` fallback of `grep` applies the same exclusions
directly.
### Tests
- New: as one user, a blank, relative or glob search sees nothing under
another user's namespace - in both the default and the writable-project
construction - and the content operations answer "not found" for a
sibling namespace spelled through the physical layout, while project
files outside the workspace and the caller's own namespace stay readable.
- New: a symbolic link planted in the project that points into the
workspace subtree stays hidden - `read`, `ls` and `write` see nothing
through it, and the target file is untouched. The case skips on hosts
that cannot create links.
- New: direct use of the hidden lower layer - `delete` leaves the subtree
untouched, `move` cannot cross the boundary in either direction, writes
cannot land inside it (the target does not exist yet, so the assertion
cannot pass merely because the file is there), and operations that start
at an ancestor (recursive delete, directory move) are refused outright
instead of partially touching the hidden subtree. Each of these assertions
was verified to fail with its guard removed.
- New: the ripgrep path of `grep` keeps the boundary when the parent process
cwd is unrelated to the search root - the pinned directory is deliberately
not hidden, so ripgrep's default hidden-file skip cannot mask the result
(verified to fail with the working-directory alignment removed). Skipped
when ripgrep is not installed.
- New: a shared workspace stays enumerable through the project layer, so
the boundary does not over-reach into single-tenant deployments.
- `mvn -pl agentscope-harness test`: 1628 tests, 0 failures, 37 skipped
(Docker, ripgrep and symlink cases that this host cannot run).
Fixes agentscope-ai#4069
## Description
With the default local filesystem, the project layer reaches across
namespaces in three ways:
- Enumeration: `grep(pattern, "")` returns matches from another user's
`MEMORY.md`, content included; `ls("")` and `glob("**/*.md", "")` list the
sibling namespaces. The overlay hands the same path to the upper (workspace)
and lower (project) layers, the default workspace is a subtree of the
project directory, and the lower layer carries no namespace.
- Direct content access: `read`, `exists`, `edit` (copy-on-write),
`downloadFiles` and `move` fall back to the lower layer too, so a relative
path spelling the physical layout - `.agentscope/workspace/alice/MEMORY.md`
- reads alice's file, and `edit` copies it into the caller's namespace
before modifying it.
- Absolute paths: the namespace prefix is skipped for absolute spellings, so
without a boundary the `projectFs` write route would run a delete or move
against an absolute path inside the workspace subtree.
Previously `LocalFilesystem.resolvePath` passed a blank key to the namespace
prefix unchanged, so it resolved to the workspace root; the physical layout
was reachable whenever the caller named it.
### What changed
- A blank key is resolved as `.` before the namespace is applied, so an
empty path means "the caller's root" instead of the shared workspace root.
Deployments without a namespace resolve to the same directory as before.
- `LocalFilesystem` can hide a subtree entirely: enumeration skips it while
walking, and the content operations - reads, edits, writes, deletes, moves,
downloads, uploads and existence checks - see nothing there. `delete`
treats the subtree as absent (an idempotent no-op that never walks it),
`move` can neither move a file out of or into the subtree, and both `move`
and recursive `delete` refuse a directory that contains it outright rather
than partially touch it. Explicitly addressing a hidden subtree as a
search root yields nothing rather than walking it, and a `walkFileTree`
visitor that cannot enter a directory skips and continues instead of
propagating. The check resolves the path first, so a symbolic link that
points into the subtree is hidden too; `delete` and `move` still act on
the link entry itself, which never reaches the hidden target. Every
rejection reads like a missing path, so refusing a hidden path does not
announce that something is hidden.
- `LocalFilesystemSpec` hides the workspace from the project layers when the
workspace is a proper subtree of the project and namespace scoping is on -
both the read-only lower layer and, for the same reason, the `projectFs`
write route, whose absolute paths skip the namespace prefix. A workspace
equal to or outside the project has no nesting to hide, a shared workspace
belongs to every caller equally, and project files outside the workspace
subtree stay shared, like `AGENTS.md` and `knowledge/`.
- The ripgrep path of `grep` runs rg with its working directory set to the
search root: `--glob` patterns match against paths relative to the working
directory, so the excluded-subtree globs missed whenever the parent process
was started outside the search root. Output paths do not depend on the
working directory, so entry-path resolution is unaffected.
- `relativeForGlob` compares the first path name instead of the string, so a
legitimate directory literally named `..cache` is a descendant, not a
traversal escape.
- `docs/v2/{zh,en}/docs/harness/filesystem.md` note the boundary in the
Overlay filesystem section, the project-writable read behavior, and the
mode table.
Absolute paths in the upper (workspace) layer and `..` segments are out of
scope: agentscope-ai#3292 covers the former, agentscope-ai#3378 the latter. Symbolic links are covered
here - the path is resolved before the boundary is applied. The shell keeps its own
project-rooted working directory, so `execute` is not bound by these guards
(agentscope-ai#2329). The `walkFileTree` fallback of `grep` applies the same exclusions
directly.
### Tests
- New: as one user, a blank, relative or glob search sees nothing under
another user's namespace - in both the default and the writable-project
construction - and the content operations answer "not found" for a
sibling namespace spelled through the physical layout, while project
files outside the workspace and the caller's own namespace stay readable.
- New: a symbolic link planted in the project that points into the
workspace subtree stays hidden - `read`, `ls` and `write` see nothing
through it, and the target file is untouched. The case skips on hosts
that cannot create links.
- New: direct use of the hidden lower layer - `delete` leaves the subtree
untouched, `move` cannot cross the boundary in either direction, writes
cannot land inside it (the target does not exist yet, so the assertion
cannot pass merely because the file is there), and operations that start
at an ancestor (recursive delete, directory move) are refused outright
instead of partially touching the hidden subtree. Each of these assertions
was verified to fail with its guard removed.
- New: the ripgrep path of `grep` keeps the boundary when the parent process
cwd is unrelated to the search root - the pinned directory is deliberately
not hidden, so ripgrep's default hidden-file skip cannot mask the result
(verified to fail with the working-directory alignment removed). Skipped
when ripgrep is not installed.
- New: a shared workspace stays enumerable through the project layer, so
the boundary does not over-reach into single-tenant deployments.
- `mvn -pl agentscope-harness test`: 1628 tests, 0 failures, 37 skipped
(Docker, ripgrep and symlink cases that this host cannot run).
Fixes agentscope-ai#4069
…espace-boundary # Conflicts: # agentscope-harness/src/test/java/io/agentscope/harness/agent/filesystem/LocalFilesystemModeTest.java
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
|
”zhuzhiyu.zzy“ seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
With the default local filesystem, the project layer reaches across
namespaces in three ways:
- Enumeration: `grep(pattern, "")` returns matches from another user's
`MEMORY.md`, content included; `ls("")` and `glob("**/*.md", "")` list the
sibling namespaces. The overlay hands the same path to the upper (workspace)
and lower (project) layers, the default workspace is a subtree of the
project directory, and the lower layer carries no namespace.
- Direct content access: `read`, `exists`, `edit` (copy-on-write),
`downloadFiles` and `move` fall back to the lower layer too, so a relative
path spelling the physical layout - `.agentscope/workspace/alice/MEMORY.md`
- reads alice's file, and `edit` copies it into the caller's namespace
before modifying it.
- Absolute paths: the namespace prefix is skipped for absolute spellings, so
without a boundary the `projectFs` write route would run a delete or move
against an absolute path inside the workspace subtree.
Previously `LocalFilesystem.resolvePath` passed a blank key to the namespace
prefix unchanged, so it resolved to the workspace root; the physical layout
was reachable whenever the caller named it.
- A blank key is resolved as `.` before the namespace is applied, so an
empty path means "the caller's root" instead of the shared workspace root.
Deployments without a namespace resolve to the same directory as before.
- `LocalFilesystem` can hide a subtree entirely: enumeration skips it while
walking, and the content operations - reads, edits, writes, deletes, moves,
downloads, uploads and existence checks - see nothing there. `delete`
treats the subtree as absent (an idempotent no-op that never walks it),
`move` can neither move a file out of or into the subtree, and both `move`
and recursive `delete` refuse a directory that contains it outright rather
than partially touch it. Explicitly addressing a hidden subtree as a
search root yields nothing rather than walking it, and a `walkFileTree`
visitor that cannot enter a directory skips and continues instead of
propagating. The check resolves the path first, so a symbolic link that
points into the subtree is hidden too; `delete` and `move` still act on
the link entry itself, which never reaches the hidden target. Every
rejection reads like a missing path, so refusing a hidden path does not
announce that something is hidden.
- `LocalFilesystemSpec` hides the workspace from the project layers when the
workspace is a proper subtree of the project and namespace scoping is on -
both the read-only lower layer and, for the same reason, the `projectFs`
write route, whose absolute paths skip the namespace prefix. A workspace
equal to or outside the project has no nesting to hide, a shared workspace
belongs to every caller equally, and project files outside the workspace
subtree stay shared, like `AGENTS.md` and `knowledge/`.
- The ripgrep path of `grep` runs rg with its working directory set to the
search root: `--glob` patterns match against paths relative to the working
directory, so the excluded-subtree globs missed whenever the parent process
was started outside the search root. Output paths do not depend on the
working directory, so entry-path resolution is unaffected.
- `relativeForGlob` compares the first path name instead of the string, so a
legitimate directory literally named `..cache` is a descendant, not a
traversal escape.
- `docs/v2/{zh,en}/docs/harness/filesystem.md` note the boundary in the
Overlay filesystem section, the project-writable read behavior, and the
mode table.
Absolute paths in the upper (workspace) layer and `..` segments are out of
scope: agentscope-ai#3292 covers the former, agentscope-ai#3378 the latter. Symbolic links are covered
here - the path is resolved before the boundary is applied. The shell keeps its own
project-rooted working directory, so `execute` is not bound by these guards
(agentscope-ai#2329). The `walkFileTree` fallback of `grep` applies the same exclusions
directly.
- New: as one user, a blank, relative or glob search sees nothing under
another user's namespace - in both the default and the writable-project
construction - and the content operations answer "not found" for a
sibling namespace spelled through the physical layout, while project
files outside the workspace and the caller's own namespace stay readable.
- New: a symbolic link planted in the project that points into the
workspace subtree stays hidden - `read`, `ls` and `write` see nothing
through it, and the target file is untouched. The case skips on hosts
that cannot create links.
- New: direct use of the hidden lower layer - `delete` leaves the subtree
untouched, `move` cannot cross the boundary in either direction, writes
cannot land inside it (the target does not exist yet, so the assertion
cannot pass merely because the file is there), and operations that start
at an ancestor (recursive delete, directory move) are refused outright
instead of partially touching the hidden subtree. Each of these assertions
was verified to fail with its guard removed.
- New: the ripgrep path of `grep` keeps the boundary when the parent process
cwd is unrelated to the search root - the pinned directory is deliberately
not hidden, so ripgrep's default hidden-file skip cannot mask the result
(verified to fail with the working-directory alignment removed). Skipped
when ripgrep is not installed.
- New: a shared workspace stays enumerable through the project layer, so
the boundary does not over-reach into single-tenant deployments.
- `mvn -pl agentscope-harness test`: 1628 tests, 0 failures, 37 skipped
(Docker, ripgrep and symlink cases that this host cannot run).
Fixes agentscope-ai#4069
With the default local filesystem, the project layer reaches across
namespaces in three ways:
- Enumeration: `grep(pattern, "")` returns matches from another user's
`MEMORY.md`, content included; `ls("")` and `glob("**/*.md", "")` list the
sibling namespaces. The overlay hands the same path to the upper (workspace)
and lower (project) layers, the default workspace is a subtree of the
project directory, and the lower layer carries no namespace.
- Direct content access: `read`, `exists`, `edit` (copy-on-write),
`downloadFiles` and `move` fall back to the lower layer too, so a relative
path spelling the physical layout - `.agentscope/workspace/alice/MEMORY.md`
- reads alice's file, and `edit` copies it into the caller's namespace
before modifying it.
- Absolute paths: the namespace prefix is skipped for absolute spellings, so
without a boundary the `projectFs` write route would run a delete or move
against an absolute path inside the workspace subtree.
Previously `LocalFilesystem.resolvePath` passed a blank key to the namespace
prefix unchanged, so it resolved to the workspace root; the physical layout
was reachable whenever the caller named it.
- A blank key is resolved as `.` before the namespace is applied, so an
empty path means "the caller's root" instead of the shared workspace root.
Deployments without a namespace resolve to the same directory as before.
- `LocalFilesystem` can hide a subtree entirely: enumeration skips it while
walking, and the content operations - reads, edits, writes, deletes, moves,
downloads, uploads and existence checks - see nothing there. `delete`
treats the subtree as absent (an idempotent no-op that never walks it),
`move` can neither move a file out of or into the subtree, and both `move`
and recursive `delete` refuse a directory that contains it outright rather
than partially touch it. Explicitly addressing a hidden subtree as a
search root yields nothing rather than walking it, and a `walkFileTree`
visitor that cannot enter a directory skips and continues instead of
propagating. The check resolves the path first, so a symbolic link that
points into the subtree is hidden too; `delete` and `move` still act on
the link entry itself, which never reaches the hidden target. Every
rejection reads like a missing path, so refusing a hidden path does not
announce that something is hidden.
- `LocalFilesystemSpec` hides the workspace from the project layers when the
workspace is a proper subtree of the project and namespace scoping is on -
both the read-only lower layer and, for the same reason, the `projectFs`
write route, whose absolute paths skip the namespace prefix. A workspace
equal to or outside the project has no nesting to hide, a shared workspace
belongs to every caller equally, and project files outside the workspace
subtree stay shared, like `AGENTS.md` and `knowledge/`.
- The ripgrep path of `grep` runs rg with its working directory set to the
search root: `--glob` patterns match against paths relative to the working
directory, so the excluded-subtree globs missed whenever the parent process
was started outside the search root. Output paths do not depend on the
working directory, so entry-path resolution is unaffected.
- `relativeForGlob` compares the first path name instead of the string, so a
legitimate directory literally named `..cache` is a descendant, not a
traversal escape.
- `docs/v2/{zh,en}/docs/harness/filesystem.md` note the boundary in the
Overlay filesystem section, the project-writable read behavior, and the
mode table.
Absolute paths in the upper (workspace) layer and `..` segments are out of
scope: agentscope-ai#3292 covers the former, agentscope-ai#3378 the latter. Symbolic links are covered
here - the path is resolved before the boundary is applied. The shell keeps its own
project-rooted working directory, so `execute` is not bound by these guards
(agentscope-ai#2329). The `walkFileTree` fallback of `grep` applies the same exclusions
directly.
- New: as one user, a blank, relative or glob search sees nothing under
another user's namespace - in both the default and the writable-project
construction - and the content operations answer "not found" for a
sibling namespace spelled through the physical layout, while project
files outside the workspace and the caller's own namespace stay readable.
- New: a symbolic link planted in the project that points into the
workspace subtree stays hidden - `read`, `ls` and `write` see nothing
through it, and the target file is untouched. The case skips on hosts
that cannot create links.
- New: direct use of the hidden lower layer - `delete` leaves the subtree
untouched, `move` cannot cross the boundary in either direction, writes
cannot land inside it (the target does not exist yet, so the assertion
cannot pass merely because the file is there), and operations that start
at an ancestor (recursive delete, directory move) are refused outright
instead of partially touching the hidden subtree. Each of these assertions
was verified to fail with its guard removed.
- New: the ripgrep path of `grep` keeps the boundary when the parent process
cwd is unrelated to the search root - the pinned directory is deliberately
not hidden, so ripgrep's default hidden-file skip cannot mask the result
(verified to fail with the working-directory alignment removed). Skipped
when ripgrep is not installed.
- New: a shared workspace stays enumerable through the project layer, so
the boundary does not over-reach into single-tenant deployments.
- `mvn -pl agentscope-harness test`: 1628 tests, 0 failures, 37 skipped
(Docker, ripgrep and symlink cases that this host cannot run).
Fixes agentscope-ai#4069
… local filesystem (#3292) Backport the verified fix to the 2.0.x implementation and retain its existing public contracts where the upstream kernel differs. (cherry picked from commit 55498cf) Backport-review-patch: 6570c9bec31926955fb76740547888b917d8432a Constraint: No AgentScope Service or SDK migration Confidence: high Not-tested: Whole-repository verification pending after lane integration
With the default local filesystem, the project layer reaches across
namespaces in three ways:
- Enumeration: `grep(pattern, "")` returns matches from another user's
`MEMORY.md`, content included; `ls("")` and `glob("**/*.md", "")` list the
sibling namespaces. The overlay hands the same path to the upper (workspace)
and lower (project) layers, the default workspace is a subtree of the
project directory, and the lower layer carries no namespace.
- Direct content access: `read`, `exists`, `edit` (copy-on-write),
`downloadFiles` and `move` fall back to the lower layer too, so a relative
path spelling the physical layout - `.agentscope/workspace/alice/MEMORY.md`
- reads alice's file, and `edit` copies it into the caller's namespace
before modifying it.
- Absolute paths: the namespace prefix is skipped for absolute spellings, so
without a boundary the `projectFs` write route would run a delete or move
against an absolute path inside the workspace subtree.
Previously `LocalFilesystem.resolvePath` passed a blank key to the namespace
prefix unchanged, so it resolved to the workspace root; the physical layout
was reachable whenever the caller named it.
- A blank key is resolved as `.` before the namespace is applied, so an
empty path means "the caller's root" instead of the shared workspace root.
Deployments without a namespace resolve to the same directory as before.
- `LocalFilesystem` can hide a subtree entirely: enumeration skips it while
walking, and the content operations - reads, edits, writes, deletes, moves,
downloads, uploads and existence checks - see nothing there. `delete`
treats the subtree as absent (an idempotent no-op that never walks it),
`move` can neither move a file out of or into the subtree, and both `move`
and recursive `delete` refuse a directory that contains it outright rather
than partially touch it. Explicitly addressing a hidden subtree as a
search root yields nothing rather than walking it, and a `walkFileTree`
visitor that cannot enter a directory skips and continues instead of
propagating. The check resolves the path first, so a symbolic link that
points into the subtree is hidden too; `delete` and `move` still act on
the link entry itself, which never reaches the hidden target. Every
rejection reads like a missing path, so refusing a hidden path does not
announce that something is hidden.
- `LocalFilesystemSpec` hides the workspace from the project layers when the
workspace is a proper subtree of the project and namespace scoping is on -
both the read-only lower layer and, for the same reason, the `projectFs`
write route, whose absolute paths skip the namespace prefix. A workspace
equal to or outside the project has no nesting to hide, a shared workspace
belongs to every caller equally, and project files outside the workspace
subtree stay shared, like `AGENTS.md` and `knowledge/`.
- The ripgrep path of `grep` runs rg with its working directory set to the
search root: `--glob` patterns match against paths relative to the working
directory, so the excluded-subtree globs missed whenever the parent process
was started outside the search root. Output paths do not depend on the
working directory, so entry-path resolution is unaffected.
- `relativeForGlob` compares the first path name instead of the string, so a
legitimate directory literally named `..cache` is a descendant, not a
traversal escape.
- `docs/v2/{zh,en}/docs/harness/filesystem.md` note the boundary in the
Overlay filesystem section, the project-writable read behavior, and the
mode table.
Absolute paths in the upper (workspace) layer and `..` segments are out of
scope: agentscope-ai#3292 covers the former, agentscope-ai#3378 the latter. Symbolic links are covered
here - the path is resolved before the boundary is applied. The shell keeps its own
project-rooted working directory, so `execute` is not bound by these guards
(agentscope-ai#2329). The `walkFileTree` fallback of `grep` applies the same exclusions
directly.
- New: as one user, a blank, relative or glob search sees nothing under
another user's namespace - in both the default and the writable-project
construction - and the content operations answer "not found" for a
sibling namespace spelled through the physical layout, while project
files outside the workspace and the caller's own namespace stay readable.
- New: a symbolic link planted in the project that points into the
workspace subtree stays hidden - `read`, `ls` and `write` see nothing
through it, and the target file is untouched. The case skips on hosts
that cannot create links.
- New: direct use of the hidden lower layer - `delete` leaves the subtree
untouched, `move` cannot cross the boundary in either direction, writes
cannot land inside it (the target does not exist yet, so the assertion
cannot pass merely because the file is there), and operations that start
at an ancestor (recursive delete, directory move) are refused outright
instead of partially touching the hidden subtree. Each of these assertions
was verified to fail with its guard removed.
- New: the ripgrep path of `grep` keeps the boundary when the parent process
cwd is unrelated to the search root - the pinned directory is deliberately
not hidden, so ripgrep's default hidden-file skip cannot mask the result
(verified to fail with the working-directory alignment removed). Skipped
when ripgrep is not installed.
- New: a shared workspace stays enumerable through the project layer, so
the boundary does not over-reach into single-tenant deployments.
- `mvn -pl agentscope-harness test`: 1628 tests, 0 failures, 37 skipped
(Docker, ripgrep and symlink cases that this host cannot run).
Fixes agentscope-ai#4069
Summary
With
LocalFilesystemSpecand a per-session/per-userIsolationScope, absolute paths bypass the session namespace entirely: the namespace prefix only scopes relative keys (applyNamespacePrefixpasses absolute keys through), and theROOTEDacceptance check treats the workspace root as an implicit allowed root. One session could therefore enumerate and read another session's directory under the shared workspace root (MEMORY.md,memory/,agents/, generated artifacts) with a plain absolute path — makingIsolationScope.SESSIONa path prefix rather than an access boundary.Fixes #3261. It implements the "reject absolute keys that resolve inside another namespace" direction from the issue evaluation; happy to rework if maintainers prefer the effective-root design.
Changes
LocalFilesystemgains an opt-innamespaceBoundary(boolean). When enabled, inROOTEDmode an absolute path that resolves undercwdmust resolve undercwd/<namespace>to be accepted; anything else is rejected with aSecurityExceptionthat names the namespace root. The leading-slash virtual form (/foo→<workspace>/foo) is covered too, since it resolves undercwdthe same way.PathPolicyroots that lie outsidecwd(the read-only project layer,additionalRoots) are unaffected.AGENT/GLOBALscope, or missing user/session identifiers) the check is a no-op.LocalFilesystemusers;LocalFilesystemSpecenables it for the workspace layer whenmode == ROOTED(the spec default).SANDBOXEDalready re-roots absolute paths under the workspace;UNRESTRICTEDis documented to pass absolute paths through...segments are already rejected byAbstractFilesystem.validatePath.Behavior change to be aware of
With a namespace active, absolute access to shared directories sitting at the workspace root (e.g.
skills/,knowledge/) is now rejected as well — from the filesystem alone those are indistinguishable from a sibling session's directory. Shared content remains reachable through workspace-relative paths, which the overlay resolves against the read-only project layer; the injected workspace prompt already steers the model to relative paths. If maintainers would rather keep a shared-areas carve-out (e.g. a configurable allowlist of shared dir names), I'm glad to iterate.As noted in the issue evaluation,
execute()still runs host shell commands and is out of scope here — the local + shell mode is documented for trusted single-process hosts.Testing
LocalFilesystemModeTest: new cases for sibling-namespace rejection, own-namespace allowance, workspace-root absolute rejection, leading-slash virtual form rejection, default-off back-compat, and the no-active-namespace no-op. The previousrooted_leadingSlashWithNamespaceassertion encoded the vulnerable behavior and now asserts the refusal.agentscope-harnesssuite:Tests run: 1062, Failures: 0, Errors: 0, Skipped: 14.mvn spotless:checkpasses.