Skip to content

fix: root a glob in the workspace, not in the machine - #106

Merged
DEENUU1 merged 1 commit into
mainfrom
fix/glob-rooted-in-the-workspace
Aug 20, 2026
Merged

fix: root a glob in the workspace, not in the machine#106
DEENUU1 merged 1 commit into
mainfrom
fix/glob-rooted-in-the-workspace

Conversation

@DEENUU1

@DEENUU1 DEENUU1 commented Aug 20, 2026

Copy link
Copy Markdown
Member

glob_command passed its root through to find, and a caller naming the
backend's root spells it /, "" or .. For a backend addressing files
by virtual path, / is the top of the namespace; for a shell it is the
machine. So find / searched the whole container.

Measured against a running sandboxd, in a session holding three files:

pattern   entries   outside the workspace
*            2540                    2540
**/*         2540                    2540
*.txt          25                      22
./**/*          0                       -

Two things follow, and neither announces itself. An agent's own glob
tool reads the image it is running on - /proc, /usr, every path in the
base layer - into its context, and answers a question about the workspace
with 2540 paths that are not in it. And any caller diffing two globs to
learn what changed during a turn is comparing two photographs of /proc:
one such caller posts an agent's new files back into a chat channel.

The root now resolves to ., which is the session's working directory,
and an absolute path is still passed through - /etc is a root a caller
may mean and this is not the place to argue with them.

**/* is fixed with it, and it is the pattern that matters most: find -path matches with fnmatch, where ** is no different from * and every
/ in the pattern must be present in the path, so **/* required two
slashes and missed every file at the top level. A leading **/ means "at
any depth", which is exactly what the */ prefix already provides, so it
is dropped rather than stacked.

Verified on the same service after the change:

pwd                        -> /workspace
find . -path '*/*' -type f -> ./b.txt ./deep/deeper/c.txt ./uploads/a.txt

Six new tests - the three spellings of the root, an absolute root left
alone, and four patterns through the globstar rule. 1670 tests, 100%
coverage.

Found while tracking down why an agent's ls reported an empty workspace in a downstream product (vstorm-co/agenticos#1039). The attachment bug there was its own, but this one is why the same product's channel snapshots and the agent's glob tool were both reading the container's base image.

`glob_command` passed its root through to `find`, and a caller naming the
backend's root spells it `/`, `""` or `.`. For a backend addressing files
by virtual path, `/` *is* the top of the namespace; for a shell it is the
machine. So `find /` searched the whole container.

Measured against a running `sandboxd`, in a session holding three files:

    pattern   entries   outside the workspace
    *            2540                    2540
    **/*         2540                    2540
    *.txt          25                      22
    ./**/*          0                       -

Two things follow, and neither announces itself. An agent's own `glob`
tool reads the image it is running on - `/proc`, `/usr`, every path in the
base layer - into its context, and answers a question about the workspace
with 2540 paths that are not in it. And any caller diffing two globs to
learn what changed during a turn is comparing two photographs of `/proc`:
one such caller posts an agent's new files back into a chat channel.

The root now resolves to `.`, which is the session's working directory,
and an absolute path is still passed through - `/etc` is a root a caller
may mean and this is not the place to argue with them.

`**/*` is fixed with it, and it is the pattern that matters most: `find
-path` matches with fnmatch, where `**` is no different from `*` and every
`/` in the pattern must be present in the path, so `**/*` required two
slashes and missed every file at the top level. A leading `**/` means "at
any depth", which is exactly what the `*/` prefix already provides, so it
is dropped rather than stacked.

Verified on the same service after the change:

    pwd                        -> /workspace
    find . -path '*/*' -type f -> ./b.txt ./deep/deeper/c.txt ./uploads/a.txt

Six new tests - the three spellings of the root, an absolute root left
alone, and four patterns through the globstar rule. 1670 tests, 100%
coverage.
@github-project-automation github-project-automation Bot moved this to Triage in Vstorm OSS Aug 20, 2026
@DEENUU1
DEENUU1 merged commit 5a07d2a into main Aug 20, 2026
15 checks passed
@DEENUU1
DEENUU1 deleted the fix/glob-rooted-in-the-workspace branch August 20, 2026 15:58
@DEENUU1 DEENUU1 mentioned this pull request Aug 20, 2026
DEENUU1 added a commit that referenced this pull request Aug 20, 2026
Cuts 0.2.27 for #106 - a glob rooted in the workspace rather than in the
machine.

Behaviour change, and worth reading before upgrading: a caller that
relied on `glob` searching the whole filesystem from a shell-backed
sandbox will now search the working directory. That reliance is unlikely
to have been deliberate - the same call on a virtual-path backend always
meant the workspace - but a caller wanting the machine can still ask for
it by naming an absolute root.

Everything else is a fix in the direction callers already expected:
`**/*`
now matches files at the top level, and a glob of `*` no longer answers
2540 paths from `/proc`.

Version and changelog only. Verified on #106 before merge: the full
suite, 100% coverage, and the built command checked against a live
service - `find . -path '*/*' -type f` in a workspace holding three
files
answers exactly those three.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant