Function hashes, and the footprint a cached result rests on (design notes §7.3).
A function's hash is the SHA-256 of its module's context (every module-body
expression that is not a function clause, a nested module or a documentation
attribute: use, import, alias, attributes, defstruct, ...) and all its clauses
in source order, as Sourceror parses them with every node's metadata stripped. So a
comment, a blank line or a layout change keeps the hash; an edit in the function, or in
what its module gives it (an attribute it reads, an alias it calls through), changes it.
A function the source does not write (__struct__/0, a default-argument arity, a
schemata copy) resolves to its module's context hash, and a module the file does not
define (or a file that does not parse) to the hash of the whole file: never a hash that
could stay the same while the code behind it changed.
A footprint, as recorded in a cache entry, is %{file => %{"sha" => content sha, "functions" => %{key => hash}}}, keys as key/3 makes them. It stands while every
file's content is unchanged, or, where the content changed, every recorded function
hashes the same.
Summary
Types
Each file of the footprints looked at: its content sha and, if needed, its hashes.
Functions
Whether recorded names every file of functions.
The current state of every file in footprints (recorded footprints): its content sha,
and its hashes only when its content differs from a sha some footprint recorded. nil
for a file that cannot be read.
The hashes of every function and module of source.
The footprint key of a function: "Elixir.Mod|fun/arity".
The footprint of functions ({file, module, fun, arity}, files relative to root)
as the files under root are now. A file that cannot be read is left out, which no
later footprint check can confirm, so callers record no entry for it (complete?/2).
The hash of key in a file's hashes: the function's own, else its module's context
hash, else "file:" and the file's content hash.
The hashes of each of files (relative to root) as it is now, nil for a file that
cannot be read. Each file is parsed once, in parallel, so a run that records many
footprints over the same files (recorded/2) parses a file once, not once per
footprint.
Whether a recorded footprint stands against current (see the module doc).
Types
Each file of the footprints looked at: its content sha and, if needed, its hashes.
Functions
@spec complete?(recorded(), [function_ref()]) :: boolean()
Whether recorded names every file of functions.
The current state of every file in footprints (recorded footprints): its content sha,
and its hashes only when its content differs from a sha some footprint recorded. nil
for a file that cannot be read.
The hashes of every function and module of source.
The footprint key of a function: "Elixir.Mod|fun/arity".
@spec record(Path.t(), [function_ref()]) :: recorded()
The footprint of functions ({file, module, fun, arity}, files relative to root)
as the files under root are now. A file that cannot be read is left out, which no
later footprint check can confirm, so callers record no entry for it (complete?/2).
@spec recorded(%{required(String.t()) => hashes() | nil}, [function_ref()]) :: recorded()
The footprint of functions from scans (scan/2 of their files). As in record/2,
a file scans holds no hashes for (unreadable, or not scanned) is left out.
The hash of key in a file's hashes: the function's own, else its module's context
hash, else "file:" and the file's content hash.
The hashes of each of files (relative to root) as it is now, nil for a file that
cannot be read. Each file is parsed once, in parallel, so a run that records many
footprints over the same files (recorded/2) parses a file once, not once per
footprint.
Whether a recorded footprint stands against current (see the module doc).