# Reference patch — 03-glob-search

The answer key for how the reference absorbs this change, and the thing that makes
`budget.json` reproducible. **Never shipped to the candidate.**

1. **Overlay** `../contract-delta/FileSystemApi.java` onto `contract/FileSystemApi.java`. Contract
   files are given, so nothing here is charged.
2. **Add** `Glob.java` (in this directory) to `reference/src/`. New file, free.
3. **Add four lines** to `reference/src/InMemoryFileSystem.java`:

   ```java
   @Override
   public List<String> find(String globPattern) {
       return Glob.find(tree.getDirectory("/"), globPattern);
   }
   ```

Measured: `reference_diff = 4` — one method, entirely new, nothing else touched — so
`diff_budget = max(3, 4 + min(ceil(4/2), 6)) = 6`.

Both the curveball suite (6 tests) and the base suite (29 tests) are green after the patch.

## Why this is the cheap one

The whole feature is a new question over the tree's shape, answerable by reading it, never by
changing it. Nothing about `mkdir`, `write`, `read`, `mv` or `delete` had any reason to move, and
none of them did. The four lines that did land are exactly the price of declaring the new contract
method somewhere — the same "declaration, not design" cost the vending-machine and library
patches both name for their own new methods — and this one has nothing else attached to it,
because the algorithm lives entirely in the new file.

**Why `Glob` needed no access beyond what was already public.** `PathResolver` already exposed
`getDirectory(path)`, and `getDirectory("/")` is the root — no new accessor, no new interface
method, on `PathResolver` or anywhere else. `Glob` then walks the tree itself using exactly the
same reads `ls` already uses: `childNames()` and `child(name)`. That a brand-new, fairly involved
recursive matcher could be written entirely as a new class calling only pre-existing public
methods is the measurement this curveball is really taking — it is evidence that `DirectoryNode`'s
public surface was already the right shape for "walk my children," not shaped narrowly around
`ls`'s one specific need.

**Why it is a new file and not a method added to `PathResolver` or `DirectoryNode`.** `find`
answers a different kind of question than either of those interfaces asks: "what exists" rather
than "what is at this one path" or "attach/detach this name." Folding it into `PathResolver` would
have mixed a read-only, exception-free search with an interface whose other four methods are all
about resolving and mutating a single location and throwing the four domain exceptions when they
can't. Keeping it apart is also what makes `Glob` free of `FileSystemException` entirely — a
non-match is not a failure of anything, so the class that computes it never throws one.
