Skip to content

Design

Ichnos replaces hand-written path filters with one rule:

A command that passed is not run again while everything it read is unchanged.

There is no separate "learn the dependency map" phase and no diff between commits. Every run that executes is traced, and its footprint is stored next to its result. This supersedes the two-phase design in the feasibility study, whose map went stale within a week.

Why a remembered result cannot go stale

A deterministic command can only start depending on a new file if something it already reads changes: a new import comes from an edited source file, a new config key from an edited config. That edit invalidates the footprint, the command runs again, and the new run records the new footprint. So the check "nothing in the footprint changed" also guarantees the footprint itself is still right. The walk validation tests this on real history.

What a footprint holds

Entry Recorded when the command... Invalidated when...
files reads or executes a file its content changes or it disappears
exists only looks at a path (stat, access) the path disappears or changes type
listings lists a folder an entry is added to or removed from it
absent looks for a path that is not there the path appears

Entries are checked against the files git can see: tracked files, and untracked files that are not ignored. Ignored files are treated as build outputs, not inputs.

Rules that keep footprints small and correct

  • Copies are followed. If a run copies repository files to a sandbox and reads the copies, it depends on the originals it read, not on everything it copied. Copies are recognised from sendfile and copy_file_range, and from cp, install and mv by name. A copy Ichnos does not recognise counts as a read, which costs precision but never correctness.
  • Bytecode stands for its source. Reading __pycache__/x.cpython-312.pyc is depending on x.py.
  • A run that modifies a file it read is not remembered.
  • Symlinks and submodules inside the repository become dependencies on the link itself.

Two tracers, one set of rules

eBPF (bpftrace) strace
Needs root, or sudo without a password nothing
How the kernel reports each call as it returns; nothing is stopped stops the process at every call
One tracer for the whole run: units are told apart afterwards each unit
Fixed cost about one second per run, to start and stop none

Both end as the same list of calls, read by the same rules, and the test suite runs under each. eBPF is used when it is available.

With eBPF, a unit asks to be watched by trying to enter a folder whose name only Ichnos knows, because process ids are not the same inside a container and in the kernel. Anything doubtful makes a unit run but not be remembered, and its outcome says why: events lost by bpftrace, a path longer than bpftrace carries (about 200 bytes before version 0.21, 1,024 after), a line of the trace that is not an event, a descriptor whose path is not known. A unit that uses io_uring, chroot or a 32-bit program is not remembered either: under strace those go unnoticed.

Three things learnt the hard way, all on GitHub's runners (Linux 7.0, bpftrace 0.25):

  • The per-syscall tracepoints report one processor out of four there, without a warning. Ichnos uses the raw tracepoint that covers every syscall, which reports them all.
  • A path read when a call starts may not be in memory yet, and reads as empty. Everything is read when the call returns.
  • bpftrace drops what is left in its buffers when told to stop. Ichnos first waits for an echo of its own to come back through the same buffers, twice.

Without tracing: the whole tree

ichnos run --whole-tree, ichnos seen and ichnos remember tie a result to one hash of every visible file instead of a traced footprint. Such a result is reused only on identical files: the merge commit of a pull request that main did not move under, or a re-run. It is the fallback for what strace cannot follow (a docker build happens in the daemon) or slows too much.

ichnos passed-in-pull-request answers the same question from GitHub's own run results instead of the shared memory: the commit must be the merge of a pull request whose last commit has the same git tree, and the named jobs must have succeeded, not been skipped, in a successful run of the same workflow on that commit. It needs no write access and trusts nothing a pull request could write.

Known gaps

Not tracked What to do
Tool versions, runner image, environment variables Pass them with --key
The network, the clock, randomness Keep a periodic full run with --no-skip
Tests with a time limit: tracing slows them (1.2× to 3×) and one may time out Raise the limit when ICHNOS=1 is set, or use --whole-tree
Files git ignores (local config, node_modules) Declare a lockfile with --input
The .git folder itself (git describe) --key "$(git describe)"
A decision made from a file's size or date alone --strict-stat
Flaky tests Partly handled: see below
io_uring, chroot, 32-bit programs Detected with eBPF: the unit is not remembered. Not seen with strace
macOS and Windows Commands run untraced and are never skipped

Flaky tests

A test that sometimes passes is dangerous here: one lucky pass would be remembered and the test skipped from then on. On ai-running-coach this caused the only wrong skip of the audit. Three rules limit it:

  • Failures are remembered too, with their footprint. They never allow a skip.
  • Two results on the same files mean flaky. A pass where a failure still holds, or a failure where a pass still holds, marks the unit. A marked unit always runs for 14 days.
  • A pass right after a failure is on probation. It has to pass once more before it can be skipped, so a real fix costs one extra run.

The second rule needs a run that Ichnos would have skipped, so keep a periodic full run with --no-skip: it is what catches a flaky test that was remembered. What is left uncovered is a test that passes twice in a row by luck while its files keep changing.

Where the memory lives

Records are small JSON files, one per run, named after their content. Locally they sit in .ichnos/memo/, which ignores itself so it never enters a commit.

To share them, ichnos memo push and ichnos memo pull use a ref on the project's own remote, refs/ichnos/memo:

  • It is in the project's git repository, so there is no extra service, no 7-day eviction and no branch-scoping, unlike the Actions cache.
  • It is outside the history. No branch or tag points to it, clones do not download it, and it is one commit without parents, so each push replaces the last and the repository does not grow without bound.
  • Two jobs publishing at once merge their records. The loser of a race loses nothing but a re-run.

Committing the memory to a branch was rejected. Measured on ai-running-coach, it is about 8 KB per unit (17 MB for 2,215 records, before git compression) and most of it changes weekly.

Trust

Whoever can write the memory can make CI skip a test, so writing it is as sensitive as pushing to main.

  • A record is only ever used if its footprint matches the files at hand. A stale or foreign record can cause a re-run, not a wrong skip. A forged record with an empty footprint could cause one.
  • Set ICHNOS_SIGNING_KEY from a CI secret. Records are then signed, and unsigned or wrongly signed ones are ignored. Pull requests from forks cannot read secrets, so they can neither forge nor publish.
  • A memory folder that contains files tracked by git is refused, so a pull request cannot commit one.
  • Pulling takes only plain record files from the shared ref, never links or other paths.
  • The code under test runs with the rights of Ichnos itself. It can hide from either tracer, or write records directly. That is no more than editing the tests: Ichnos guards against stale results, not against the author of the change.
  • Still to do: protect refs/ichnos/* with a repository ruleset, and stop a same-repository pull request that edits the workflow from reading the secret.

Commands

Command Purpose
ichnos run --id NAME -- cmd Run one command unless its last passing run still holds
ichnos batch units.json The same for many units in parallel, with a JSON report
ichnos explain --id NAME -- cmd Say whether it would be skipped, and what changed
ichnos estimate --commits N Replay git history to predict the saving
ichnos memo pull / push Share the memory through the git remote
ichnos doctor Check that tracing works on this machine

Not built yet

  • Test-runner adapters that split a suite into units (unittest classes, pytest files).
  • Running the affected tests first when nothing can be skipped.
  • Anything for macOS.