fix: decide a skipped profile by its kind

This commit is contained in:
Abdessamad Derraz committed 2026-11-24 02:18:53 +01:00
1 parent 6e44a93156
commit ac334729f5
7 files changed
+133 -61

No files matched your search

+3 -4
View File
@@ -18,8 +18,7 @@ from model.registry import list_registered_platforms
from profiling import version_basis
from profiling.anchoring import REVIEW_STATUSES
from profiling.rebase import pending_recale
from profiling.reports import ProfileReport
from profiling.resolver import NO_SOURCE_REF
from profiling.reports import ProfileReport, SkipKind
from profiling.yamledit import apply_edit, insert_after_line, replace_field_line, set_version_fields
from resolve.cores import resolve_platform_cores
@@ -73,7 +72,7 @@ def _needs_review(report: ProfileReport, accept_changed: bool) -> bool:
"""Whether the report leaves a ref to read before the pin may move."""
# A profile citing nothing has nothing to read again: anarch's pin sat
# behind a CI-only commit through every bulk advance.
if report.skipped not in (None, NO_SOURCE_REF) or not report.head or report.pinned_tag:
if report.skip_kind not in (None, SkipKind.NO_SOURCE_REF) or not report.head or report.pinned_tag:
return True
blocking = REVIEW_STATUSES if not accept_changed else (
s for s in REVIEW_STATUSES if s != "CHANGED"
@@ -164,7 +163,7 @@ def bump_commit(
report.upstream_head
and report.upstream_pin != report.upstream_head
and not report.upstream_tag
and report.skipped != NO_SOURCE_REF
and report.skip_kind is not SkipKind.NO_SOURCE_REF
)
if document.get("source_commit") == report.head and not upstream_moves:
# Rewriting the pin to the value it already holds is not a bump, and
+51 -11
View File
@@ -3,6 +3,7 @@
from __future__ import annotations
from dataclasses import asdict, dataclass, field
from enum import Enum
from core import upstream
from model.sourceref import ANNOTATION_RE, trim_prose
@@ -58,6 +59,42 @@ class Attention:
detail: str
class SkipKind(str, Enum):
"""Why a profile was not compared, set where the skip is decided.
The sentence in ``skipped`` is for a reader. Every verdict on a skip
reads this field: the JSON attention, --strict, the triage and the exit
code, so rewording a sentence moves no profile out of any of them.
"""
NO_SOURCE_REF = "no_source_ref"
UNSUPPORTED_HOST = "unsupported_host"
# The profile declares the forge gone and the forge agrees.
GONE_DECLARED = "gone_declared"
# The forge says it is gone and the profile does not.
GONE = "gone"
# The profile declares the forge gone and the forge answers.
GONE_CONTRADICTED = "gone_contradicted"
# No declared repository answers, or none has a pin to read.
UNANSWERED = "unanswered"
# A forge failed this time: the profile is unread, not settled.
UPSTREAM_ERROR = "upstream_error"
RATE_LIMITED = "rate_limited"
OFFLINE = "offline"
# Skips that say the profile cannot be checked as written: a repository
# that no longer answers, no pin to read, a death the forge contradicts.
# --strict passed them, and the CI job meant to stop an unchecked profile
# let a mistyped repository through.
UNCHECKABLE_SKIPS = frozenset({
SkipKind.UNANSWERED, SkipKind.GONE_CONTRADICTED, SkipKind.GONE,
})
# Skips that leave the run incomplete: a forge that failed or refused this
# time. The profile fails the run, and its JSON row says it was not read.
UNREACHED_SKIPS = frozenset({SkipKind.UPSTREAM_ERROR, SkipKind.RATE_LIMITED})
@dataclass
class ProfileReport:
name: str
@@ -72,6 +109,7 @@ class ProfileReport:
head: str | None = None
entries: list[EntryReport] = field(default_factory=list)
skipped: str | None = None
skip_kind: SkipKind | None = None
counts: dict[str, int] = field(default_factory=dict)
# Declared repositories whose forge the tool cannot read. They are named
# rather than dropped: a `source` on an unknown host used to fall back to
@@ -135,20 +173,18 @@ class ProfileReport:
# profile was read from does not carry. Not part of the JSON form.
cited_sources: list[CitedSource] = field(default_factory=list)
# Skips that say the profile cannot be checked as written: a repository
# that no longer answers, no pin to read, a death the forge contradicts.
# --strict passed them, and the CI job meant to stop an unchecked profile
# let a mistyped repository through.
UNCHECKABLE = (
"no declared repository answers",
"no source_commit and no resolvable profiled_date",
"upstream_gone is declared but the forge answers",
"upstream gone:",
)
def skip(self, kind: SkipKind, reason: str) -> None:
"""Mark the profile skipped, for a verdict and for a reader."""
self.skip_kind = kind
self.skipped = reason
def uncheckable(self) -> bool:
"""Whether the skip is a defect of the profile rather than its nature."""
return bool(self.skipped and self.skipped.startswith(self.UNCHECKABLE))
return self.skip_kind in UNCHECKABLE_SKIPS
def unreached(self) -> bool:
"""Whether a forge failing this time left the profile unread."""
return self.skip_kind in UNREACHED_SKIPS
def needs_review(self) -> int:
counts = self.counts or {}
@@ -200,6 +236,8 @@ class ProfileReport:
reasons = []
if self.uncheckable():
reasons.append(Attention("uncheckable", UNKNOWN_LEVEL, self.skipped or ""))
if self.unreached():
reasons.append(Attention("unreached", UNKNOWN_LEVEL, self.skipped or ""))
if self.page_version:
# Off any forge, the release page is the feed: a version there
# beyond the declared one is a release the profile does not cover.
@@ -409,6 +447,8 @@ def report_to_dict(report: ProfileReport) -> dict:
"""Serialisable form of one report."""
payload = asdict(report)
del payload["cited_sources"]
# The verdicts it decides are in "attention".
del payload["skip_kind"]
payload["needs_review"] = report.needs_review()
payload["attention"] = [asdict(reason) for reason in report.attention()]
return payload
+11 -8
View File
@@ -39,7 +39,7 @@ from profiling.citations import (
strip_repo_word,
symlink_target,
)
from profiling.reports import CitedSource, EntryReport, ProfileReport
from profiling.reports import CitedSource, EntryReport, ProfileReport, SkipKind
from model.profilerepos import declared_repositories
from profiling.repos import (
PIN,
@@ -237,7 +237,9 @@ def _readable_views(
]
if select_repo(profile) is None:
declared = str(profile.get("source") or profile.get("upstream") or "")
report.skipped = f"unsupported host: {declared or 'none declared'}"
report.skip(
SkipKind.UNSUPPORTED_HOST, f"unsupported host: {declared or 'none declared'}"
)
return None
stated_gone = str(profile.get("upstream_gone") or "").strip()
@@ -253,21 +255,22 @@ def _readable_views(
# The profile says the forge is gone and the forge agrees. That is
# a recorded fact, not an open problem: the refs describe the last
# revision anyone can reach, and nothing further is possible.
report.skipped = f"upstream gone (declared): {stated_gone}"
report.skip(SkipKind.GONE_DECLARED, f"upstream gone (declared): {stated_gone}")
return None
raise
if stated_gone and any(view.field != "source_mirror" for view in views):
# Declared dead, yet it answered. A profile that keeps saying so stops
# being read, so the contradiction is the finding.
report.skipped = (
f"upstream_gone is declared but the forge answers: {stated_gone}"
report.skip(
SkipKind.GONE_CONTRADICTED,
f"upstream_gone is declared but the forge answers: {stated_gone}",
)
return None
if not views and stated_gone:
report.skipped = f"upstream gone (declared): {stated_gone}"
report.skip(SkipKind.GONE_DECLARED, f"upstream gone (declared): {stated_gone}")
return None
if not views:
report.skipped = _unanswered_skip(profile)
report.skip(SkipKind.UNANSWERED, _unanswered_skip(profile))
return None
return views
@@ -918,7 +921,7 @@ def build_report(
# A profile carrying no source_ref still has a pin worth writing and a
# version worth checking, so the revisions above are resolved first.
if not refs:
report.skipped = NO_SOURCE_REF
report.skip(SkipKind.NO_SOURCE_REF, NO_SOURCE_REF)
return report
resolver = _Resolver(
+15 -16
View File
@@ -18,6 +18,7 @@ from profiling.realign import realign_prose
from profiling.rebase import attribute_refs, rebase_refs
from profiling.reports import (
ProfileReport,
SkipKind,
fetch_plan,
format_markdown,
format_report,
@@ -368,13 +369,11 @@ def read_one_profile(
# nothing about the 600 profiles on GitHub. upstream stops asking
# that host, so the rest of the pass costs it nothing.
print(f"{name}: {exc}", file=sys.stderr)
reports.append(ProfileReport(
name=name, entries=[], counts={},
skipped=f"rate limited: {exc.host or exc}",
))
failed.add(name)
return
report = _skipped(name, SkipKind.RATE_LIMITED, f"rate limited: {exc.host or exc}")
writes = False
reports.append(report)
if report.unreached():
failed.add(name)
if writes:
try:
with record_write(profile_path, name, written):
@@ -391,6 +390,13 @@ def read_one_profile(
failed.add(name)
def _skipped(name: str, kind: SkipKind, reason: str) -> ProfileReport:
"""The report of a profile no forge comparison could be made for."""
report = ProfileReport(name=name, entries=[], counts={})
report.skip(kind, reason)
return report
def read_selected(
args: argparse.Namespace, selected: dict, writes: bool
) -> tuple[list[ProfileReport], set[str], set[str], bool]:
@@ -446,24 +452,17 @@ def _build_full_report(
# Offline with a cache that never stored this file: the profile
# is unverified, not wrong. Reporting GONE sent readers after
# files that exist.
report = ProfileReport(
name=name, entries=[], counts={}, skipped=f"offline: {exc}"
)
report = _skipped(name, SkipKind.OFFLINE, f"offline: {exc}")
except upstream.GoneError as exc:
# The forge is not coming back: a takedown, or a host that no
# longer resolves. Saying so once in the summary beats repeating
# it on stderr every pass, and it keeps the profile out of the
# backlog, where nobody can act on it anyway.
report = ProfileReport(
name=name, entries=[], counts={}, skipped=f"upstream gone: {exc}"
)
report = _skipped(name, SkipKind.GONE, f"upstream gone: {exc}")
except upstream.UpstreamError as exc:
# One unreachable forge must not abandon the other profiles.
print(f"{name}: {exc}", file=sys.stderr)
report = ProfileReport(
name=name, entries=[], counts={}, skipped=f"upstream error: {exc}"
)
failed.add(name)
report = _skipped(name, SkipKind.UPSTREAM_ERROR, f"upstream error: {exc}")
if not report.skipped and profile_path.is_file():
report.stale_prose = _read_stale_prose(name, profile_path, args, failed)
if args.check_version and profile.get("version_source"):