Skip to content

feat(comply): pre-fill more fields from scan data - #137

Merged
lab700xdev merged 2 commits into
mainfrom
feat/comply-scan-fields
Nov 15, 2026
Merged

lab700xdev merged 2 commits into
mainfrom
feat/comply-scan-fields

Conversation

@lab700xdev

Copy link
Copy Markdown
Contributor

Summary

aisbom comply now pre-fills more of the fields it used to leave as TODO (provider), from data the scan already reaches. Every value names its source, and nothing is guessed:

  • Declared values get their own row. A card's languages, CO2 emissions, evaluation results and the repository's creation date are shown as "declared", and the regulatory field next to them stays TODO.
  • Interpretations are labelled. Modality from the task and supplier from the repository owner are tagged AIsbom's mapping.
  • Parameter counts come only from complete data. A count is summed only over a provably complete set of safetensors files.

SBOM (additive only)

  • modelCard properties: aisbom:hf:author, base_model, language, created_at, parameters_total, co2_eq_emissions (+ source, training type, hardware, location).
  • created_at is skipped when it is the 2022-03-02T23:29:04Z stamp that every repo older than HF's migration carries.
  • The card's model-index results go into the typed quantitativeAnalysis.performanceMetrics slot, capped at 50.
  • aisbom:safetensors:parameters is added per file: the sum of tensor-shape products from the header, recorded only when every shape is well formed.
  • aisbom:pypi:author is added on dependencies, read from the PyPI request already made for licences. The licence cache schema is bumped so old entries are fetched again.

comply packs

  • EU AI Act:
    • Model dependencies come from base_model.
    • Parameter count comes from HF's safetensors total and/or AIsbom's sum over a complete set (one unsharded file, or every -0000k-of-0000N shard).
    • Input/output modality comes from a 24-task table.
    • New declared rows: languages, first published on Hugging Face, training hardware, CO2 emissions, evaluation results.
  • FDA: component-support.csv gets four new columns at the end: supplier, supplier_source, end_of_support_lookup, end_of_support_lookup_source.
    • Supplier: a model's HF repo owner, unless its card names a base model from another namespace; a package's PyPI author.
    • End-of-support dates come from endoflife.date, used only for products that list the package's own pkg:pypi/ purl, matched to the pin's release cycle. A provider answer always keeps the date cell.

Privacy

  • New endoflife.date lookup for comply --framework fda only. It sends package names; versions stay local.
  • Opt out with --no-eol-lookup, AISBOM_NO_EOL_LOOKUP=1 or --offline.
  • Disclosed in the README Privacy section. scan never makes this request.

docs/comply.md mapping is updated; TEMPLATE_VERSION is now 2026-11-15.2.

Verification

  • poetry run pytest --cov=aisbom --cov-fail-under=85: 1777 passed, 94.63%. New suites: modelcard declared fields, safetensors parameters, PyPI author, endoflife.date, comply scan fields (present/absent per field, partial and duplicated shard sets, answers coexistence, CLI opt-outs).
  • aisbom bypass-scorecard --check passes.
  • Old (main) vs new SBOM, compared field by field for demo_data and hf://google-bert/bert-base-uncased: no existing field changed; only the properties above were added.
  • AIsbom's header sum matches HF's server-side total exactly for bert (110,106,428) and for sharded Qwen2.5-3B-Instruct (3,085,938,688).
  • Live FDA pack on a tree pinning numpy, django, requests, torch and python-dateutil: numpy and django got endoflife.date dates; the untracked packages stayed TODO; all five got a PyPI author as supplier.

Fill more of the comply pack's TODO fields from data the scan already
reaches, each tagged with its source and none guessed.

SBOM (additive; old-vs-new diff on demo_data and bert shows no change to
existing fields):
- modelCard properties: aisbom:hf:author, base_model, language,
  created_at (skipping HF's 2022 migration stamp), parameters_total and
  co2_eq_emissions; model-index results as typed
  quantitativeAnalysis.performanceMetrics (capped at 50)
- aisbom:safetensors:parameters per file, summed from header shapes
- aisbom:pypi:author on dependencies, from the existing PyPI request
  (licence cache schema bumped so old entries are refetched)

comply:
- EU AI Act: model dependencies from base_model; parameter count from
  HF's total and/or a complete safetensors set; modality from the task
  (AIsbom's mapping); "declared" rows for languages, first published on
  Hugging Face, training hardware, CO2 and evaluation results, leaving
  the regulatory field itself TODO
- FDA: supplier and end-of-support columns appended to
  component-support.csv. End-of-support dates come from endoflife.date
  for packages it tracks (package names only; --no-eol-lookup,
  AISBOM_NO_EOL_LOOKUP=1 and --offline skip it; disclosed in README)

docs/comply.md mapping updated; TEMPLATE_VERSION 2026-11-15.2.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T05:06:58.274234Z d14ef00 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d14ef00cbf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aisbom/comply.py Outdated
Comment on lines +1058 to +1060
(str(c["name"]), str(c["version"]))
for c in _components(doc)
if c.get("type") != _ML_COMPONENT_TYPE and c.get("name") and c.get("version")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve exact-pin information before selecting EOL lookups

For an unpinned requirement such as numpy>=2.2.0, DeepScanner._parse_requirements records version="2.2.0" and pinned=False, but CycloneDX serialization drops the pinned flag. This predicate consequently includes that lower bound as though it were an installed version, and the FDA pack fills end_of_support_date using the 2.2 cycle even though the requirement permits later cycles with different support dates. Preserve pin provenance through serialization and restrict EOL enrichment to exact pins; otherwise unpinned dependencies should remain TODO.

Useful? React with 👍 / 👎.

Comment thread aisbom/comply.py Outdated
Comment on lines +333 to +335
shard = _SHARD.match(name)
if shard:
key = (shard["stem"], int(shard["total"]))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Group local shards by their originating directory

When scanning a local directory tree, artifact names contain only basenames (_inspect_safetensors uses local_path.name), so this key merges shards from unrelated model directories. For example, a tree containing only a/model-00001-of-00002.safetensors and b/model-00002-of-00002.safetensors produces a supposedly complete parameter count in Annex XI even though neither model is complete. Carry the originating directory or another model-set identity into the grouping, and leave the count TODO when that identity cannot be established.

Useful? React with 👍 / 👎.

…er directory

endoflife.date dates are now looked up only for exact == pins, taken from the
scan's dependency list (the SBOM drops the pin flag and records numpy>=2.2.0
as 2.2.0), and joined to components by bom-ref.

Shard-set completeness is now decided by the scanner, which sees directories,
and written as aisbom:safetensors:set_parameters / set_shards on each shard.
comply no longer groups by component name, which is a basename for local scans
and would treat halves of two models in different directories as one set.
@lab700xdev
lab700xdev merged commit de36059 into main Nov 15, 2026
2 checks passed
@lab700xdev
lab700xdev deleted the feat/comply-scan-fields branch November 15, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant