Commit 5a07d2a
authored
fix: root a glob in the workspace, not in the machine (#106)
`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.1 parent 590630c commit 5a07d2a
2 files changed
Lines changed: 60 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
154 | 165 | | |
155 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
156 | 185 | | |
157 | 186 | | |
158 | 187 | | |
159 | 188 | | |
160 | 189 | | |
161 | | - | |
162 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
163 | 194 | | |
164 | 195 | | |
165 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
225 | 251 | | |
226 | 252 | | |
227 | 253 | | |
| |||
0 commit comments