# Changing a Watchman query's selection

## Measured result
A retained explicit clock does not re-baseline a changed filter. In 18 native
executions on ext4 and tmpfs, broadening a suffix expression missed an unchanged
file; narrowing it retained a now-excluded file in a delta-only client index.
Every incremental response was empty with is_fresh_instance=false. The unchanged
filter control remained correct. Replacing the index from a full query under
the new expression recovered exact membership in all 18 cases.

## Method
Three schedules, two mounts, three repetitions each, one host. Each new private
root contains keep.dat and note.txt, plus Watchman's configuration. The control
keeps the .dat expression. Broadening changes .dat to .dat OR .txt; narrowing
reverses it. Both application files exist before the baseline query. No
application writes occur afterward. Payload equality is checked after queries.
Internal synchronization cookies are not application files and do not match
either expression. The original 36 history/reset cases remain a separate dataset.

The baseline is a full query. The next query uses its explicit clock with the
new expression. The intentionally incorrect consumer applies the returned delta
to the old selection. An independent directory enumeration supplies the expected
name set for the new expression. A full query without since supplies the recovery
control. The probe checks all of these, records native requests and responses,
and aborts on command failure, unexpected continuity, changed payload or mismatch.
Only random fixture-root names are normalized; clocks are retained as opaque strings.

## Reproduce
Place scope.py, observe.py and test_scope.py together; observe.py is the unchanged
private-server helper from the original experiment. Also obtain scope-results.json
to run the published-evidence tests. See README.md and manifest.json for package
provenance, isolation details and private library paths.

```sh
python3 -B scope.py --binary /absolute/path/to/watchman --directory /tmp --directory /dev/shm --repetitions 3 --output fresh-scope.json
python3 -B -m unittest -v test_scope
python3 -B -O -m unittest -v test_scope
```

The measured binary is Ubuntu noble amd64 Watchman 4.9.0-7build4, reporting 4.9.0.
scope-results.json records timestamp, kernel, Python, libc and binary/helper/probe
hashes. scope-summary.json is derived by summarize(), not manually transcribed.
scope-manifest.json records public artifact hashes and references the original
package/source manifest. Replays are compared, not added to the original sample.
This older target does not establish the behavior of a current release.

## Engineering interpretation
The official File Queries documentation separates candidate generation from
expression filtering. An explicit clock denotes a history position, not the
selection used to build a client's previous index. Our observation is consistent
with that separation, not evidence of a server defect.

Store the selection contract alongside the index and clock. A changed contract
needs an explicit migration or new baseline before claiming completeness. A full
replacement is a tested recovery control here, not the only possible migration:
a correct subset migration can remove excluded names locally. Root, relative
root, filters and exclusions can all be relevant to a consumer's scope; only
suffix-expression changes were executed here.

Unchanged physical files are missing from, or extra in, a selected index. The
narrowing case does not mean a deleted file persists. This is a name-membership
experiment, not a content snapshot, backup implementation, throughput benchmark,
crash test, history-expiration test or measured failure rate. All cases are
constructed, quiescent and on one host; repetitions do not estimate prevalence.
No recommendation to delete source files follows from an index exclusion.

## Primary sources and rights
Reviewed on 2026-10-21:
- https://facebook.github.io/watchman/docs/file-query
- https://facebook.github.io/watchman/docs/clockspec
- https://github.com/facebook/watchman/blob/v4.9.0/clockspec.cpp
- https://github.com/facebook/watchman/blob/v4.9.0/query/eval.cpp

The existing article's historical context was rechecked against Wumpus
(Buettcher and Clarke, ;login: 31(3), 2006, pp. 31-33) and ViewBox (FAST 2014,
sections 3.3.1-3.3.2). Neither paper reports this Watchman experiment.
Source files and package hashes remain in manifest.json; no upstream source,
paper, figure or executable is redistributed.
Original code: MIT (LICENSE). Original observations: CC0-1.0.
