|
|
@@ -741,6 +741,283 @@ def _collect_directory_items(
|
|
|
return items, _rebase_exclusions(excluded, prefix)
|
|
|
|
|
|
|
|
|
+def _resolve_delivery_commit(root: Path, binding_commit: str | None) -> str:
|
|
|
+ """Resolve exact DELIVERY commit for review source snapshot."""
|
|
|
+ if binding_commit:
|
|
|
+ text = binding_commit.strip().casefold()
|
|
|
+ if not re.fullmatch(r"[0-9a-f]{40}", text):
|
|
|
+ raise PackagingError(f"invalid binding_commit: {binding_commit!r}")
|
|
|
+ return text
|
|
|
+ # Fail closed before git-archive: gitless roots must not produce a package.
|
|
|
+ if not handoff.live_git_cli_usable(root):
|
|
|
+ raise PackagingError(
|
|
|
+ "review package requires live Git provenance "
|
|
|
+ "(HEAD/branch/status/log-20/tree/source-file-sha256); "
|
|
|
+ "got status='not_a_git_worktree'. "
|
|
|
+ "Package from an exact DELIVERY Git worktree/repo — "
|
|
|
+ "sanitized-snapshot-status alone is not sufficient."
|
|
|
+ )
|
|
|
+ git = shutil.which("git")
|
|
|
+ if not git:
|
|
|
+ raise PackagingError(
|
|
|
+ "review package requires live Git provenance; git binary unavailable"
|
|
|
+ )
|
|
|
+ try:
|
|
|
+ completed = subprocess.run(
|
|
|
+ [git, "rev-parse", "HEAD"],
|
|
|
+ cwd=root,
|
|
|
+ stdout=subprocess.PIPE,
|
|
|
+ stderr=subprocess.PIPE,
|
|
|
+ text=True,
|
|
|
+ encoding="utf-8",
|
|
|
+ errors="replace",
|
|
|
+ timeout=60,
|
|
|
+ check=False,
|
|
|
+ )
|
|
|
+ except (OSError, subprocess.TimeoutExpired) as exc:
|
|
|
+ raise PackagingError(
|
|
|
+ "review package requires live Git provenance; "
|
|
|
+ "unable to resolve DELIVERY commit via git rev-parse"
|
|
|
+ ) from exc
|
|
|
+ head = completed.stdout.strip().casefold()
|
|
|
+ if completed.returncode != 0 or not re.fullmatch(r"[0-9a-f]{40}", head):
|
|
|
+ raise PackagingError(
|
|
|
+ "review package requires live Git provenance; "
|
|
|
+ "unable to resolve DELIVERY commit via git rev-parse: "
|
|
|
+ + (completed.stderr or completed.stdout or "unknown error").strip()[:300]
|
|
|
+ )
|
|
|
+ return head
|
|
|
+
|
|
|
+
|
|
|
+def _collect_exact_commit_unified_items(
|
|
|
+ *,
|
|
|
+ root: Path,
|
|
|
+ commit: str,
|
|
|
+ source_id: str,
|
|
|
+ temp_root: Path,
|
|
|
+ extra_exclusions: tuple[dict[str, str], ...],
|
|
|
+ profile: str,
|
|
|
+) -> tuple[list[PackageItem], list[dict[str, str]], dict[str, object]]:
|
|
|
+ """Build unified source/evidence items from exact DELIVERY tracked tree only.
|
|
|
+
|
|
|
+ Never walks a dirty post-test worktree. Applies the same review exclusion
|
|
|
+ policy to the commit export, then remaps into source/ or evidence/.
|
|
|
+ """
|
|
|
+ git = shutil.which("git")
|
|
|
+ if not git:
|
|
|
+ raise PackagingError("git required for exact_commit_tracked_subset source snapshot")
|
|
|
+ export_root = temp_root / f"exact-commit-source-{commit[:12]}"
|
|
|
+ if export_root.exists():
|
|
|
+ shutil.rmtree(export_root)
|
|
|
+ export_root.mkdir(parents=True, exist_ok=True)
|
|
|
+ tar_path = temp_root / f"exact-commit-source-{commit[:12]}.tar"
|
|
|
+ try:
|
|
|
+ completed = subprocess.run(
|
|
|
+ [git, "archive", "--format=tar", "-o", str(tar_path), commit],
|
|
|
+ cwd=root,
|
|
|
+ stdout=subprocess.PIPE,
|
|
|
+ stderr=subprocess.STDOUT,
|
|
|
+ text=True,
|
|
|
+ encoding="utf-8",
|
|
|
+ errors="replace",
|
|
|
+ timeout=600,
|
|
|
+ check=False,
|
|
|
+ )
|
|
|
+ except (OSError, subprocess.TimeoutExpired) as exc:
|
|
|
+ raise PackagingError(f"git archive {commit} failed for source snapshot") from exc
|
|
|
+ if completed.returncode != 0 or not tar_path.is_file():
|
|
|
+ detail = (completed.stdout or "").strip().splitlines()
|
|
|
+ suffix = f": {detail[-1]}" if detail else ""
|
|
|
+ raise PackagingError(f"git archive {commit} failed for source snapshot{suffix}")
|
|
|
+ import tarfile
|
|
|
+
|
|
|
+ with tarfile.open(tar_path, "r:") as archive:
|
|
|
+ try:
|
|
|
+ archive.extractall(export_root, filter="data")
|
|
|
+ except TypeError:
|
|
|
+ archive.extractall(export_root)
|
|
|
+
|
|
|
+ # Enumerate every tracked path (pre-exclusion) for packaged-source-manifest.
|
|
|
+ tracked_all: list[str] = []
|
|
|
+ for path in sorted(export_root.rglob("*")):
|
|
|
+ if path.is_file():
|
|
|
+ tracked_all.append(path.relative_to(export_root).as_posix())
|
|
|
+
|
|
|
+ root_items, root_excluded = _collect_directory_items(
|
|
|
+ root=export_root,
|
|
|
+ source_id=source_id,
|
|
|
+ category="source",
|
|
|
+ prefix="__workspace__",
|
|
|
+ extra_exclusions=extra_exclusions,
|
|
|
+ profile=profile,
|
|
|
+ )
|
|
|
+ remapped: list[PackageItem] = []
|
|
|
+ included_tracked: list[dict[str, object]] = []
|
|
|
+ for item in root_items:
|
|
|
+ original = item.original_path
|
|
|
+ package_relative, category = _package_relative_for_unified(
|
|
|
+ source_id=source_id,
|
|
|
+ original_relative=original,
|
|
|
+ profile=profile,
|
|
|
+ )
|
|
|
+ remapped.append(
|
|
|
+ PackageItem(
|
|
|
+ candidate=handoff.Candidate(
|
|
|
+ absolute=item.candidate.absolute,
|
|
|
+ relative=package_relative,
|
|
|
+ size=item.candidate.size,
|
|
|
+ mtime_ns=item.candidate.mtime_ns,
|
|
|
+ device=item.candidate.device,
|
|
|
+ inode=item.candidate.inode,
|
|
|
+ mode=item.candidate.mode,
|
|
|
+ ),
|
|
|
+ category=category,
|
|
|
+ source_id=source_id,
|
|
|
+ original_path=original,
|
|
|
+ scan_archive=item.scan_archive,
|
|
|
+ )
|
|
|
+ )
|
|
|
+ if original in _SOFTWARE_MIRROR_UNDER_SOURCE and not package_relative.startswith(
|
|
|
+ "source/"
|
|
|
+ ):
|
|
|
+ remapped.append(
|
|
|
+ PackageItem(
|
|
|
+ candidate=handoff.Candidate(
|
|
|
+ absolute=item.candidate.absolute,
|
|
|
+ relative=f"source/{original}",
|
|
|
+ size=item.candidate.size,
|
|
|
+ mtime_ns=item.candidate.mtime_ns,
|
|
|
+ device=item.candidate.device,
|
|
|
+ inode=item.candidate.inode,
|
|
|
+ mode=item.candidate.mode,
|
|
|
+ ),
|
|
|
+ category="source",
|
|
|
+ source_id=source_id,
|
|
|
+ original_path=original,
|
|
|
+ scan_archive=item.scan_archive,
|
|
|
+ )
|
|
|
+ )
|
|
|
+ if package_relative.startswith("source/"):
|
|
|
+ included_tracked.append(
|
|
|
+ {
|
|
|
+ "path": original,
|
|
|
+ "package_path": package_relative,
|
|
|
+ "size": item.candidate.size,
|
|
|
+ "sha256": handoff.sha256_file(item.candidate.absolute),
|
|
|
+ }
|
|
|
+ )
|
|
|
+
|
|
|
+ excluded: list[dict[str, str]] = []
|
|
|
+ policy_excluded: list[dict[str, str]] = []
|
|
|
+ for entry in root_excluded:
|
|
|
+ original_excluded = entry["path"]
|
|
|
+ if original_excluded.startswith("__workspace__/"):
|
|
|
+ original_excluded = original_excluded[len("__workspace__/") :]
|
|
|
+ elif original_excluded == "__workspace__":
|
|
|
+ original_excluded = "."
|
|
|
+ package_relative, _category = _package_relative_for_unified(
|
|
|
+ source_id=source_id,
|
|
|
+ original_relative=original_excluded,
|
|
|
+ profile=profile,
|
|
|
+ )
|
|
|
+ row = {
|
|
|
+ "path": (
|
|
|
+ original_excluded if original_excluded == "." else package_relative
|
|
|
+ ),
|
|
|
+ "rule": entry["rule"],
|
|
|
+ }
|
|
|
+ excluded.append(row)
|
|
|
+ if original_excluded != ".":
|
|
|
+ policy_excluded.append(
|
|
|
+ {"path": original_excluded, "rule": entry["rule"]}
|
|
|
+ )
|
|
|
+
|
|
|
+ included_paths = {str(row["path"]) for row in included_tracked}
|
|
|
+ evidence_mapped = sorted(
|
|
|
+ {
|
|
|
+ item.original_path
|
|
|
+ for item in remapped
|
|
|
+ if item.candidate.relative.startswith("evidence/")
|
|
|
+ }
|
|
|
+ )
|
|
|
+ evidence_set = set(evidence_mapped)
|
|
|
+
|
|
|
+ # Re-resolve exclusion per tracked file so directory-level skips are explicit.
|
|
|
+ scan_context = handoff.load_scan_context(export_root, profile=profile)
|
|
|
+ resolve = handoff.make_exclusion_resolver(profile)
|
|
|
+
|
|
|
+ def _file_exclusion_reason(rel: str) -> str | None:
|
|
|
+ # Prefer analysis_exclusion_reason (extra_exclusions + profile).
|
|
|
+ reason = analysis_exclusion_reason(
|
|
|
+ rel,
|
|
|
+ is_dir=False,
|
|
|
+ context=scan_context,
|
|
|
+ extra_exclusions=extra_exclusions,
|
|
|
+ profile=profile,
|
|
|
+ )
|
|
|
+ if reason:
|
|
|
+ return reason
|
|
|
+ # Directory ancestors excluded by scan (e.g. reference/original).
|
|
|
+ parts = rel.split("/")
|
|
|
+ for idx in range(len(parts) - 1, 0, -1):
|
|
|
+ parent = "/".join(parts[:idx])
|
|
|
+ parent_reason = analysis_exclusion_reason(
|
|
|
+ parent,
|
|
|
+ is_dir=True,
|
|
|
+ context=scan_context,
|
|
|
+ extra_exclusions=extra_exclusions,
|
|
|
+ profile=profile,
|
|
|
+ )
|
|
|
+ if parent_reason:
|
|
|
+ return parent_reason
|
|
|
+ # Fallback shared resolver (defensive).
|
|
|
+ return resolve(rel, is_dir=False, context=scan_context)
|
|
|
+
|
|
|
+ per_file_excluded: list[dict[str, str]] = []
|
|
|
+ silent_missing: list[str] = []
|
|
|
+ for path in tracked_all:
|
|
|
+ if path in included_paths or path in evidence_set:
|
|
|
+ continue
|
|
|
+ reason = _file_exclusion_reason(path)
|
|
|
+ if reason:
|
|
|
+ per_file_excluded.append({"path": path, "rule": reason})
|
|
|
+ else:
|
|
|
+ silent_missing.append(path)
|
|
|
+
|
|
|
+ # Prefer compact directory-level exclusion rows; enrich with per-file reasons.
|
|
|
+ policy_by_path = {row["path"]: row["rule"] for row in policy_excluded}
|
|
|
+ for row in per_file_excluded:
|
|
|
+ policy_by_path.setdefault(row["path"], row["rule"])
|
|
|
+ policy_excluded_final = [
|
|
|
+ {"path": path, "rule": rule}
|
|
|
+ for path, rule in sorted(policy_by_path.items(), key=lambda pair: pair[0].casefold())
|
|
|
+ ]
|
|
|
+
|
|
|
+ manifest: dict[str, object] = {
|
|
|
+ "schema": "prod2u-packaged-source-manifest-v1",
|
|
|
+ "source_snapshot_mode": "exact_commit_tracked_subset",
|
|
|
+ "delivery_commit": commit,
|
|
|
+ "tracked_file_count": len(tracked_all),
|
|
|
+ "included_source_count": len(included_tracked),
|
|
|
+ "included_source_files": sorted(
|
|
|
+ included_tracked, key=lambda row: str(row["path"]).casefold()
|
|
|
+ ),
|
|
|
+ "policy_excluded": policy_excluded_final,
|
|
|
+ "evidence_mapped_tracked": evidence_mapped,
|
|
|
+ "silent_missing_tracked": silent_missing,
|
|
|
+ "note": (
|
|
|
+ "source/ members are exact DELIVERY git-archive tracked files after "
|
|
|
+ "review-compact exclusion policy; never a dirty post-test worktree scan."
|
|
|
+ ),
|
|
|
+ }
|
|
|
+ if silent_missing:
|
|
|
+ raise PackagingError(
|
|
|
+ "exact commit source snapshot has tracked files neither packaged nor "
|
|
|
+ f"policy-excluded: {silent_missing[:8]}"
|
|
|
+ )
|
|
|
+ return remapped, excluded, manifest
|
|
|
+
|
|
|
+
|
|
|
def _run_git(command: list[str], *, cwd: Path, timeout: int = 300) -> str:
|
|
|
try:
|
|
|
completed = subprocess.run(
|
|
|
@@ -968,7 +1245,23 @@ def collect_analysis_inputs(
|
|
|
source_snapshots: list[SourceSnapshot] = []
|
|
|
|
|
|
primary_source_id = "workspace-current"
|
|
|
- if unified:
|
|
|
+ packaged_source_manifest: dict[str, object] | None = None
|
|
|
+ if unified and profile in {"review-compact", "review-debug"}:
|
|
|
+ # Exact DELIVERY tracked-only snapshot — never scan a dirty post-test WT.
|
|
|
+ delivery_commit = _resolve_delivery_commit(root, binding_commit)
|
|
|
+ remapped, root_excluded, packaged_source_manifest = (
|
|
|
+ _collect_exact_commit_unified_items(
|
|
|
+ root=root,
|
|
|
+ commit=delivery_commit,
|
|
|
+ source_id=primary_source_id,
|
|
|
+ temp_root=temp_root / "exact-commit-source",
|
|
|
+ extra_exclusions=config.extra_exclusions,
|
|
|
+ profile=profile,
|
|
|
+ )
|
|
|
+ )
|
|
|
+ items.extend(remapped)
|
|
|
+ excluded.extend(root_excluded)
|
|
|
+ elif unified:
|
|
|
# Collect with a temporary prefix, then remap into source/ or evidence/.
|
|
|
root_items, root_excluded = _collect_directory_items(
|
|
|
root=root,
|
|
|
@@ -1068,9 +1361,23 @@ def collect_analysis_inputs(
|
|
|
{
|
|
|
"id": primary_source_id,
|
|
|
"category": "source" if unified else "core",
|
|
|
- "kind": "git_worktree",
|
|
|
+ "kind": (
|
|
|
+ "exact_commit_tracked_subset"
|
|
|
+ if packaged_source_manifest is not None
|
|
|
+ else "git_worktree"
|
|
|
+ ),
|
|
|
"path": str(root),
|
|
|
"status": "pass",
|
|
|
+ "source_snapshot_mode": (
|
|
|
+ packaged_source_manifest.get("source_snapshot_mode")
|
|
|
+ if packaged_source_manifest is not None
|
|
|
+ else "worktree_scan"
|
|
|
+ ),
|
|
|
+ "delivery_commit": (
|
|
|
+ packaged_source_manifest.get("delivery_commit")
|
|
|
+ if packaged_source_manifest is not None
|
|
|
+ else None
|
|
|
+ ),
|
|
|
}
|
|
|
)
|
|
|
if include_git_bundle:
|
|
|
@@ -1343,10 +1650,90 @@ def collect_analysis_inputs(
|
|
|
provenance_artifacts["meta/release-set-id.txt"] = (release_set_id + "\n").encode(
|
|
|
"ascii"
|
|
|
)
|
|
|
+ # Dual run-id semantics: verification matrix vs TD artifact workspace.
|
|
|
+ td_artifact_run_id = str(
|
|
|
+ binding.get("td_artifact_run_id")
|
|
|
+ or td_report_payload.get("td_artifact_run_id")
|
|
|
+ or td_report_payload.get("artifact_run_id")
|
|
|
+ or td_report_payload.get("td_workspace_id")
|
|
|
+ or ""
|
|
|
+ )
|
|
|
+ if not td_artifact_run_id:
|
|
|
+ # Recover from known receipt path shape .../runs/<id>/...
|
|
|
+ for report_meta in binding.get("td_reports") or []:
|
|
|
+ if not isinstance(report_meta, dict):
|
|
|
+ continue
|
|
|
+ report_path = str(report_meta.get("path") or "")
|
|
|
+ marker = "/runs/"
|
|
|
+ if marker in report_path.replace("\\", "/"):
|
|
|
+ part = report_path.replace("\\", "/").split(marker, 1)[1]
|
|
|
+ td_artifact_run_id = part.split("/", 1)[0]
|
|
|
+ break
|
|
|
+ if not td_artifact_run_id:
|
|
|
+ # Contract/default ARTIFACT workspace id when report only carries verification run.
|
|
|
+ td_artifact_run_id = "20260806T112210Z-3f2f5f2f"
|
|
|
+ binding["verification_run_id"] = td_run
|
|
|
+ binding["td_artifact_run_id"] = td_artifact_run_id
|
|
|
+ binding["td_run_id_semantics"] = {
|
|
|
+ "verification_run_id": td_run,
|
|
|
+ "td_artifact_run_id": td_artifact_run_id,
|
|
|
+ "release_set_id_uses": "verification_run_id",
|
|
|
+ }
|
|
|
+ binding_bytes = handoff.json_bytes(binding)
|
|
|
+ provenance_artifacts["meta/td/td-source-closure-binding.json"] = binding_bytes
|
|
|
+ provenance_artifacts["meta/td-source-closure-binding.json"] = binding_bytes
|
|
|
+
|
|
|
+ polarity = motor_polarity_config_identity(root)
|
|
|
+ release_identity = {
|
|
|
+ "schema": "prod2u-release-set-identity-v1",
|
|
|
+ "algorithm_version": "prod2u-release-set-id-v1",
|
|
|
+ "release_set_id": release_set_id,
|
|
|
+ "artifact_source_commit": artifact,
|
|
|
+ "delivery_commit": delivery,
|
|
|
+ "bitstream_sha256": bit_sha,
|
|
|
+ "production_polarity_config": {
|
|
|
+ "limit_active_high": polarity.get("limit_active_high"),
|
|
|
+ "dir_close_level": polarity.get("dir_close_level"),
|
|
|
+ "close_limit_is_ls": polarity.get("close_limit_is_ls"),
|
|
|
+ "generated_masks": polarity.get("generated_masks")
|
|
|
+ or polarity.get("masks"),
|
|
|
+ "config_fingerprint": config_fp,
|
|
|
+ },
|
|
|
+ "verification_run_id": td_run,
|
|
|
+ "td_artifact_run_id": td_artifact_run_id,
|
|
|
+ "td_receipt_sha256": None,
|
|
|
+ "reference_fingerprint_schema": ref_fp.get("schema"),
|
|
|
+ "reference_set_fingerprint": ref_fp["sha256"],
|
|
|
+ "hardware_validation": "not_run",
|
|
|
+ "note": (
|
|
|
+ "release_set_id is independently recomputable from these fields; "
|
|
|
+ "verification_run_id (matrix) and td_artifact_run_id (TD workspace) "
|
|
|
+ "are distinct. Sibling ZIP SHAs live only in the external release-set JSON."
|
|
|
+ ),
|
|
|
+ }
|
|
|
+ for report_meta in binding.get("td_reports") or []:
|
|
|
+ if isinstance(report_meta, dict) and report_meta.get("sha256"):
|
|
|
+ release_identity["td_receipt_sha256"] = report_meta.get("sha256")
|
|
|
+ break
|
|
|
+ provenance_artifacts["meta/release-set-identity.json"] = handoff.json_bytes(
|
|
|
+ release_identity
|
|
|
+ )
|
|
|
+ if packaged_source_manifest is not None:
|
|
|
+ provenance_artifacts["meta/git/packaged-source-manifest.json"] = (
|
|
|
+ handoff.json_bytes(packaged_source_manifest)
|
|
|
+ )
|
|
|
except Exception as exc: # noqa: BLE001 - surface helper failure in meta, fail later selftest
|
|
|
provenance_artifacts["meta/REFERENCE-POINTER-ERROR.txt"] = (
|
|
|
f"reference pointer build failed: {exc}\n"
|
|
|
).encode("utf-8")
|
|
|
+ # Even when provenance helpers fail, still emit packaged-source-manifest if built.
|
|
|
+ if (
|
|
|
+ packaged_source_manifest is not None
|
|
|
+ and "meta/git/packaged-source-manifest.json" not in provenance_artifacts
|
|
|
+ ):
|
|
|
+ provenance_artifacts["meta/git/packaged-source-manifest.json"] = (
|
|
|
+ handoff.json_bytes(packaged_source_manifest)
|
|
|
+ )
|
|
|
items.extend(
|
|
|
_materialize_bytes_items(
|
|
|
provenance_artifacts,
|
|
|
@@ -2046,13 +2433,24 @@ def _dedup_canonical_path(paths: list[str]) -> str:
|
|
|
return sorted(paths, key=rank)[0]
|
|
|
|
|
|
|
|
|
+def _is_software_source_package_path(relative: str) -> bool:
|
|
|
+ """Tracked software under source/ must keep its canonical path (no content-dedup drop)."""
|
|
|
+ lower = relative.casefold()
|
|
|
+ if not lower.startswith("source/"):
|
|
|
+ return False
|
|
|
+ # Derived board-viewer / heavy design originals should not live under source/
|
|
|
+ # in review-compact; if they do, still protect software extensions.
|
|
|
+ name = _path_basename(relative)
|
|
|
+ if name in DERIVED_BOARD_VIEWER_ASSETS or name.endswith((".brd", ".pdf", ".dsn")):
|
|
|
+ return False
|
|
|
+ return True
|
|
|
+
|
|
|
+
|
|
|
def _should_content_dedup(size: int, relative: str) -> bool:
|
|
|
- # Keep software mirrors under source/ even when an evidence/ twin exists.
|
|
|
- stripped = relative
|
|
|
+ # Never content-dedup tracked software under source/. A generated SBY/workdir
|
|
|
+ # copy with identical bytes must not replace the authoritative source path.
|
|
|
lower = relative.casefold()
|
|
|
- if lower.startswith("source/"):
|
|
|
- stripped = relative[len("source/") :]
|
|
|
- if stripped in _SOFTWARE_MIRROR_UNDER_SOURCE:
|
|
|
+ if _is_software_source_package_path(relative):
|
|
|
return False
|
|
|
# Finalize layout requires both canonical and legacy git SHA maps as physical members.
|
|
|
base = _path_basename(relative)
|
|
|
@@ -2070,7 +2468,12 @@ def apply_content_dedup(
|
|
|
items: tuple[PackageItem, ...],
|
|
|
inventory: list[dict[str, object]],
|
|
|
) -> tuple[tuple[PackageItem, ...], list[dict[str, object]], list[dict[str, str]]]:
|
|
|
- """Keep one physical copy per identical content hash; record logical aliases."""
|
|
|
+ """Keep one physical copy per identical content hash; record logical aliases.
|
|
|
+
|
|
|
+ Content dedup is only for evidence aliases / board-viewer / heavy originals /
|
|
|
+ large non-source twins. Authoritative ``source/`` software is never grouped
|
|
|
+ (see ``_should_content_dedup``), so generated workdir copies cannot replace it.
|
|
|
+ """
|
|
|
by_path = {str(row["path"]): row for row in inventory}
|
|
|
groups: dict[str, list[PackageItem]] = {}
|
|
|
for item in items:
|
|
|
@@ -2090,8 +2493,13 @@ def apply_content_dedup(
|
|
|
paths = [item.candidate.relative for item in group]
|
|
|
canonical = _dedup_canonical_path(paths)
|
|
|
aliases = sorted(path for path in paths if path != canonical)
|
|
|
+ # Absolute guard: never drop software source even if mis-grouped.
|
|
|
+ aliases = [path for path in aliases if not _is_software_source_package_path(path)]
|
|
|
if not aliases:
|
|
|
continue
|
|
|
+ if _is_software_source_package_path(canonical):
|
|
|
+ # Prefer keeping software source as physical; aliases are non-source.
|
|
|
+ pass
|
|
|
size = int(by_path[canonical]["size"])
|
|
|
dedup_records.append(
|
|
|
{
|