feat: classify update-swarm verdicts including watchlist and Z-safe compare
This commit is contained in:
1 parent
cbe1848d10
commit
b5cce78652
2 files changed
+132
No files matched your search
@@ -0,0 +1,72 @@
|
||||
from __future__ import annotations
|
||||
from update_swarm.versions import compare_versions
|
||||
|
||||
def judge_one(job: dict, census: dict, scout: dict) -> dict:
|
||||
installed = census.get("installed_version")
|
||||
latest = scout.get("latest_english_version")
|
||||
gate = scout.get("gate")
|
||||
url = scout.get("url")
|
||||
out = {
|
||||
"stem": job["stem"],
|
||||
"bucket": "current",
|
||||
"reason": "",
|
||||
"fetch_url": None,
|
||||
"installed_version": installed,
|
||||
"latest_english_version": latest,
|
||||
"gate": gate,
|
||||
"incomparable": False,
|
||||
"bump_status": None,
|
||||
"remove_from_watchlist": False,
|
||||
}
|
||||
if not latest:
|
||||
out["reason"] = "no-latest"
|
||||
return out
|
||||
if census.get("source") == "unknown" and census.get("sha256") and scout.get("sha256"):
|
||||
if census["sha256"] == scout["sha256"]:
|
||||
out["reason"] = "hash-match"
|
||||
return out
|
||||
cmp = compare_versions(installed or "", latest) if installed else "lt"
|
||||
if installed and cmp == "incomparable":
|
||||
out["bucket"] = "incomparable"
|
||||
out["incomparable"] = True
|
||||
out["reason"] = "incomparable"
|
||||
return out
|
||||
newer = (not installed) or cmp == "lt"
|
||||
if not newer:
|
||||
out["reason"] = "up-to-date"
|
||||
return out
|
||||
complete = (scout.get("upstream_status") == "Complete")
|
||||
ungated = gate == "ungated" and url
|
||||
if job.get("watchlist"):
|
||||
if complete and ungated:
|
||||
out["bucket"] = "watchlist_promote"
|
||||
out["fetch_url"] = url
|
||||
out["remove_from_watchlist"] = True
|
||||
out["reason"] = "watchlist-complete-ungated"
|
||||
return out
|
||||
if not ungated:
|
||||
out["bucket"] = "gated_queue"
|
||||
out["bump_status"] = "Complete" if complete else None
|
||||
out["reason"] = "watchlist-gated"
|
||||
return out
|
||||
out["bucket"] = "watchlist_report"
|
||||
out["reason"] = "watchlist-demo"
|
||||
return out
|
||||
if ungated:
|
||||
out["bucket"] = "update"
|
||||
out["fetch_url"] = url
|
||||
out["reason"] = "newer-ungated"
|
||||
return out
|
||||
out["bucket"] = "gated_queue"
|
||||
out["bump_status"] = "Complete" if complete else None
|
||||
out["reason"] = "newer-gated"
|
||||
return out
|
||||
|
||||
def judge_all(jobs: list[dict], census_by_stem: dict, scouts_by_stem: dict) -> list[dict]:
|
||||
verdicts = []
|
||||
for job in jobs:
|
||||
stem = job["stem"]
|
||||
c = census_by_stem.get(stem) or {"stem": stem, "installed_version": job.get("note_version"), "source": "note" if job.get("note_version") else "unknown", "sha256": None}
|
||||
s = scouts_by_stem.get(stem) or {"stem": stem, "latest_english_version": None, "url": None, "gate": None, "upstream_status": None}
|
||||
verdicts.append(judge_one(job, c, s))
|
||||
return verdicts
|
||||
Reference in new issue
Block a user