Revision: 1 Last modified: 2026-12-04T19:00:00Z
io_trace.sh observes which files a gate actually reads and writes, and persists that observation
as the gate→inputs map.
This is the mechanism that makes sound gate selection possible. affected_set.py can only skip a gate
when it knows that gate's real inputs; guessing the inputs from a script's source text is the guess
that lets a real regression slip through. So the inputs are measured, not inferred — by running the gate
under strace and reading the paths the kernel was actually asked to open.
The load-bearing detail is the syscall layer only ever sees the path after shell expansion. A gate
that builds a path dynamically ("$DIR/$name.sh") shows up as the resolved path, not as a template
string. A source scanner would record the literal template and then match nothing.
Two subcommands:
| Form | Meaning |
|---|---|
io_trace.sh <gate-script> [args...] |
Bare form — same as trace. |
io_trace.sh trace <gate-script> [args...] |
Trace one gate, emit its read/write sets. |
io_trace.sh build-map [...] |
Trace every gate under a directory and persist the map. |
sh,python3,stracewith-fsupport. Missingstraceorpython3is a tracer-level failure (exit2) — never a silent pass.lib/io_trace_parse.pyandlib/io_trace_build_map.pybeside it.- For
build-map: a sections directory of*.shgate scripts, and a writable map database path.
No environment variables are read.
# observe one gate's inputs; args after the script are passed to the gate
sh scripts/fastcycle/gates/io_trace.sh scripts/gates/cm_fetch_before_edit_audit.sh --root .
# explicit form
sh scripts/fastcycle/gates/io_trace.sh trace scripts/gates/some_gate.sh
# rebuild the persisted map, re-tracing only scripts whose hash changed
sh scripts/fastcycle/gates/io_trace.sh build-map \
--sections-dir device/rockchip/rk3588/tests \
--db .cache/fastcycle/io_map.sqlite
# trace device-mutating scripts (refused by default — see below)
sh scripts/fastcycle/gates/io_trace.sh build-map --allow-device-scripts
# bound each traced script
sh scripts/fastcycle/gates/io_trace.sh build-map --per-script-timeout 120trace prints exactly one JSON object on stdout:
{"reads": ["/abs/path/a", "..."], "writes": ["/abs/path/b"]}| Code | Meaning |
|---|---|
0 |
The trace succeeded. This is exit 0 even when the traced gate itself failed — the tracer observes, it does not judge. |
2 |
Tracer-level failure: strace unavailable, python3 unavailable, the gate script missing or unreadable, or a usage error. |
The distinction is the point: a 1 here would be indistinguishable from "the gate failed", so tracer
faults use 2 and never 0/1.
build-map exits 0 on a completed map build and 2 on the same tracer-level failures.
For each observed path argument of an openat / stat / newfstatat / lstat / execve call:
openatwithO_WRONLY,O_RDWRorO_CREAT→ write;- any other
openat→ read; - any stat-family call → read. Deciding on a file's existence is genuinely consuming it as an
input, which is why
statcounts as a read rather than being ignored.
Noise filtered out, as a documented and reviewable list rather than an unstated heuristic: /lib/,
/lib64/, /usr/lib/, /etc/ld.so.cache, /etc/ld.so.preload, /proc/, /dev/, /sys/,
/etc/nsswitch.conf, /etc/localtime. These are what a traced sh interpreter opens during its own
startup. A tracer that leaked them into the reported set would be a §11.4.201(1) false positive on the
tracer itself.
- A dynamically built path. Reported resolved, never as the template — this is the golden-bad fixture the tracer exists to satisfy.
- Device-mutating scripts.
build-maprefuses to trace a script matching a device-mutating pattern (adb,reboot,settings put, flash/power-cycle tooling,rm -rfoutside a scratch tree) unless--allow-device-scriptsis passed. Tracing executes the gate for real, so this is a host- and device-safety refusal, not a style preference (§12, §11.4.225). - Unchanged scripts.
build-mapcomputes each script's content sha256 and re-traces only those whose hash differs from, or is absent in, the persisted map. Re-tracing everything is the backstop's job, not this subcommand's. - A gate that hangs. Bounded by
--per-script-timeout; without a bound, a hanging gate hangs the map build. stracepresent but lacking-f. Not probed separately; a failure surfaces as a tracer-level2.
- Validates subcommand and arguments (
exit 2via the usage path). - Requires
straceandpython3before doing any work (exit 2if absent). - Runs the gate under
strace -f -e trace=openat,stat,newfstatat,lstat,execvein the current (already-clean) checkout. - Parses the raw strace log for path arguments, classifies each as read or write, and drops the documented noise prefixes.
- Emits one JSON object on stdout and exits
0.
build-map additionally walks --sections-dir for *.sh, hashes each, applies the
device-mutating refusal, and delegates the incremental re-trace and persistence to
lib/io_trace_build_map.py.
Called by scripts/fastcycle/gates/backstop.sh, scripts/fastcycle/gates/lib/gate_runner_order.py,
scripts/fastcycle/gates/lib/gate_runner_shard.py and
scripts/fastcycle/review/lib/precheck_pack_run.py.
Calls scripts/fastcycle/gates/lib/io_trace_parse.py,
scripts/fastcycle/gates/lib/io_trace_build_map.py.
Guarded by scripts/fastcycle/tests/test_io_trace_red.sh (T052), fixtures under
scripts/fastcycle/tests/fixtures/io_trace/.
See also docs/scripts/affected_set.py.md (the consumer of this map) and
docs/scripts/gate_runner.sh.md.
2026-12-04 — bash -n scripts/fastcycle/gates/io_trace.sh → exit 0. sh scripts/fastcycle/gates/io_trace.sh with no arguments prints the three-form usage block on stderr and
exits 2.