Track release paths against the owners in a signed Vinix root
@@ -75,3 +75,15 @@ python3 tools/release-files.py "$state/all.tsv" "$state/installed" \
7575```
7676
7777`$state/installed` is from the Alpine minirootfs. Use the corresponding arm64 assets and a fresh output directory for the other target. The worker keeps the four published assets, input hashes and detailed manifests in `musl-busybox-CqkBEA/release-inputs/iso-2026-11-28`. Under each architecture, `comparison/packages.tsv` gives the input hash and counts per candidate, and `comparison/package-files.tsv` lists the evidence per path. The package summaries have SHA-256 `09ad06488a1f35e7bc6e5410e743a09f478cc5773e3227c7745c237255133017` (amd64) and `810b8612a6e786f412f1882022542978c7f43a4d2a5b328e3286fa63c021d2d4` (arm64).
78+
79+## Tracking replacement owners
80+
81+Run the owner comparison against an installed vpac root on the build worker. It reruns the installed-root auditor, then joins each published path to its actual vpac owner. It retains the original Alpine binary, version, repository and image or sidecar layer. The summary gives the expected Vinix packages, their presence in the signed root and an outstanding check for each input. To inventory an architecture awaiting its first root, omit both client options.
82+
83+```sh
84+python3 tools/release-owners.py x86_64 "$release/amd64/comparison" "$work/owners" \
85+ --client "$work/client" --auditor "$work/installed-root"
86+python3 tools/release-owners.py aarch64 "$release/arm64/comparison" "$work/arm-pending"
87+```
88+
89+The 62-package x86_64 root for the November 28 image had 3,899 matching input/layer/path observations. It had 928 with an expected owner, 117 with another owner and 2,854 without an owner in this snapshot. The same path can appear in more than one Alpine package version or release layer. Rebuilt bytes normally differ, and matching an owned path still leaves ABI and runtime behavior to verify. The arm64 baseline had 4,019 observations awaiting an installed root. The worker retains the per-row results and hashes in `amd64/owners-62` and `arm64/owners-pending` beside the release comparisons.
@@ -0,0 +1,145 @@
1+"""Compare published release inputs with package owners in an audited vpac root."""
2+import argparse
3+import csv
4+import subprocess
5+from collections import Counter, defaultdict
6+from pathlib import Path
7+
8+
9+# Most Alpine split packages are combined under their source name in Vinix.
10+# These are expected owners. Actual ownership comes from the installed database.
11+SOURCE_OWNERS = {
12+ "alpine-base": ("vinix-release",),
13+ "alpine-baselayout": ("vinix-filesystem", "vinix-accounts", "netbase"),
14+ "alpine-keys": ("vinix-keyring",),
15+ "apk-tools": ("vpac",),
16+ "hwdata": ("hwdata-pci",),
17+ "llvm17": ("llvm17-libs",),
18+ "llvm19": ("llvm19-libs",),
19+ "mpc1": ("mpc",),
20+ "mpfr4": ("mpfr",),
21+ "openssh": ("openssh-client",),
22+ "pax-utils": ("scanelf",),
23+}
24+BINARY_OWNERS = {
25+ "ca-certificates-bundle": ("ca-certificates-bundle",),
26+ "libuuid": ("libuuid",),
27+ "musl-utils": ("musl-utils",),
28+ "ssl_client": ("ssl-client",),
29+ "mesa-dev": ("mesa", "mesa-platform-headers", "mesa-gallium-sdk"),
30+ "mesa-dri-gallium": ("mesa-gallium-sdk",),
31+ "mesa-osmesa": ("mesa-gallium-sdk",),
32+ "mesa-xatracker": ("mesa-gallium-sdk",),
33+}
34+
35+
36+def providers(row):
37+ if row["origin"] == "mesa" and row["repository"] == "v3.20/main":
38+ return ("mesa-glx-legacy",)
39+ return BINARY_OWNERS.get(row["binary"], SOURCE_OWNERS.get(row["origin"], (row["origin"],)))
40+
41+
42+def field(body, name):
43+ for group in body.strip().split("\n\n"):
44+ marker, _, value = group.partition("\n")
45+ if marker == "%" + name + "%":
46+ return value.splitlines()
47+ return []
48+
49+
50+def installed(client, arch, auditor):
51+ result = subprocess.check_output([auditor, arch, client], text=True)
52+ names = set()
53+ owners = {}
54+ for description in sorted((client / "db/local").glob("*/desc")):
55+ name, = field(description.read_text(), "NAME")
56+ names.add(name)
57+ for path in field(description.with_name("files").read_text(), "FILES"):
58+ if not path.endswith("/"):
59+ if path in owners:
60+ raise ValueError(f"multiple owners for {path}")
61+ owners[path] = name
62+ return names, owners, result
63+
64+
65+def rows(path):
66+ with path.open() as stream:
67+ yield from csv.DictReader(stream, delimiter="\t")
68+
69+
70+def key(row):
71+ return row["binary"], row["version"], row["repository"]
72+
73+
74+def action(row, state, names, expected, has_client):
75+ if int(row["unavailable"]):
76+ return "obtain and compare original source input"
77+ if not state:
78+ if int(row["different"]):
79+ return "review changed published paths and identify their owner"
80+ if row["profiles"] == "x11-index-dependency":
81+ return "check whether native X11 builds require this index dependency"
82+ return "verify as a build or staging input"
83+ if not has_client:
84+ return "install and audit the target packages"
85+ if row["origin"] in ("alpine-keys", "apk-tools"):
86+ return "verify the Vinix trust and package-management replacements in the image"
87+ if not names.intersection(expected):
88+ return "build and install the expected packages"
89+ if state["unowned"] or state["other_owner"]:
90+ return "resolve missing paths, alternate owners and intentional replacements"
91+ return "verify the package behavior in the release image"
92+
93+
94+def compare(args):
95+ names, owners, audit = installed(args.client, args.arch, args.auditor) if args.client else (set(), {}, "")
96+ packages = {key(row): row for row in rows(args.comparison / "packages.tsv")}
97+ details = defaultdict(Counter)
98+ seen = set()
99+ args.output.mkdir()
100+ if audit:
101+ (args.output / "installed-root.log").write_text(audit)
102+ with (args.output / "paths.tsv").open("x") as stream:
103+ writer = csv.writer(stream, delimiter="\t", lineterminator="\n")
104+ writer.writerow(["binary", "version", "repository", "layer", "published_path",
105+ "original_comparison", "candidate_path", "installed_owner", "ownership"])
106+ for row in rows(args.comparison / "package-files.tsv"):
107+ k = key(row)
108+ path = row["published_path"]
109+ owner = owners.get(path, "")
110+ known = row["comparison"] != "different"
111+ expected = providers(packages[k])
112+ match = ("unmeasured" if not args.client else "unowned" if not owner else
113+ "expected_owner" if owner in expected else "other_owner")
114+ writer.writerow([*k, row["layer"], path, row["comparison"], row["candidate_path"], owner, match])
115+ observation = k, row["layer"], path
116+ if known and observation not in seen:
117+ seen.add(observation)
118+ details[k][match] += 1
119+ with (args.output / "packages.tsv").open("x") as stream:
120+ writer = csv.writer(stream, delimiter="\t", lineterminator="\n")
121+ writer.writerow(["binary", "version", "repository", "origin", "profiles", "expected_packages",
122+ "installed_expected_packages", "published_matching_paths", "expected_owner",
123+ "other_owner", "unowned", "unmeasured", "next_check"])
124+ for k, row in packages.items():
125+ expected = providers(row)
126+ state = details[k]
127+ writer.writerow([*k, row["origin"], row["profiles"], ",".join(expected),
128+ ",".join(sorted(names.intersection(expected))), sum(state.values()),
129+ *[state[s] for s in ("expected_owner", "other_owner", "unowned", "unmeasured")],
130+ action(row, state, names, expected, args.client is not None)])
131+ print(f"{args.arch}: {len(packages)} release input rows, {len(names)} installed packages, "
132+ f"{len(seen)} matching input/layer/path observations")
133+
134+
135+if __name__ == "__main__":
136+ parser = argparse.ArgumentParser(description=__doc__)
137+ parser.add_argument("arch", choices=("x86_64", "aarch64"))
138+ parser.add_argument("comparison", type=Path)
139+ parser.add_argument("output", type=Path)
140+ parser.add_argument("--client", type=Path, help="fresh signed vpac client to audit")
141+ parser.add_argument("--auditor", type=Path, help="compiled tests/installed-root.v")
142+ args = parser.parse_args()
143+ if bool(args.client) != bool(args.auditor):
144+ parser.error("--client and --auditor must be used together")
145+ compare(args)