symfonic.platform.artifact_identity¶
artifact_identity ¶
Prove that an installed symfonic-core dist-info owns the imported code.
importlib.metadata returns the first matching dist-info on sys.path.
That says nothing about which code the process runs: a source checkout ahead
of an install, an editable install of another checkout, a hand-edited file or
an in-place upgrade all leave a readable version that describes other bytes.
A version is attributed only when all of these hold, else None:
- the distribution is not an editable (
direct_url.json) install; - its RECORD lists every loaded
symfonicmodule, at the path the module was imported from, with a sha256 that matches the file. A loaded module the RECORD does not list (added later, sourceless, or another distribution's) withholds the version; symfonic/__init__.py, this module and the stamping module are among them, so a foreign tree cannot pass by importing nothing the RECORD lists;- the RECORD lists
METADATAwith a matching sha256, and the version is read from those same bytes, so an edited version label is not attributed; - none of those files, nor the RECORD, changed after the process started.
The start time is read from
/proc; where it cannot be read the answer isNone.
This is consistency between the RECORD and the .py files on disk, not
build authenticity: a RECORD rewritten to match edited files before the
process starts passes, and the bytecode actually executed is not hashed.
is_editable ¶
True when the install records an editable source directory.
Source code in src/symfonic/platform/artifact_identity.py
loaded_modules ¶
(name, file) for every loaded symfonic source module.
owned_version ¶
dist's version if it provably owns modules; otherwise None.
Source code in src/symfonic/platform/artifact_identity.py
process_start_ns ¶
This process's start time in epoch nanoseconds, never later than the truth.
Start ticks are truncated and the uptime sample is padded by its 10 ms resolution, so the value can only be early: a file written after the real start is always newer than it, and one written in the last ~20 ms before it may also count as newer, which withholds the version (fail closed).
Source code in src/symfonic/platform/artifact_identity.py
verify_modules ¶
Whether every listed module is dist's recorded, unchanged file.