Skip to content

Metadata provenance

Note: This is reference documentation for auditing or debugging a generated SBOM -- not needed to just generate one. The schema described below is still in beta and can change without notice between releases.

Pitloom tracks the source of each metadata field in the SBOM, so questions like "why does the SBOM say the concluded licence is MIT?" or "where did the version number come from?" have a traceable answer.

Provenance is recorded as SPDX 3 Core Annotation elements -- structured, machine-readable JSON keyed by field name -- with the original human-readable comment form kept alongside for back-compat. The format, detail, preserve-source-metadata and max-source-metadata-bytes keys of [tool.pitloom.provenance] control it; their values, defaults and flags are in Configuration.

By default (detail = "minimal"), a field only gets a provenance Annotation when it adds something the native SPDX value can't already convey -- e.g. the value was inferred or detected rather than read verbatim. A value with a real native SPDX home (the licence itself, the package version, a dependency edge) is never restated in the Annotation; only how it was determined is. Set detail = "full" for an exhaustive per-field source map instead. A field built from more than one file names them all, comma-separated, with each Field in the same order (Source: setup.py, setup.cfg | Field: setup(url=...), metadata.url/project_urls); when every one is a manifest, minimal leaves it out like a single manifest read.

The provenance reference is split by topic:

  • Preserved artefact metadata -- an artefact's own metadata kept in one annotation, and its size bound.
  • Licences and copyright -- how a licence source is chosen, how a licence value is recorded, and how the copyright text is found.
  • Authors -- how authors and a dependency's originators are read.

Provenance examples

An Annotation on a package whose licence was detected (not author-declared):

{
  "type": "Annotation",
  "annotationType": "other",
  "contentType": "application/json",
  "subject": "https://spdx.org/spdxdocs/mypackage-.../#Package-1",
  "statement": "{\"fields\":{\"license\":{\"method\":\"licenseid_detection\",\"source\":\"LICENSE\",\"tool\":\"licenseid==0.9.0\"}},\"kind\":\"fields\",\"schema\":\"https://pitloom.dev/provenance/fields/1\"}"
}

The legacy comment form of the same information (present when format includes "comment", the default "both" does):

{
  "type": "software_Package",
  "name": "mypackage",
  "software_packageVersion": "1.2.3",
  "comment": "Metadata provenance: version: Source: src/mypackage/__about__.py | Method: dynamic_extraction"
}

The provenance information shows:

  • Version: Dynamically extracted from src/mypackage/__about__.py
  • Licence: Detected from a LICENSE file, not author-declared

This transparency is crucial for:

  • Auditability: Understanding where SBOM data comes from
  • Trust: Verifying the accuracy of metadata, and distinguishing extracted facts from inferred/detected ones
  • Machine consumption: Automated tools can parse provenance
  • Human review: Manual inspection of data sources

What the method values mean

The method field in a provenance entry says how Pitloom arrived at a value, not just where it read it from:

method Meaning
dynamic_extraction Read from a Python file at build time (e.g. a __version__ or __about__.py variable), not from pyproject.toml directly.
licenseid_detection Licence text matched against a known SPDX licence using the LicenseID library -- detected, not author-declared.
licenseid_resolution A declared licence value read as one SPDX id by LicenseID (Apache2 as Apache-2.0) -- the resolver's reading of what the author wrote, not the author's own words; the value as written stays in Normalized-From.
copyright_notice_lines The main package's copyright text: the copyright notice lines of the named licence files, as written (see How the copyright text is found).
parsed_author_list A dependency's originators, when its author fields name more than one (several address-field entries, several mailboxes in a name field, or a name beside them).
file_directive A pyproject.toml dynamic field pointed at a file ({file = "..."}); the value was read from that file.
attr_directive A dynamic field pointed at a Python attribute (pyproject.toml {attr = "..."}, setup.cfg attr:); the string assigned to it was read from the module's source, which is never imported.
inspect_caller Recorded automatically by the pitloom.loom tracking SDK via Python stack inspection -- identifies which script/function called the SDK.
synthetic The element is Pitloom's own synthesised placeholder root package for an installed environment (loom env), not extracted from any source file.
magika_content_detection Per-file content type resolved by the magika content-detection library.
extension_guess Per-file content type resolved by a filename-extension fallback (no magika, or no confident result).
file_name_stem An AI model's name is its file name without the last extension: the file names no model (or only a tool's default graph name).
semver_bit_packed An ONNX integer model_version decoded as bit-packed SemVer (MAJOR.MINOR.PATCH).
array_length A GGUF array field: only its element count is recorded (property <key>.length); the elements are not recorded.
crfsuite_model_type A CRFsuite model's type of model, conditional random field, derived from the header's model type (FOMC, a first-order Markov CRF, the only type CRFsuite writes).
generated_from_labels A CRFsuite model's description, written by Pitloom from the model's labels (the file has no description): the label count and the first 20 labels, each cut to 64 characters.
derived_from_format A value the file does not state but its format fixes: a fastText model's domain (from args.model) and output (label_probabilities, supervised models), and a CRFsuite model's output (label_sequence, one label per input item).
resolved_lockfile A dependency version pinned by a lock file (pylock.toml, uv.lock, poetry.lock and similar), not by the project's own requirement specifier.
pinned_requirements A dependency version pinned with == or === in a requirements.txt; weaker evidence than a real lock file, so tagged separately.
pdm_dynamic_version A PDM dynamic version, resolved from [tool.pdm.version] with PDM's own resolver; the tag ends with the declared source in parentheses, e.g. pdm_dynamic_version(file).
flit_dynamic_metadata A Flit dynamic version or description, read from the module's __version__ and docstring with flit-core's own AST scan.
member_count A ZIP-based model archive's member count (property archive_member_count), read from the archive's central directory.
yaml_frontmatter Read from a local README/model card's YAML frontmatter block during enrichment.
tensor_element_sum An AI model's parameter count: the sum of the element counts of its tensors, derived by Pitloom (GGUF tensor_infos, Safetensors header shapes, ONNX graph.initializer and graph.sparse_initializer, PT2 data/weights/model_weights_config.json sizes) or computed by the Hugging Face Hub (safetensors.total, gguf.total). All stored tensors count: what that means.
one_weight_per_feature A CRFsuite model's parameter count: the feature count of its FEAT chunk, each feature storing one weight.
hub_dataset_id A GGUF training dataset's name: the Hub id a Hub dataset page names, or the one llama.cpp split into its model-path repo_url; for the latter, also its download location, that dataset's page.
comma_list An ONNX model's originators, split on commas because the model_author property is a comma-separated list; set only when the text has a comma. A name that holds a comma (Doe, Jane) is split too.
latest-release The version of a file read from a PyPI URL that named none: the release PyPI lists as the latest (see the download record).
running-environment The wheel read from a PyPI URL was picked for the Python and platform Pitloom ran on, not named by the URL.
repository_owner A Hugging Face model's originator and supplier (originators, supplier): the owner of the Hub repository (model_info author), which the Hub does not say is the model's author.

A field with no method -- just a source -- was read verbatim from the named file with no interpretation involved (e.g. project.name from pyproject.toml). In detail = "minimal" (the default), these no-method entries are dropped entirely when the source is a well-known, re-readable manifest (pyproject.toml, setup.cfg/setup.py, wheel metadata, an sdist's PKG-INFO, the Hugging Face Hub API) -- they add no signal beyond what's already implied by the native field. Set detail = "full" to see every field's source regardless.

How sure a recorded fact is: Evidence and Reason

A provenance entry in the comment form is a list of segments, in this order: Source | Field | Method | Evidence | Reason. Evidence says how a number, hash or other fact was obtained, as distinct from where (Source) and how it was read (Method). An entry with no Evidence segment is a fact Pitloom measured by reading the content, which is nearly every entry. Only the keys Pitloom writes are read as keys; any other segment, and the value of a Note segment, is a note, so free text holding a : (a URL) adds no key.

Evidence Meaning
measured_stat Taken from the file system without reading the content (a file's size from stat()).
(no segment) Computed by reading the content within the caps (measured_read).
declared Stated by metadata and not checked (an archive header, a Hub API response).
lower_bound A read stopped at its limit: "at least N".
not_measured Not read, and nothing declared; always with a Reason.

Reason is a short code, never free text: over-cap, download-timeout, download-network-failed, lfs-pointer, file-unreadable or dir-unlistable, the code of the WARNING: that said why. Today over-cap, file-unreadable and dir-unlistable are written, for a dataset in loom (a file or a directory; the Python API):

  • A file over max-dataset-hash-bytes has no hash, and its verified_using entry reads Source: data.csv | Evidence: not_measured | Reason: over-cap. Its size is recorded from stat(), and byte_size reads Source: data.csv | Evidence: measured_stat.
  • A file hashed in full has its size, the bytes read, and no entry.
  • A directory over the cap: the same verified_using entry, and no size.
  • An over-cap file under 1,024 bytes (it might be a Git LFS pointer, and Pitloom never reads past the cap to tell) and a size above 2^53-1 get no size, and byte_size reads Evidence: not_measured | Reason: over-cap.
  • A Git LFS pointer gets no size (its own is not the content's).
  • A file the system refuses to read has no hash, and its verified_using entry reads ... | Evidence: not_measured | Reason: file-unreadable; its size is from stat(), or, under 1,024 bytes, byte_size reads the same not_measured entry. A path whose stat() is refused gets the verified_using entry only.
  • A directory holding a file it cannot read, or a subdirectory it cannot list: the verified_using entry with file-unreadable or dir-unlistable, and no size.
  • A file or directory gone while it was read is absent: no entry.

With detail = "minimal" (the default), an entry that has an Evidence segment is kept, even from a source that is otherwise left out.

The download record: a file read from a PyPI URL

A wheel or sdist that Pitloom downloaded from a PyPI URL (SBOM from a PyPI URL) carries one more provenance record, on the main package, written last so that no other id changes. SPDX 3 has no property for it (gap FG-15), so each fact is a provenance entry; its keys are project_url, download_location, sha256, sha256_declared, release_version, release_status (only for a pre-release or a yanked release), wheel_tags and compatible_wheels_skipped (wheels only). They read, for example:

sha256: Source: downloaded file | File: demo-1.0-py3-none-any.whl | Value: <64 hex digits> | Evidence: measured_read
sha256_declared: Source: PyPI JSON API | File: demo-1.0-py3-none-any.whl | Value: <64 hex digits> | Evidence: declared
release_version: Source: PyPI JSON API | Value: 1.0.0 | Normalized-From: 1.0
  • Value carries a fact no SPDX property holds (a URL, a digest, a version, a count); it is part of the entry's text, built through the same escaping as every other segment, so text from the index cannot add a segment.
  • Evidence: measured_read is written out here (an entry elsewhere leaves it out): the digest of the bytes Pitloom received. Evidence: declared is the digest the PyPI JSON API gave for the file; Pitloom compared the two and refuses the download when they differ, so they are equal in every SBOM.
  • Normalized-From is the version as the URL spelled it, when PyPI lists the release under an equal PEP 440 spelling (1.0 for 1.0.0).
  • No entry names a manifest as its Source, so detail = "minimal" leaves every one in.

How a dependency-version source is chosen

The disagreement detection of a licence source also applies to a dependency's resolved version, once a project lock file is in play (see Dependency sources and precedence). Unlike licence, there's no independent-detection procedure here -- both candidates are the project's own stated claims, just from two different files, so both are role: "declared", not a declared/detected pair:

  • A direct dependency pinned exactly (e.g. requests==2.31.0) whose pinned version doesn't match what the lock file separately resolved to.
  • A direct dependency declared as a range or left unpinned (e.g. requests>=2.0) whose declared constraint the lock file's resolved version doesn't satisfy.

Either way, the resolved software_packageVersion still follows the same "explicit pin beats local environment" precedence described in Dependency sources and precedence (a declared exact pin always wins; otherwise the lock file's version wins), and Pitloom adds a conflict Annotation (field: "dependency_version") on the dependency package recording both values:

{
  "candidates": [
    {"role": "declared", "source": "Source: pyproject.toml | Field: dependencies", "value": ">=2.0"},
    {"role": "declared", "source": "Source: requirements.txt | Method: resolved_lockfile", "value": "1.5.0"}
  ],
  "field": "dependency_version",
  "kind": "conflict",
  "schema": "https://pitloom.dev/provenance/conflict/1"
}

Note the declared candidate's value is a PEP 440 specifier expression (e.g. ">=2.0"), not a version, when the dependency was declared as a range rather than pinned exactly -- the exact-pin case instead has a concrete version on both sides.

A dependency's declared_constraint annotation holds every string declared for that package, extras included (see Extras and the optional edge), sorted and joined by |, each one a note: one holding a : (a direct URL, a marker) is written after a Note: key. Every route spells a dependency alike: the package name is the PEP 503 name its pkg:pypi PURL uses (Foo_Bar is foo-bar), and each declared string is spelt as packaging writes it, whether the source kept the spelling (a setuptools wheel) or not. loom env names each installed distribution the same way (PyYAML is pyyaml), whatever its .dist-info spells. The SBOM's own root package keeps the name the project declares (Foo_Bar), on every route; only its PURL is PEP 503.

See also

[tool.pitloom.provenance] is read the same way regardless of entry point -- see Command line, Hatchling build hook, and Python API for where to set it.